Custom GLSL bug, 'vIndirectFront' : undeclared identifier

Hi ! I’m trying to make this codepen works in last Three.js versions : and there is my current version :

I tried to change ShaderMaterial to RawShaderMaterial and get different errors. And I don’t have the knowledge to identify where the errors comme from. I have looked for lasts versions and updates from the Three.js library without seeing any changements about the integration.

Thank you in advance !

I recommend to us Material.onBeforeCompile() for such modifications since it makes the implementation of custom shader enhancements easier. Check out with the following live example how this approach improves the readability of your program.

Thank you so much ! I personnaly prefer to have all GLSL handled like the codepen but I learned many things with your proposition ! Do you know the reason why those errors appears with the last versions ?

The code in shader chunks might change over time. This can easily break custom shaders, especially if they are written from scratch with ShaderMaterial or RawShaderMaterial and reuse shader chunks. Using Material.onBeforeCompile() makes custom materials less fragile in that regard.

1 Like