I’ve noticed a behaviour in three that I think is a bit strange. I’m working with a scene where I’m using a
VSMShadowMap for a topography mesh on top of a mapbox scene. I’m using a transparent topography mesh with a
ShadowMaterial that is placed slightly above the mapbox scene to give the illusion that the shadows are placed on the map. The problem I have is the following:
When I have a topography mesh that recieves the shadows is double curved, I sometimes get strange artefacts when the sun position is low. Have a look at this
After looking at when this occures, this is my guess at what is happening:
Do you have ideas or suggestions on how to fix this?
Would it be possible to visualize the transparent topography mesh? This is just to see whether there is any relation between its shape and the issue with the shadow.
Sometimes shadows can be cut off because of the size of the shadow map, because of the frustum of the shadow camera and so on, so a
light.shadow.camera might give a hint too.
If you change the type of shadow, do you still get the same problem?
thank you so much for your reply, I really appreciate it. I’ve done what you suggested and this is the result
Here I’m using a
MeshPhongMaterial instead of a
ShadowMaterial for the topography mesh. I’d say that it looks much better, but it is sill not perfect and it also creates other issues such as that the scene is much darker. I probably don’t want to use this but maybe it makes it easier to debug the issue.
I also added a camera helper like you said and as you can see, the relevant part of the scene is inside the frustum of the directional lights shadow camera.
I’m not sure if this is telling me so much but maybe it can help you to understand what the issue is when I use the ShadowMaterial.
Here are some more pictures of the scene with the new settings:
Oh, it appears that your topography mesh is the ground! Initially I thought it is something in the air hovering above the city.
I have the following (sad) experience with shadows. Sometimes (it depends on type of shadow, level of bias and normal bias) I have a shadow that is torn away from the object; as if parts of the object do not generate shadows. Maybe your case is a similar one?
If you want to see whether your case is the same, use the most simple shadow type
BasicShadowMap, remove all extra parameter settings (like bias-es), but keep the shadow map size the same. I’d expect that the problem will be gone (i.w. there will be no bright fragments), but at the cost of a very ugly shadow.
That why need example link always
Hello again @PavelBoytchev,
thank you for your response again, really appreciate it. I’ll try this as soon as I have time and update the results here. I’m sorry if my first post was unclear so I’ve drawn a picture of how it works for future reference in this thread. I’ll also try to provide an example link so it’s easier to debug, but it is quite tricky since the code is divided into multiple files but I’ll give it a shot.
I’ve done some more research on this and I’ve realized that my original idea of the issue was wrong. The issue is actually exactly what’s described here:
I’m still not sure how to solve this issue in three though, so any suggestions would be much appreciated!
Unity and Three.js have different code base, so the reason for some side effect in Unity might differ (or might not differ!!!) from the reason of the same side effect in Three.js.
Could you recreate the problem in CodePen, so that it is possible to experiment with the scene? You don’t need to recreate the map or the buildings, just a self-shadowing terrain and a sun light just above the horizon.