Odd self shadowing question

Started by
1 comment, last by BloodOrange1981 9 years, 1 month ago

Hi!

I've solved a self shadowing issue, but the solution was the opposite to what I expected. I had a mesh and a simple plane with the meshes' shadow being rendered on the plane via shadowmapping.

When rendering from the light's POV of course I culled front faces and rendered back faces of the mesh. There was some pretty bad self shadowing on the final image so I thought that the back and front sides of the mesh may have been too close to each other leading to problems in the depth values being compared. Therefore I thought scaling the mesh would help.

I scaled the mesh to 200% of its size in every direction, with the thought that the two sides of the mesh would be further apart and so the depth values for comparison would be wider apart. Yet, the self shadowing was in fact much worse.

I then tried the counter-intuitive solution of making the mesh smaller by 50% in each direction, and that solved the problem.

Why is this?

Advertisement

You use the term "self shadowing" which can have several definitions and causes. Among the causes for artifacts (a more general term) is the closeness of depth values between the shadow map and the scene depth. That closeness can result from several factors - one of which is the difference between shadow map texels and scene pixels. That is, the shadow map characterizes a texel at a single depth. From the scene point of view, that texel may be sampled for several pixels to be rendered. If the scene depth varies over those pixels (particularly along edges or faces with high slope values with respect to the view direction), those depths will all be compared to the same depth in the shadow map. EDIT: that is, when pixels are rendered close to the edge of an object, some of the pixels are at "background" depth. When the edge of the object is rendered adjacent to a "background" pixel, the depth decreases dramatically. However, both the "background" pixels and the closer object pixels may all be at the same texel location in the shadow map.

The closer an object is to the near-plane in a scene, the more pixels are rendered, and the more likely a single shadow map texel will be sampled for multiple pixels. It may be that by scaling the mesh, you're reducing the number of pixels in the scene that are compared to a single texel.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Thank you! That's an interesting block of info regarding sampling a single texel for several projected points on a mesh.

This topic is closed to new replies.

Advertisement