Sign in to follow this  

Shadow Mapping Slight Problem

This topic is 3088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using fixed-function pipeline. Regular shadow-mapping as described in every tutorial. Standard stuff. I get this: http://img37.imageshack.us/img37/2102/viperf.png I just to know how to get rid of those ugly streaks all over the car without turning off GL_LINEAR filtering on the shadow-map texture. I tried many blending modes etc. Regards, L. Spiro

Share this post


Link to post
Share on other sites
You should only apply the shadow map on the diffuse and specular components of a fragment not the ambient. In glsl this is quite easy. With fixed function you need to render the scene in two passes (I think, I could be wrong). One pass for the ambient color and another pass for the diffuse and specular color components with the shadow map enabled.

Share this post


Link to post
Share on other sites
I am already making 2 passes (3 if you include the generation of the shadow map).
In the first pass I enable lighting, disable all lights, and set a global ambient term.

Then in second pass I enable the light of interest and render again (but admittedly I do not disable the ambient light).

In the second pass, is it enough to get set the ambient light to 0,0,0,0, disable the ambient on the light I am using to render, and draw? Or must I disable the ambient material for each object?


L. Spiro

Share this post


Link to post
Share on other sites
Your problem may be due to the limited precision of the shadow map. When you compare the distance from the map to the distance to the light source, use a fudge term. Something like if(distance_from_light > distance_in_shadow_map+some_small_constant){Is_in_shadow;}

Share this post


Link to post
Share on other sites
The streaks are caused by double-blending of the shaded ares along shadow borders.

The frame buffer contains the ambient-only pass, with everything as dark as the shadowed regions in the final image.
The borders of shadow regions have alpha values as a result of linear texture filtering, causing the fragment to blend against the already-dark frame buffer.


L. Spiro

Share this post


Link to post
Share on other sites
I think Einar89 is correct, these just look like the usual self shadowing artifacts - unless I'm missing what you're getting at.

Unfortunately, there's no good solution to this. You might be able to get them to an acceptable level by tweaking a depth offset (with glPolygonOffset) or by increasing shadow map resolution.

Some people recommend turning off self shadowing, but you'll want the programmable pipeline for that!

Share this post


Link to post
Share on other sites
That is not the problem I am trying to demonstrate (though turning off self-shadowing would indirectly solve this problem).
I already use glPolygonOffset() to fix the common problem to which you are referring.
Raising the resolution of the shadow-map reduces the visibility of this current problem, but since it is impossible, it is not an option.


The headlight casts a regular shadow down the side of the door.
If you can ignore the blockiness and jagged shadow edges, look at the border of the shadow.
The top part of the door is bright-yellow. Then at the edge of the shadow it is a dark yellow. Then inside the shadow it is a middle yellow. Then dark-yellow back to bright-yellow as you leave the shadow again.

In case the dark-yellow is hard to see at the edge of that shadow (because it is surrounded by bright-yellow), you can also look at the center of the door, where other shadows (coming from objects in the interior of the car) are being cast onto the door, again leaving dark-yellow outlines which appear as ugly dark-yellow streaks.

Except that around the center area of the door they do not appear as shadows because the whole area is middle-yellow. Some parts of the door are middle-yellow because a shadow is cast there, and other parts are middle-yellow because of regular Goraud shading.

But just trust me, there are shadows there, coming from parts inside the car, and they are all leaving ugly dark-yellow borders, which are causing those ugly streaks all over the side of the car.


The shadows have soft borders because of GL_LINEAR shading.
Obviously I want to keep that, since the alternative gives terrible blocky results, since as I said the shadow-map resolution can not get any higher than that.


L. Spiro

Share this post


Link to post
Share on other sites

This topic is 3088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this