PDA

View Full Version : Shadow Mapping Ambient



azcoder
05-16-2004, 09:58 AM
Thanks in advance for any help....

I don't want my shadows to be pitch black. It looks like ARB_shadow_ambient or GL_SGIX_shadow_ambient both address this, but I can't seem to get them to work.

Here is a small bit of code:

//Init Depth Map Texture
glGenTextures(1,&m_depth_map);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,m_depth_map);
glTexImage2D(GL_TEXTURE_2D,0,m_depth_format,TEX_SI ZE,TEX_SIZE,0,GL_DEPTH_COMPONENT,GL_UNSIGNED_INT,0 );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _CLAMP_TO_BORDER_ARB);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _CLAMP_TO_BORDER_ARB);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_M ODE_ARB,GL_COMPARE_R_TO_TEXTURE_ARB);
glTexParameterf(GL_TEXTURE_2D,GL_SHADOW_AMBIENT_SG IX,0.5f);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_F UNC_ARB,GL_LEQUAL);

But the shadows are still solid black. Everything still shadows correctly, and my understanding is that the only thing I need to get non-black shadows is the call to:
glTexParameterf(GL_TEXTURE_2D,GL_SHADOW_AMBIENT_SG IX,0.5f);

Should'nt this change the luminance of the affected fragments from 0.0 to something else?

Any help is greatly appreciated...this is driving me nuts....

Even better, any other technique to get non-black shadows is welcome - must work on GeForce 4 and above...

rgpc
05-16-2004, 04:34 PM
I would guess that it's not working because the extension is not available on geforce cards (at least up to v56.56 drivers and fx 5900's - ie. my configuration). Might be different for later drivers (I have doubts) or cards...

I am not aware of any other techniques that can be used to get the desired effect with shadow buffers.

azcoder
05-16-2004, 08:32 PM
Thanks rgpc - That does definitely explain why it isn't working....

Is there anyway to accomplish this in geforce 3+ hardware using register combiners or something?

Thanks again...

PT
05-17-2004, 02:04 PM
Yep. ARB_shadow_ambient has very light support. I used register combiners to achieve transparent shadows.

azcoder
05-17-2004, 09:20 PM
PT - Can you elaborate on how you used register combiners?

Thanks!!

PT
05-17-2004, 10:53 PM
Sorry I can't supply a code sample right now. But the approach I took isn't very sophisticated. Here's the gist of it:

shadow_color * (1 - shadow_texture) + fragment_color * shadow_texture

. set a constant color to be grey
. for the shadow color, blend the constant color with the incoming fragment color to darken it
. use your shadow map texture result (which is 0 or 1) to modulate between the shadow color and the fragment color

BTW: Having set up register combiners has made me *really* appreciate high level shading languages.

Good luck!

Ozzy
06-24-2004, 10:48 PM
could you supply code? ^^