Quick Shadow question

Started by
12 comments, last by cippyboy 20 years, 4 months ago
I looked again(now with the faces going pointing the right direction) at that ''Carmack Reverse'' and... I might say it`s not perfect... I can see the shadow when I have the light from top to bottom, and there`s no inside error .
But when I go underneath the plane, I see the shadow and that second triangle that`s almost moving with the camera...
Also when I put it in a box, the shadows only exist when the light comes from top to bottom, even if there are polys up... which is not that practical... I`m gonna try the NeHe demo next(for the third/forth time)

Relative Games - My apps

Advertisement
the plane must cast a shadow volume to.
I used the NeHe shadow code from the tutorial and... modifyed it to work... relatively normal like this ->
DrawPlane();	DrawTriangle();	glEnable(GL_CULL_FACE);	glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );		glDepthMask( GL_FALSE );					// Turn Off Writing To The Depth-Buffer	glDepthFunc( GL_LESS );	glEnable( GL_STENCIL_TEST );					// Turn On Stencil Buffer Testing	glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );		// Don''t Draw Into The Colour Buffer	glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFFL );	glCullFace(GL_FRONT);	glStencilOp( GL_KEEP, GL_INCR,GL_KEEP);	DrawTriangleSilhouette();	// Second Pass. Decrease Stencil Value In The Shadow	glCullFace(GL_BACK);	glStencilOp( GL_KEEP, GL_DECR,GL_KEEP);	DrawTriangleSilhouette();		glDepthFunc(GL_LEQUAL);	glDisable(GL_CULL_FACE);	glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );				glStencilFunc(GL_EQUAL,1,1);	glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );	glEnable(GL_BLEND);	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);	glColor4f(0,0,0,0.4f);		DrawPlane();        glDisable(GL_BLEND);		glPopAttrib();


And offcourse it had that, ''under the silhouette shit happens'' and I modifyed it some more as [Enigma] instructed and... this is what exactly happens->
http://www.geocities.com/cippyboy_7/shadowbug.jpg
as I`ve seen there`s another another triangles that`s inverting it`s color...
If I`m wrong in some part of the code please correct me !

Relative Games - My apps

It looks like a uncapped shadow volume to me.
Theory of stencil shadow volumes

This topic is closed to new replies.

Advertisement