problems with shadow mapping(frontface culling, depth texture)

Started by
4 comments, last by sobeit 9 years, 9 months ago

I'm trying to implement Variance Shadow Mapping. As I searched around I found many sites mentioned that frontface culling could reduce self-shadowing artifacts, but I failed to generate shadow map whenever I turned on frontface culling, and I think it's reasonable, because all the front facing triangle would be culled out. I mean let's imagine your eyes are camera and there's a counter-clock winding(front facing) triangle in front of you, then you do a frontface culling and throw the triangle away, now how could you get the depth of the back face of that triangle? Could someone explain this to me?

another question is: when I render depth to texture, OpenGL would convert x and y from normal device coordinate to texture coordinate(from [-1, 1] to [0, 1]), does the same goes to z axis?

Advertisement

then you do a frontface culling and throw the triangle away, now how could you get the depth of the back face of that triangle? Could someone explain this to me?

You do not disable culling, just redefine what is front face, wheather it clockwise or , counter clockwise.

Just switch the front face identification by winding, this will render the actual "backfaces" now front faces and not render the actual "frontfaces" now backfaces. Do not disable culling, reverse it for the front face, and keep culling backface. Rememeber that vertex attributes such as normals will be bogus by this, so stick to only position and rasterized depth and such.

This article disusses various shadow mapping techniques and concludes that front-face culling is as good as any.

Front-face culling (with back-face culling disabled) renders the back-faces, which creates essentially the same shadows but eliminates some artifacts. However, as discussed in that article, if you have objects with no back-faces (billboards, alpha-blended foliage, etc. - objects with no back-faces), some objects will not cast shadows.

how could you get the depth of the back face of that triangle?

You don't. You render the back-faces to get the depth of the rear of the object (ONLY if it has rear-facing triangles.) Think of front-face culling / back-face rendering as, e.g., rendering the rear half of a sphere. You get the same shadow.

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 guys, I think I got it. Front face culling would fail shadow map generation for flat objects with no thickness.

anyone know answers of my second question?

When the shadow map texture is being generated, the depth is (normally) set to pos.z/pos.w (homogeneous depth).

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.

When the shadow map texture is being generated, the depth is (normally) set to pos.z/pos.w (homogeneous depth).

Thank you Buckeye

I wrote gl_FragCoord.z to texture and it ranges for 0 to 1.

This topic is closed to new replies.

Advertisement