With ShadowMaterial you can create a plane and show how shadow is casting on a plane from a single light.
Although this material works well and renders fast it doesn’t look like a baked shadow:
I’m trying to cast 2 shadows on a single ShadowMaterial plane.
First origin of shadow - light source 1 (figure 1):
Second origin of shadow - light source 2 (figure 2):
When casting shadows from both light the plane either has shadow or not. There’s no difference between a spot on the plane that has 2 light sources that are casting shadows, only 1 light that is casting shadow.
It always looks like figure 1.
Can I influence differently on several points on the ShadowMaterial so the opacity value will render differently, not just 0 or myShadowMaterial.opacity?
Backing shadow maps is:
- Manual process.
- Will not change according to the lights position - static.
I’m not sure I understand this. Do you mind demonstrating the issue with a live example?
Thanks for addressing the issue.
There are 3 scenarios:
- A plane with 2 source lights and no occlusion.
- A plane with 2 source lights when 1 is casting shadow (occluded) and the other is not.
- A plane with 2 occluding source lights.
The problem is, while using ShadowMaterial, that options 2 and 3 will look the same although in reality they won’t.
I believe I was.
The shadows looks perfect and you can even set the opacity of the plane to 0 and still get the shadow effect just like you would in ShadowMaterial.
Beside the fact that it doesn’t look straightforward to implement (maybe we can use onBeforeRender for that?), it looks like you need to render the scene 4 times for each frame.
How will it effect on the performance?
Should I expect similar impact as with the Reflector component?
I’m happy to report that preformance are looking really good. Couldn’t notice any lags.
Can those shader take the opacity value under a consideration?
This backed shadow for example does that.
On your example I see that you are replacing this glsl line of code:
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
with this one:
gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );
I have tried to replace it with this one:
gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness * opacity );
but it doesn’t seems to have any effect on the outcome:
I see now that the opacity refers to the
MeshBasicMaterial so that obviously won’t work.