shadow2DProj return values

I’m writing a simple application to play with shadow maps in OpenGL, but I’m getting shadows that are much lighter and sharper than I expect (and what I get on another system).

I’ve thrown up a couple of images to show what I’m getting and what I expect, as well as the shader: http://glosx.blogspot.com/

Section 13.2.3 of the orangebook says that I should expect a binary 0 or 1 value back from shadow2DProj, but that’s not what I’m seeing. When I run the same code on another machine, I get exactly what I expect. The other machine has an older GPU, so I could reasonably believe that the sharper edges are the result of the newer machine doing some PCF for me when it samples the shadow map. That doesn’t directly explain why the shadows are so light though. I have considered that perhaps my shadow matrix is incorrect, but shadows are generally where they should be… If anyone has any thoughts as to where I’ve goofed, I’d appreciate it.

Thanks!
Andrew.

You have to enable the compare mode for the texture:

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);

The PFC mode will be activated if the linear magnification filter is enabled.

Hey, thanks :smiley: That worked perfectly. I’m not seeing PCF w/ linear magnification, but things make a lot more sense now.

Andrew.

but with “compare” as above and filtering set to linear shadow2DProj(<sampler2DShadow>, <texcoords>).r - has more values from [0, 1] range - so you should see the difference :wink:

MichalST.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.