Camera inside shadow volume

I can only get shadow volumes to work like this. When the camera goes inside the volume, the shadow disappears. I have read several papers on “Carmack’s Reverse” but it results in no shadows when I use all the settings other people suggest. Please show me what to replace in this code to make it work right.

The object brush I draw at the end is an extruded shape that contains the entire shadow volume mesh. This will cover the entire area of the shadow on screen, so I use it instead of covering the whole screen with a quad.

								'Draw shadows
								glclear GL_STENCIL_BUFFER_BIT
								glDisable GL_LIGHTING
								glDepthMask GL_FALSE
								glEnable GL_STENCIL_TEST
								glStencilFunc GL_ALWAYS,1,255
								'First Pass. Increase Stencil Value In The Shadow
								glFrontFace GL_CCW
								glStencilOp GL_KEEP,GL_KEEP,GL_INCR
								'Second Pass. Decrease Stencil Value In The Shadow
								glFrontFace GL_CW
								glStencilOp GL_KEEP,GL_KEEP,GL_DECR
								'Final pass
								glFrontFace GL_CCW
								glColor4f 0.0,0.0,0.0,a
								glStencilFunc GL_NOTEQUAL,0,255
								glStencilOp GL_KEEP,GL_KEEP,GL_KEEP
								gldisable GL_DEPTH_TEST
								'Draw object brush
								glmatrixmode GL_MODELVIEW
								glRotatef camera.roll,0,0,1
								glRotatef camera.pitch,1,0,0
								glRotatef -camera.yaw,0,1,0
								glTranslatef -camera.x,-camera.y,camera.z
								glScalef 1,1,-1
								For face:tface=EachIn lightlink.brushvolume.faces
									If pointplanedistance(camera.x,camera.y,camera.z,face.nx,face.ny,,face.d)<0.0
										glenableclientstate GL_VERTEX_ARRAY
										glVertexPointer 3,GL_FLOAT,0,BankBuf(face.rendersurface.vertexarray)
										glDrawElements GL_POLYGON,face.rendersurface.indicearray.size()/2,GL_UNSIGNED_SHORT,BankBuf(face.rendersurface.indicearray)
								glmatrixmode GL_MODELVIEW
								'Restore Settings
								glenable GL_DEPTH_TEST
								gldisable GL_STENCIL_TEST
								gldepthmask GL_TRUE
								glcolor4f 1,1,1,1

for z-fail (or carmacs reverse) it’s glStencilOp GL_KEEP GL_INCR GL_KEEP

and glStencilOp GL_KEEP,GL_DECR,GL_KEEP instead of glStencilOp GL_KEEP,GL_KEEP,GL_DECR

And don’t forget to cap of the shadow volumes

Well, I tried those two changes, but no shadows appear with the code I have above. What other changes are needed?

Anyone? If I use my original code, shadows appear, but disappear when I enter the volume. If I make the suggested changes, no shadows appear at all.

I would suggest starting with some working example code. It can be tricky to debug problems with SSV rendering.

I’m afraid that’s impossible, without posting my entire engine source.

I thought your code didn’t work.