Jump to content
  • Advertisement
Sign in to follow this  
sobeit

OpenGL problems with shadow mapping(frontface culling, depth texture)

This topic is 1518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Edited by JohnnyCode

Share this post


Link to post
Share on other sites

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.

Edited by Buckeye

Share this post


Link to post
Share on other sites

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?

Edited by sobeit

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by sobeit

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!