Archived

This topic is now archived and is closed to further replies.

Mirror image....

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

Hello, I have mirred a image on a surrface which works fine except when I view the surface from below the mirroed image is there, like its real. It shouldn''t be below the surface, and I was wonder how to fix this... Thanks Frag

Share this post


Link to post
Share on other sites
quote:
Original post by Frag
Hello, I have mirred a image on a surrface which works fine except when I view the surface from below the mirroed image is there, like its real. It shouldn''t be below the surface, and I was wonder how to fix this...

Thanks Frag


i''m guessing you are using stencil reflections that''s why you are getting this effect.

just do a test to determine if you are on the same side of the plane as the relfected object and dont draw it if you''re on the other side. In this case you could blend the surface onto the object (if it''s a transparent window or a water surface)

to do this test do:

CVector3 vNormal = Cross((vSurfacePoint1 - vSurfacePoint2), (vSurfacePoint1 - vSurfacePoint3));

float dot1 = Dot((vObject - vSurfacePoint1), vNormal);
float dot2 = Dot((vCamera - vSurfacePoint1), vNormal);

if (dot1 * dot2 > 0) renderobject();

Share this post


Link to post
Share on other sites

This picture shows the mirrored brick cubes that should not be displayed.



This picture shows the bottom of the floor, as you can see everything is mirrored exactly.

[edited by - Frag on November 9, 2003 1:31:47 PM]

Share this post


Link to post
Share on other sites
render a quad on the reflection plane which you blend over the reflected image.

EDIT: i see what you mean now: render only the reflective parts in the stencil buffer! then render the mirrored image with stencil test, then render the reflective plane again, then the normal image!

[edited by - Ilici on November 9, 2003 1:41:24 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Ilici
render a quad on the reflection plane which you blend over the reflected image.


There is no problem with the reflections them selves, just the other side of the surface.

For example, I have it set up to properly i give the effect if your looking at the mirror, but when you move to the other side of the mirror you see where the reflections would be.

Share this post


Link to post
Share on other sites
quote:
Original post by Lunatic Raven
quote:
Original post by Frag
Yes i know nehe has a tutorial on mirror images, but it didn''t seem to address or solve my problem.


If you read the tutorial, it WOULD have solved your problem.


The only difference that i see between my rendering code any NEHE''s 26th tutorial is that my floor is rendering in small blocks. would this make a difference?

Share this post


Link to post
Share on other sites
quote:
Original post by Lunatic Raven
Then you would notice that he uses the stencil buffer to keep the reflection from rendering underneath of the floor >.>


im using a stencil buffer

Share this post


Link to post
Share on other sites