Hi,
I have a custom shader that highlights some parts of a ground (a plane that uses a heigh map), but the problem I have is that I don’t have shadows on it. My current guesses are:
- I don’t have shadows because those were drawn by a shader and my current shader is replacing them.
- To fix this I need to add the shadow adding process to my custom shader.
I’ve got some code from some ansers in this forum that I think it could help me, although I’m a bit lost in how to implement it:
customMaterial.setTexture("shadowSampler0", light.getShadowGenerator().getShadowMapForRendering());
customMaterial.setMatrix("lightMatrix0", light.getShadowGenerator().getTransformMatrix());
customMaterial.setVector3("shadowsInfo0", light.getShadowGenerator().getDarkness(), light.getShadowGenerator().getShadowMap().getSize().width, light.getShadowGenerator().bias);
I guess what this does is to set the shadow and light information in the shader. But I’m not sure how to use that information inside the shader (assuming that code above is correct).
Another option, I guess, is just to pick the default shader that I’m guessing babylon uses and customize its behavior so it also adds the highlighting I need. But I’m not sure how to do that or where to find that code, or if the approach makes sense.
Thanks,
Hugo