Shadow map question

Description:
I am using GL_ARB_shadow to compare a texture R coordinate to a depth texture’s value to determine shadowed/unshadowed fragments in hardware.

I’m doing this to cast shadows on arbitrary textured objects.

I am using GL_ARB_multitexture to apply the primary texture to the object’s polygons while comparing the R for the depth texture bound to the secondary texture unit, to produce a luminance or alpha result for the second texture unit.

Question(s):
Is there a way to control the luminance/darkness of the shadow? For example, I don’t want the shadows to appear completely black. Specifically if the compare results in a luminance value, is there any way to force the alpha value of 0.4 to go with all the generated luminance values?

What is the best way to control the darkness of the shadow when employing a multitexture render and shadow compare?

(I’ll add one more caveat: I’m looking for a technique that works on semi-recent NVIDIA hardware)

Thank you!

Well, since a shadow is the lack of light from a specific lightsource it should be black if you only have one direct light.

But opengl has the nice thing called ‘ambient light’ to simulate the light that been reflected around so much that you dont know where its origin is.

I know that there exist some extension handeling the shadowpart, but its just as easy to draw the whole scene with only ambient first, then draw it again with the rest of the light and shadows.

Does anyone have a suggestion that is not multi-pass?

Thank you.

Thanks Mazy for your response. I coded it and the multi-pass approach works great. Very subtle shadows.

It looks good so I’ll just live with the extra pass for now.

Thanks again.

[This message has been edited by robosport (edited 03-19-2004).]

Does anyone have a suggestion that is not multi-pass?

Rather than using ARB_shadow, do the comparison in a shader. There, you’re not culling the fragment; you’re just getting a 0 or 1 value telling you if you’re in shadow or not. You can build the lighting equation based on this. For example, you can say: ambient + shadowValue * lightResult. All in one pass.

That sounds cool! Much more flexible. I wrote shaders for RenderMan about 12 years ago. I guess its time to learn about shader programming with OpenGL.

Can anyone suggest a good starting place for diving into the topic of using shaders with OpenGL?

Thank you.

Now that all the OpenGL Dev forums seem to be back up and running (and nicely upgraded it seems), I found a helpful collection of “getting started with GLSL” links in this thread from one of the other forums:
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_t opic;f=11;t=000119

Thanks again.

Sorry to revive such an old topic, but I found this while I was searching for a solution to my problem. Basically, it’s the exact same thing as he explained in the very first post. The only difference is that I’m rendering multi-textured objects and applying the shadow map on the 4th texture unit, Gl_Texture3, using display lists.

Basically, I’m just wondering if there is any way to apply a lower alpha value to the depth texture. I realize that you can’t actually poke an alpha value into the depth texture itself, but I can’t seem to grasp how to blend it with the output from the previous texture unit, without appearing totally black.

Thanks for any help. :slight_smile:

Edit:
Here’s a picture showing the behavior.

Is anyone able to help me with this, or at least point me to a tutorial on glsl for ULTRA beginners? The link up there is broken or outdated. Thanks. :wink:

try this to get a different alpha…

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.4f);

I didnt try it my self but maybe it works :slight_smile: