Sign in to follow this  
Vexator

little stencil shadows bug (pic incl.)

Recommended Posts

hey! i built nehe's and brett's code for stencil shadows into my project and advanced it a bit.. it actually works fine. but if i have multiple objects casting shadows or just two lights with shadow-casting enabled, the cast shadows are drawn with different transparecies althoug i always call the same funtion with the same parameters to draw the shadows: screenshot (the white dots are the light sources): http://www.vexator.net/neu-1.jpg any idea why this happens? thx :)

Share this post


Link to post
Share on other sites
The only way i can think of is that you
draw your shadow in mulitple passes!
What you should do, is to setup your shadow stencil, and then draw
ONE quad over the whole screen (using the shadow).
Since the stencil buffer only can have pixels as true or false,
this guaranties all shadows to look the same.

anders

Share this post


Link to post
Share on other sites
yeah i'm doing it with multiple passes.. it's the only way i could figure out with which i can exclude triangles from being covered by shadows :/

Share this post


Link to post
Share on other sites
Quote:
Original post by uncutno
The only way i can think of is that you
draw your shadow in mulitple passes!
What you should do, is to setup your shadow stencil, and then draw
ONE quad over the whole screen (using the shadow).
Since the stencil buffer only can have pixels as true or false,
this guaranties all shadows to look the same.

anders


That is not true, the stencil buffer can have up to 256 values(0-255), it is only when testing against the stencil buffer you get a true or false response.
Because of this you can and should render all shadow volumes in one pass.

Share this post


Link to post
Share on other sites
Did I understand you picture wrong or is there also an error in the orientation the shadow of the cross has? if the light source is directly above it it should cast a shadow with the shape of a quad.

Share this post


Link to post
Share on other sites
not if it's a 3D cross with one more axis than other non 3d ones have.
it would have made mutch more sence if the shading wasn't so odd.

Share this post


Link to post
Share on other sites
I only see two axes on the cross. But, it might be the shading...

edit: I looked at it again and it seems to have three axes indeed.

Share this post


Link to post
Share on other sites
That lesson doesnt do the shading correct 100%.

What you want to do is.
Draw Scene Normaly with Lighting enabled
Draw the Volume shadow to the stencil buffer
Draw The Scene only in the Shadow Stencil with lights disabled.

There is no transparency thingy needed. And this effect is better since if it is a red light then making it darker isnt correct.

Although that effect allows you to make shadows other colours for example instead of darkening the shadow fragments you can lighten it creating a alien type of view.

Quote:
Original post by uncutno
The only way i can think of is that you
draw your shadow in mulitple passes!
What you should do, is to setup your shadow stencil, and then draw
ONE quad over the whole screen (using the shadow).
Since the stencil buffer only can have pixels as true or false,
this guaranties all shadows to look the same.

Yes when you setup your pixelformat you chose a stencil buffer size.

1,4,8 are accepted by most hardware.
If you are using a 1bit then true it can only hold true/false(0,1) but if its 8 bits thats not true.

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