Home
Products
Community
Manuals
Contact
Login or Signup

Shadow maps - trouble with GL_COMPARE_R_TO_TEXTURE

BlitzMax Forums/BlitzMax OpenGL Programming/Shadow maps - trouble with GL_COMPARE_R_TO_TEXTURE

Warner(Posted 1+ years ago) #1
I'm trying to convert one of the sgi examples on shadow maps to BlitzMax, but I have trouble getting GL_COMPARE_R_TO_TEXTURE to work.
When I leave the R row of the texture matrix empty, it draws the entire shadow map, without filtering it.

It could be just my card, though, all other shadow map samples showed a black screen.

Hopefully there is someone who wants to have a look at it? Code should run without any external mods.
I indicated the line with "-HERE". (all caps)
Without that line, I see a (blockish, but clear) gray shadow on the white ground. With that line added, there is no shadow visible.


Last edited 1+ years ago


jkrankie(Posted 1+ years ago) #2
Hi,

I'm seeing this on my mac with the line commented out:


and this with it uncommented:


This is on my Mac Mini, which has an Nvidia Gforce 9800 card.

Cheers
Charlie


Warner(Posted 1+ years ago) #3
That's just weird. Without the line, I get this:

And with that line, I see this:

I find it troubling that the same code renders something else on two different cards, however, it is reassuring that both not render what it is supposed to render.
I'll start the translation again from scratch. Maybe there is something I am overlooking:



jkrankie(Posted 1+ years ago) #4
Output is identical on Windows XP with an Nvidia 6800 GT.

The shadow projected from both the box and the torus onto the ground plane looks right, although it's very blocky. Those projected onto the cube and the torus look wrong though, almost as if you've got the texcoords wrong.

Can't think why the shadow texture is inverted on the plane.

Cheers
Charlie


Warner(Posted 1+ years ago) #5
I now tried running the C code in DevC++. That seems to work exactly as the BlitzMax version. So, I'm thinking the problem could be in the original sample. That would be weird, since it is a sgi example.
I have trouble understanding the technique, but as I understood, the technique should work as follows:
1. render the scene from the light view
2. store z-buffer in texture
3. adjust texture matrix to match camera view
4. apply texture
5. set 'compare' mode on for z-buffer (compares texture z-buffer and screen z-buffer)
6. render scene again
I may be missing some key steps in this process, though.
In this case, the z-comparisation seems to malfunction in the above program.
But when you disable this, it does show the texture rendered in step 1-4.


Warner(Posted 1+ years ago) #6
I just can't get it to work properly. Is there anyone with shadow mapping experience that could give some pointers or possibly an example?


col(Posted 1+ years ago) #7
double post. lol

Last edited 1+ years ago


col(Posted 1+ years ago) #8
Hi Warner.

I get the same result as in Post#2 by jkrankie. I'm more of a DirectX guy but I'll take a look through your code now, no promises though...

Maybe JoshK would be a better person to help you on this? He's well into OpenGL.

Have you checked this tutorial http://www.paulsprojects.net/tutorials/smt/smt.html?? The only reason I suggest this link is he seems to set up the matrices similar to how I did the shadow mapping in the graphics showcase forum.

Sony Vaio VGN-FW31M

Last edited 1+ years ago