Sign in to follow this  
Davidtse

Self shadowing polygon seems

Recommended Posts

Hello everyone, I recently implemented shadow mapping in my engine and im trying to get it too look just right. When I added a sphere to the scene I noticed there where seams in the self shadowing along the polygons of the underlying mesh and it was not the smooth self shadowing I was expecting for a sphere. I didn’t really notice this before because I was using more complex models with more dense geometry. here is a picture of what i'm talking about


[img]http://farm9.staticflickr.com/8148/7465187798_9ed0658903_c.jpg[/img]
[img]http://farm8.staticflickr.com/7128/7465187610_eb6cce2913_z.jpg[/img]

Im not sure why this would be the case I would think there should be a nice smooth line on the part of the sphere that is in shadow. it must be a problem with something in my shaders here is how I do the shadowing.

(glsl)
Vert Shader:

ProjShadow = TextureMatrix * WorldMatrix * in_Position;

Frag Shader:

float depth = textureProj(ShadowMap, ProjShadow).x;
float R = ProjShadow.p / ProjShadow.q;
R += 0.0005;
float shadowValue = (R <= depth) ? 1.0 : 0.0;

If anyone knows what I am doing wrong and could help me out I would really appreciate it.

Thanks, David Edited by Davidtse

Share this post


Link to post
Share on other sites
This kind of self shadowing (when the polygons are backfacing relatively to the light) shouldn't be handled with shadow mapping. This should be handled by the standard lighting, which you doesn't seem to have yet.

Simply put: even if there is no shadowing at all, this kind of self shadowing is handled by the simplest lighting models "by default".

Nevertheless, there will be this self shadowing artefact accidentally with shadow mapping. This can be handled usually in two ways: if your meshes are closed, then simply don't render backfacing triangles to the shadow map.
and/or
Adding a shadow bias value. Which you seem to do (R += 0.0005), maybe it's just not a good value. Maybe you need a negative value.
If you add this bias, you won't see the self shadowing. Because as I said earlier, you need to handle that with your lighting model.

EDIT: I say "you shouldn't" because you won't be able to solve this kind of self shadowing with shadow mapping (you'll always have this non smooth pattern) and you have to use lighting anyway. Edited by szecs

Share this post


Link to post
Share on other sites
Hi

How do you create the shadow map?

EDIT:
And well... you should use a "normal" shading, like phong shading, which will be smooth. Edited by csisy

Share this post


Link to post
Share on other sites
A note to my previous post:
There was a bit misleading info, it was long ago when I did shadow mapping.
This part:
[quote]if your meshes are closed, then simply don't render backfacing triangles to the shadow map.[/quote]
can be true, but it's usually done the other way around: only backfacing triangles are rendered to the shadow map, so that there won't be artefacts on the light-facing triangles (where sometimes it's rendered shadowed, sometimes not shadowed, usually producing a striped pattern).

And another sidenote: shadows are usually "ambient shadows". Meaning the shadows are rendered (I'm not talking about the shadow map generation) with the ambient lighting component applied only to the scene. This is more realistic than adding a black, or faint black shadow overlay.

This also means that the light-backfacing self-shadowing artefacts may not be visible at all, because the shadowed and non-shadowed surfaces look the same (you won't see the striped pattern).

BUT: artefacts will be present on smooth surfaces on the border of light and shadow, so you always have to apply bias with shadow mapping.


So to sum it up: apply an appropriate bias value.

I hope that my post makes sense....

Share this post


Link to post
Share on other sites
OK I thought that this may just be a problem with shadow maps. I just thought when things are rendered to the shadow map the geometry would not effect the shadows. So bassicly you are saying that the self shadowing of the sphere is dependent on how dense the mesh is? I have the bias set to fix alot of the acne on the shadows already and already backface cull when rendering to the shadow map. I do have blinn-phong lighting implemented(not enabled in the screenshot), I was just wondering why the self shadowing was based on the polygons of the mesh. The regular Lighting does cover up and fix most of the self shadowing on the sphere but I can still see some of the sharp self shadowing from the shadow maps under the lighting. I dont think the problem is the bias because the line is the along the polygon edges and any bias value I put only effects the line but its always long the lines of the polygons of the mesh.

Share this post


Link to post
Share on other sites

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