light state - is it object or eye space

Well that bad thing is no that didnt change a thing. So this is what I have now. I set LEQUAL then do the zfill. Set LESS then do the two stencil shadow volume passes. Then use EQUAL before I draw the scene again with the light enabled, only putting light where the stencil is 0.

This is very odd.

-SirKnight

What does the output look like ? Did you remember to request 8-bits of stencil ? Stencil buffer cleared to 0 before rendering the shadows ?

Well actually it looks just like a lit up room with no shadow! I did request 8 bits of stencil. BTW, my format I request in the PFD is 32bpp, 24depth, 8 alpha and 8 stencil. That should be fine. Later ill make sure that my opengl app class is passing this request into the pixelformatdesc structure just to make sure. Im pretty sure it is though. Um, before every frame I call glClear which contains GL_STENCIL_BUFFER_BIT as one of the flags. After I call StencilFunc before the first shadow pass I call StencilMask with ~0 passed.

I noticed also that if I call Rotatef before I call DrawRoom and DrawCube that most of the screen is black with a little bit of light on the ceiling and floor. I can’t really describe this, maybe ill show a pic. But in my Draw funcs I push the MV on the stack, draw the geo then pop it off. I noticed that if I want the room and cube rotated it works better if I call rotate inside my Draw funcs after I push the MV on the stack. Some how calling Rotatef before the push causes that wierd display.

This is so wierd b/c my volume creating code and rendering code is right, the stencil funcs, ops, etc are ok. It has to be some small wierd thing that is being over looked I guess.

-SirKnight

Have you tweaked up your projection matrix to set the far plane at infinity ? I met problems like yours when the shadow volume intersected the far plane. Something else that comes to my mind is the culling of the near / far caps, have you tried to revert the vertex order to see what happens ?

Y.

Have you tweaked up your projection matrix to set the far plane at infinity ?

Yep.

have you tried to revert the vertex order to see what happens ?

Yep again, still nothing.

I don’t know why this thing is being such a pain in the arse. Im sitting here looking at the whole render function and i’m saying to myself, wth, this is correct yet it goesnt give me a shadow. I have it setup so if I set SHOW_VOLUME to 1 it renders the volume as a regular piece of geometry (and skips the stencil funcs) and it’s just how it should be.

-SirKnight

Alright, I have uploaded a zip file that contains my latest source in case someone wants to give it a quick once over and two exe files. (BTW, my rendering stuff is in OpenGL Application.cpp) Ok the exe ShadowVolumes.exe has the SHOW_VOLUME switch set to 1 so when you run this exe, you will see the volume rendered like a normal piece of geometry, like if it were a model. ShadowVolumes_stencil.exe has all the stencil stuff enabled (SHOW_VOLUMES set to 0). This exe is not very impressive.

Ok the link is:
http://sirknighttg.tripod.com/shadows2.zip

-SirKnight

Well as Gomer Pyle would say “SUPRISE SUPRISE SUPRISE!!” Welp I actually got it working perfectly! I kinda feel like a 'tard but you see, the problem was with the request of the 8 stencil bits. (I knew it was something small that was being overlooked, cuz every major part was correct). Ok well in my OpenGL class I have a structure that I fill in to request diff things like bpp, stencil, depth bits, etc. Well in my CreateOpenGLApp function I take this structure and copy its contents to the member variable of the class which is of this same structure type. Then when I request a pixelformat I do something like this:

m_pfdPixelFormat.cStencilBits = m_oglSettings.stencilbuffer;

Ok well earlier when I looked at this code I saw this line and went, ok that is passing the bit depth into there ok. But I did not realize that my opengl application class was a little broken. I was NOT copying anything into ‘m_oglSettings.stencilbuffer’ like I was supposed to in my CreateOGLApp function. So it was always set to 0. So I had 0 stencil bits, that’s why my stencil funcs never worked no matter how I used them.

Gosh, I just assumed that part of my opengl app class was fine, I didnt know I forgot to say this: ‘m_oglSettings.stencilbuffer = settings.stencilbuffer;’ in the setup. :-/

After hours of brain bashing my problem turned out to be a broken opengl app class. Just a simple problem at that. O well, I guess we all have done stupid things like this before. At least I know I learned a lot from this…experience.

So anyway, thanks everyone for your help. I appreciate it a lot.

-SirKnight

…After hours of brain bashing…

Anyone here happen to be an icebox salesman/saleswoman

Nice to hear it works, how about pics or exe of your new creation?!

Dan

Anyone here happen to be an icebox salesman/saleswoman

LOL!

When I get home later i’ll zip all the working code up and put the exe in there and post it on my site. The geometry is not very impressive at all but its simple which is good.

-SirKnight

Ok as I promised here is the exe and code to my working infinite stencil shadow volume demo. Hopefully someone can learn something from it and find it usefull in some way or another.

URL: http://sirknighttg.tripod.com/projects/shadow.zip

-SirKnight