Jump to content
  • Advertisement

Archived

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

Oniera

Mirrors + Reflections

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

Can anyone point me in the direction of some sample code on how to create a mirrored surface in D3D? Documentation in this area is very much lacking. Let''s say I''m creating a pool of water, I want the pool to reflect the surrounding enviroment. Any ideas anyone? Demetrios G. Oniera Software Artists

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I''m looking into rendering mirrors too.

I''m sure the principle is; change the render target from the back buffer, to another surface (possibly with another z buffer attached), set the view matrix in a suitable position, and run through the main render loop .

In reality, you''ll probably have to use a cut down version of the main render loop to keep the speed up.

Then render the scene from the normal position, onto the back buffer, but one object in the scene will be mapped with the previously rendered surface.

I can see some problems here, because the reflection will always be dependant on the viewing position, so the viewport in the bottom of the pool will have to be dynamically adjusted to remain correct to the main viewport.

I''m going to do some experimenting soon, and I''ll let you know how I get on. In the mean-time I''ll keep my eye on this thread for some more practical info...

Regards

Matt


Check out my project at: www.btinternet.com/~Matthew.Bennett

Share this post


Link to post
Share on other sites
quote:
Original post by Oniera
Let's say I'm creating a pool of water, I want the pool to reflect the surrounding enviroment. Any ideas anyone?



Check this out.

I wrote this stuff a while ago, but it should work

It's under the second entry from the top.

MSN

Edited by - msn12b on 4/12/00 4:10:45 PM

Share this post


Link to post
Share on other sites
Thanks for the help guys! The theory is sound, and I should be able to figure it out. (it will take some time)

3DModelMan: Sadly there seems to be no way to render directly onto a texture. You have to render onto a 3D surface, then copy each pixel to the texture surface. (SLOW)
Let me know if you get anywhere with it.....

Demetrios G
Oniera Software Artists

Share this post


Link to post
Share on other sites
Hi

There is anotherway for rendering reflections. You can Render your scene normaly, than render your waterpool to the Stencil Buffer.Then Mirror your Scene about your Watersurface, and Render again while checking against the Stencil Buffer.

Lars

Share this post


Link to post
Share on other sites
Unfortunately most older cards don''t support stencil buffers. What you can do instead is to use clip planes to constrain the mirrored image to a convex polygon. You would need one clip plane for each edge in the polygon plus one for the surface of the polygon. With DX7 clip planes is supported directly in D3D so you don''t have to do it yourself anymore . This technique requires the mirror to be rendered before the rest of the scene otherwize you will get conflicts in the z-buffer.

Share this post


Link to post
Share on other sites
The method of reflection by using the clipping plane, I think is in theory the fastest. However, for reflective surfaces which are not rectangular, I think you have to use stencil buffers.

I will of course be using both methods, but I''ve noticed that both seem to be on the difficult(ish) side. I''ve built our entire 3D engine from scratch, and this is the only thing I can''t wrap my head around. Blech! I will try both theories and let you know....

Demetrios G
Oniera

Share this post


Link to post
Share on other sites

  • 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!