• Advertisement
Sign in to follow this  

Eliminating self-shadowing for shadow volumes

This topic is 3282 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

On a low tesselated mesh this artifact can strongly be seen. For example there is no self-shadowing for characters in Doom 3. The solution for this would be, for example, to make envieronment receive shadows from characters. Characters can't cast shadow on each other. So the question is: how to achieve the latter? I have a set of characters and environement. I want the environment to receive shadows from characters and want the characters to receive shadows from each other, but the character that casts shadow cannot cast it on itself. So far I figured out something like this:
compute standard shadow regions in stencil buffer with self-shadwoing

// eliminating self-shadowing
for each rendered character
    use it's shadow volume and "subtract" it from the original region
    use that region to make shadow on the character (rendering of character)
    use character's shadow volume and "add" it to the original region
Is this algorithm correct? If so, it will make us to draw character's shadow volume three times (instead of only one with standard shadowing). But I suppose that while "subtracting" and "adding" scissor testing could be set on to make filling the stencil buffer only in character's bounding box?

Share this post


Link to post
Share on other sites
Advertisement
I have implemented my idea and it seems to work. For a not complicated geometry (5 boxes, 2 cylinders, 1 torus) FPS drops from 19-20 to about 17. Note that I don't use scissor test (which would definitely help here). Besides such a "trick" should be used only for nearby, lat's say, enemys. The further ones could only receive environement shadows or even have self-shadowing.

But maybe some of you know some trickier solution for this problem?

Share this post


Link to post
Share on other sites
If you specifically don't want self-shadowing, why don't you just draw the non-self-shadowing stuff on top of the shadow? This only requires that the z-buffer contains sensible depth values from the rest of the scene (which is usually the case in ordinary rendering). You will lose early z culling optimizations on the objects you draw this way, though.

That said, usually excessive self-shadowing can be prevented by using a bias value; that is, moving the vertices of the shadow volume by a certain short distance along their negative normal, so as to make the volume go slightly "inside" the caster. The amount of bias needed depends on the local granularity of the depth values so it is not a constant in every case.

Share this post


Link to post
Share on other sites
Quote:


That said, usually excessive self-shadowing can be prevented by using a bias value; that is, moving the vertices of the shadow volume by a certain short distance along their negative normal, so as to make the volume go slightly "inside" the caster. The amount of bias needed depends on the local granularity of the depth values so it is not a constant in every case.

Maybe I did something wrong but with small and larger bias values there were horrible artifacts.

However, I think I found the solution to my problem. Earlier, I was rendering the shadow volumes with LESS depth testing function. Changing it to LESS_EQUAL worked as I wanted. However I'm not actually sure why it works. Why with LESS_EQUAL state triangle that is faced back to the light source do not cast shadow on itself? Yet it cast shadows on the other triangles.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement