Import CustomShaderMaterial

There is a line, it is:

import CustomShaderMaterial from 'three-custom-shader-material/vanilla'

When I run it I get error:

Uncaught TypeError: The specifier “three-custom-shader-material/vanilla” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.

I need to modify the three-custom… part.
So that it works without npm.
It probably needs to be three/addons/… something.

I have googled it a lot but to no avail.

This is a sample code in Learnjs, 4th version. Chapter 4.

Does anybody know the import CustomShaderMaterial command i’m looking for?

Are you referring to this npm package? I’m not sure you’ll be able to use this with import maps outside of npm without a lot of hassle as it has 4 other npm dependencies and 13 other npm dev dependencies… What you can try is importing the CDN version, otherwise three has an inbuilt ShaderMaterial that you can compile with shader chunks from other materials or you can use onBeforeCompile on existing materials to include your desired fragment and vertex shader chunks…

1 Like