I have a couple of shader questions, and might continue this thread as I have a feeling that there are more to come
When you create a ShaderMaterial using Cyos, the worldViewProjection is added as a uniform. This way, the shader is local to the mesh and doesn’t change based on the position of the mesh. This is something I’m after, but somehow unable to achieve with the pbrCustomMaterial
Here’s an example of a moving sphere using the pbrCustomMaterial: https://www.babylonjs-playground.com/#LIVRIY#17
Here’s an example of a moving sphere using the ShaderMaterial: https://playground.babylonjs.com/#1EG6VC#1
What I want, is for the first example to behave like the second one. I am sending the worldViewProjection matrix to the shader using what I found in the ShaderMaterial source, but whenever I try using it, the mesh disappears.
- What am I doing wrong?
- Is there any way of changing the emissive color in the pbrCustomShader? If I wanted to use the above effect only as emissive color, is this possible without making another injection point in the shader, just after:
vec3 finalEmissive = vEmissiveColor;
#ifdef EMISSIVE
vec3 emissiveColorTex = texture2D(emissiveSampler, vEmissiveUV + uvOffset).rgb;
finalEmissive *= toLinearSpace(emissiveColorTex.rgb);
finalEmissive *= vEmissiveInfos.y;
<—
#endif