#146721 - Noda - Sat Dec 08, 2007 1:05 am
Hello!
I've been bothering the last days to make working my projected & cutted shadows, and it almost works, except that I'm experiencing something very weird with the stencil buffer...
Here is what I want to do:
- draw the shadows of the object on a board, which reprensent the floor (but the board is only a part of the screen, it's not infinite)
Here's what I currently do:
- draw my scene
- draw the board into the stencil buffer
- apply a matrix to draw projected shadows
- draw transparent shadow using the stencil buffer, so the shadow is cut to the board
Here's what it does:
- seems to work fine, but when the view change a little bit, some parts of the shadows masked using the stencil buffer appears (on Ideas, it works fine, as expected, without this problem).
I don't really get how the stencil buffer work here, as it seems to be influenced by the depth buffer values: if I don't draw the board in the normal scene (to see only the shadows on my skybox background), the shadows are not displayed at all...
I tried to use W/Z buffers when flushing, with auto sort & manual transparent polygon sorting, and no luck, here's the results:
- z buffer used, transparent auto sorting: the config I use currently, show some z-fighting issues on my scene and the problem with the stencil shadows described up there.
- z buffer used, transparent manual sorting: same as previous result
- w buffer, transparent auto sorting: the z-fighting issues with the scene are still here, but my transparent shadows are not displayed
- w buffer used, transparent manual sorting: same as previous result
So here are my questions:
- what is the purpose of the transparent polyg manual sorting mode? auto sort is based on poly id, and manual sort is based on drawing order, am I right?
- how the stencil buffer actually works? as it seems also there's a mistake in gbatek doc here as the stencil is not cleared after being checked (and I use it that way, and it *almost* works). The stencil seems to be linked with the depth buffer, which is something I don't understand...
For me, the stencil buffer here works just like a mask, we draw into to put the bit at 1, then everything drawn after with stencil check applied is just bitwise &-ed with it before being displayed? is this correct?
here is a link if you want to try it on hardware to see what exactly the problem is:
http://noda.free.fr/nds/marble_proto.rar
Thanks a lot for any information.
I've been bothering the last days to make working my projected & cutted shadows, and it almost works, except that I'm experiencing something very weird with the stencil buffer...
Here is what I want to do:
- draw the shadows of the object on a board, which reprensent the floor (but the board is only a part of the screen, it's not infinite)
Here's what I currently do:
- draw my scene
- draw the board into the stencil buffer
- apply a matrix to draw projected shadows
- draw transparent shadow using the stencil buffer, so the shadow is cut to the board
Here's what it does:
- seems to work fine, but when the view change a little bit, some parts of the shadows masked using the stencil buffer appears (on Ideas, it works fine, as expected, without this problem).
I don't really get how the stencil buffer work here, as it seems to be influenced by the depth buffer values: if I don't draw the board in the normal scene (to see only the shadows on my skybox background), the shadows are not displayed at all...
I tried to use W/Z buffers when flushing, with auto sort & manual transparent polygon sorting, and no luck, here's the results:
- z buffer used, transparent auto sorting: the config I use currently, show some z-fighting issues on my scene and the problem with the stencil shadows described up there.
- z buffer used, transparent manual sorting: same as previous result
- w buffer, transparent auto sorting: the z-fighting issues with the scene are still here, but my transparent shadows are not displayed
- w buffer used, transparent manual sorting: same as previous result
So here are my questions:
- what is the purpose of the transparent polyg manual sorting mode? auto sort is based on poly id, and manual sort is based on drawing order, am I right?
- how the stencil buffer actually works? as it seems also there's a mistake in gbatek doc here as the stencil is not cleared after being checked (and I use it that way, and it *almost* works). The stencil seems to be linked with the depth buffer, which is something I don't understand...
For me, the stencil buffer here works just like a mask, we draw into to put the bit at 1, then everything drawn after with stencil check applied is just bitwise &-ed with it before being displayed? is this correct?
here is a link if you want to try it on hardware to see what exactly the problem is:
http://noda.free.fr/nds/marble_proto.rar
Thanks a lot for any information.