Skip to main content
GameDev.net gamedev.net
🔒 Locked

Stencil Buffer Wrong side Reflection

Started by Ti47 Apr 6, 2006 at 7:21 PM 1 replies 400+ views
Original Post
Ti47
Ti47
Hey guys, I am doing programming from the book Introduction to DirectX9 Programming by Frank Luna and I am up to chapter about stencil buffering http://ti-x.net/images/stencilMirror.jpg if you look at that screenshot you will see that its not exactly drawing correctly its drawing the exact same thing on the oterside eventhough it should be drawing the "dark side" of the teapot. how can I remedy this, now I know i gotta do something to the light direction's matrix but the light isn't a global light its used in a local function.
sirob
sirob
When drawing the reflected object, you'll need to reflect the light direction by the same reflection matrix you use for the object.

Hope this helps :).
Sirob Yes.» - status: Work-O-Rama.
Demus79
Demus79

To make planar reflections easier, why no render the scene from the reflected point of view, instead of reflecting the whole scene + everything else ?

So, reflect your camera position + camera direction vectors by the mirroring plane and render your scene from this mirrored camera. No need to worry about lighting or triangle culling order. Only thing is that the final image will be horizontally flipped. If you are using a texture projection, the fixup is rather obvious.

Cheers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.