Translucency not working with shadows

Hello,

I tested a few things around the translucent shader from the examples (https://threejs.org/examples/webgl_materials_translucency.html) and always ran into errors until I finally found the cause: it seems it is not working with shadows enabled. Is that true? Can that be changed? It would be a pity to have to choose between translucency or shadow casting. To recreate the error just add a “renderer.shadowMap.enabled = true;” to the example. Here is an excerpt of the error message:

THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog No compiled fragment shader when at least one graphics shader is attached.
THREE.WebGLShader: gl.getShaderInfoLog() fragment
ERROR: 0:576: ‘directionalShadowMap’ : undeclared identifier
ERROR: 0:576: ‘expression’ : left of ‘[’ is not of type array, matrix, or vector
ERROR: 0:576: ‘vDirectionalShadowCoord’ : undeclared identifier
ERROR: 0:576: ‘expression’ : left of ‘[’ is not of type array, matrix, or vector
ERROR: 0:576: ‘getShadow’ : no matching overloaded function found

Thanks,
Bob

Shaders from the examples directory do not necessarily support all features of built-in materials. Unfortunately, it’s not trivial to add this features this since the respective shader needs to be enhanced with additional shader chunks. This task requires a good understanding of three.js shader lib.

Thanks a lot for the quick clarification! I see, well, then I unfortunately have to deal with it someway else. It would be great though, if there was a little more documentation for the examples. Of course I am still in the early learning stage, so it took me much longer, but I needed several hours to find the reason, why it is not working. Some basic instructions what works and what not would have saved some time and would take out the guesswork. Or did I miss something?

Thanks,
Bob

All the documentation is written by the community, and the reason that some examples don’t have docs is simply that nobody has the time to do it. If you want to contribute, adding even skeleton pages for examples would be great.

See this page as a reference:
https://threejs.org/docs/index.html#examples/en/loaders/GLTFLoader

There’s an edit button in the bottom right that will bring you to the source code.

2 Likes