Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


problems with shadow mapping(frontface culling, depth texture)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 sobeit   Members   -  Reputation: 439

Like
0Likes
Like

Posted 24 June 2014 - 01:47 AM

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?



Sponsor:

#2 JohnnyCode   Members   -  Reputation: 259

Like
0Likes
Like

Posted 24 June 2014 - 06:18 AM

 

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, 24 June 2014 - 06:19 AM.


#3 Buckeye   Crossbones+   -  Reputation: 5580

Like
0Likes
Like

Posted 24 June 2014 - 07:00 AM

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, 24 June 2014 - 07:07 AM.

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


#4 sobeit   Members   -  Reputation: 439

Like
0Likes
Like

Posted 24 June 2014 - 10:26 AM

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, 24 June 2014 - 10:27 AM.


#5 Buckeye   Crossbones+   -  Reputation: 5580

Like
0Likes
Like

Posted 24 June 2014 - 02:46 PM

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.


#6 sobeit   Members   -  Reputation: 439

Like
0Likes
Like

Posted 24 June 2014 - 03:14 PM

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, 24 June 2014 - 08:38 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS