Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

cippyboy

Quick Shadow question

This topic is 5491 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 succeded in seeing some effects from a triangle cast on a plane, and figured out what silhouettes are... Anyhow now I can see the shadow from any angle(if I modify the GL_DECR with GL_INVERT). The problem here appears as folows:outside the volume shadow everything`s fine but inside everything is upside down, meaning that there`s no shadow and I can see the silhouette poligons, like in a room . The question would be... what Stencil Func shall I use to remove this... artifact ?

Share this post


Link to post
Share on other sites
Advertisement
Read the current article about Cg-Shadow Volumes. In the first few pages the auther gives an explanation on how things work. On page 2 he addresses the problem that occurs when the camera moves inside the volume (that''s what you''re looking for, right?).

Share this post


Link to post
Share on other sites
Well that`s kind of my problem but I didn`t tested it yet.
I made a little more tests because I found out some weird about the front face/back face, and got to the conclusion that the front face/back face is not caomputed based on the surface normal... I enabled backface culing and rendered a terrain with the right normals and there`s culling but when I reversed the normals... it was the same thing only with lower lighting intensity... that`s not what I want... is there a way of setting a poligons front face/back face ? or OpenGl is setting it up ?

Share this post


Link to post
Share on other sites
front/back facing is determined by the winding order of the vertices. glFrontFace will set whether you want clockwise or anti-clockwise to be the front face.

Share this post


Link to post
Share on other sites
Well... I made it work !!!

This is pretty stupid because what I used, woren`t used in any tuts but i tryed it anyhow...
If you wonder amaze yourself og my method

DrawPlane();
DrawTriangle();
glEnable(GL_CULL_FACE);
glColorMask(GL_FALSE,GL_FALSE, GL_FALSE, GL_FALSE);
glEnable(GL_STENCIL_TEST);
glDepthMask(GL_FALSE);
glStencilFunc(GL_ALWAYS,1,0);

glStencilOp(GL_KEEP,GL_INCR,GL_KEEP);
glCullFace(GL_BACK);
DrawTriangleSilhouette();

glStencilOp(GL_KEEP, GL_INVERT,GL_KEEP);
glCullFace(GL_FRONT);
DrawTriangleSilhouette();

glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glCullFace(GL_BACK);
glDepthFunc(GL_LEQUAL);
glStencilOp(GL_KEEP, GL_KEEP,GL_KEEP);
glStencilFunc(GL_EQUAL,1,0);

glDisable(GL_LIGHT0);
glDisable(GL_CULL_FACE);
DrawPlane();

glStencilFunc(GL_EQUAL, 0, 1);
glEnable(GL_LIGHT0);
DrawPlane();
//DrawTriangle();

glDepthFunc(GL_LEQUAL);
glDisable(GL_STENCIL_TEST);
//

glDepthFunc(GL_LEQUAL);

But now I have another bug(much smaller)... Under the DrawPlane() Plane I see both the shadow and the triangle in the color of the shadow... but I may work this out .

Share this post


Link to post
Share on other sites
Well I reenabled Cull_Facing when drawing the actual shadow and it worked although underneath the plane everything`s total white(instead of a grey-ish color)

Share this post


Link to post
Share on other sites
The standard zfail volume shadow algorithm uses:
glStencilOp(GL_KEEP,GL_INCR,GL_KEEP); 

for the back faces and
glStencilOp(GL_KEEP, GL_DECR,GL_KEEP); 

for the front faces.
Using
glStencilOp(GL_KEEP, GL_INVERT,GL_KEEP); 

will only work for simple shadow volumes (no overlapping of shadows).

Also, for self shadowing to work properly you need to set your depth func to GL_LESS when drawing the shadow volumes.

Just to prove that I know what I''m talking about (and because I only finished the program this weekend and want to show it off)


Enigma

Share this post


Link to post
Share on other sites
I posted that code because only that code worked for me !
I reviewed dozens of tutorials on shadows and none worked so I played around those params and that`s the only config that works and I`m really happy about it...

The only bug now is that there are 2 shadows... and one is dependent of the camera and it`s written into the distance but still on the surface... I`ll have to mangle with that 2-pass lit/unlit rendering of the plane...

Share this post


Link to post
Share on other sites
I persume you are using zfail or carmacs reverse.
In that case, Did you cap the shadow volume.
Basicly what you do is that you draw the light facing polygons then the siluette and lastly the same lightfacing polygons but you extrude them the same way you did the siluette and you draw the vertics in the reverse order.

[edited by - lc_overlord on December 1, 2003 4:43:29 PM]

Share this post


Link to post
Share on other sites
After analysing the silhouette some more I changed the face orientation and managed to get all faces pointing outside so now the original algorithm works but there`s that inside bug again... so i`ll try using some PushAttrib() ...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!