Shadow Mapping Slight Problem

Started by
7 comments, last by L. Spiro 14 years, 9 months ago
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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement
For the shadow map, using GL_LINEAR is not going to improve the rendering quality.

Why you want to use GL_LINEAR instead of GL_NEAREST for the shadow map texture?
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.
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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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;}
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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

So any clue how to get rid of them? Perhaps it is not clear from the picture what I mean.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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!
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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement