Jump to content
  • Advertisement
Sign in to follow this  
Marty666

Stencil shadows self shadowing problem

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

Hi all! It's been a while, but since i have vacation now i decided to go on with my project. When I stopped i got the stencil shadows working. It just doesn't look right. This is the problem:

* = vertex
_ / | \ = face
                      ___
                     *   \___
lightsource >        |       *
                     |       |
                     *_______*
I have 4 verts and four faces in this 2D example... Normally opengl lights the vertexes acording to their normals. So the top and bottom face would be lit at the left vertexes and change to dark at the right ones. All exept the left face are in the shadow volume, so are rendered with only ambient light. So there is a sudden drop in light from the front face to the top and bottom faces which would normally be a gradient from the topleft (lit) vertex to the top right (unlit) vertex. Is there a way to solve this? I should change the normals in some way, but I don't want flat shading. Thanx, Marty

Share this post


Link to post
Share on other sites
Advertisement
It sounds perfectly normal for shadow volumes, shadow volumes are pretty solid if you do them right, but this is not your problem.
Now if the light behaves strangely it is because it is not lit correctly or that your models are not built for stencil lighting, in your case it's because the normals are "wonky", specificly because none of the normals in the polygons points in the actual normal of the plane, try beveling the edges a little, or subdividing your faces.

Share this post


Link to post
Share on other sites
Hi,

Beveling the edges sounds like a great idear... My models should look like they have smooth surfaces, so i'll need the normals this way. I guess the only solution is to use more faces on big surfaces and near sharp corners.

Thanks,
Marty

Share this post


Link to post
Share on other sites
Yes, or you could do what i do.
I have a algorithm that decides if the edge/corner should be sharp or not and then assigns a separate normal to each vertic of each polygon rendered.

IT behaves ok, but it is not perfect.

the best solution is to use normal maps, but that is pretty advanced.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!