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

Mirror

Started by CastorX Sep 10, 2005 at 10:39 AM 1 replies 350+ views
Original Post
CastorX
CastorX
Hello! Q1: How can I render the scene onto a mirror, without doble rendering? I mean that I want to draw the whole scene only one time. Is it able? Q2: I would like to render glass effect, with one booth, so I need the content of the backbuffer. That's OK. But HOW can I use the back buffer as a texture; or I need to render the scene onto a texture, without the backbuffer, and then render that texture with the HLSL-shadered scree-quad? Thanx!
Muhammad Haggag
Muhammad Haggag
Quote:
Original post by CastorX
Hello!
Q1: How can I render the scene onto a mirror, without doble rendering? I mean that I want to draw the whole scene only one time. Is it able?

No, it's not possible. You have to render the scene, and you have to render the reflection. If your scenes are static, you can generate environment maps for them as a preprocessing step, and use these for reflection.

Quote:
Q2: I would like to render glass effect, with one booth, so I need the content of the backbuffer. That's OK. But HOW can I use the back buffer as a texture; or I need to render the scene onto a texture, without the backbuffer, and then render that texture with the HLSL-shadered scree-quad?

- booth?
- Render the scene to a texture, then render the texture with a screen-sized quad.

Armadon
Armadon
Hi there CastorX,
How are you doing?

The Problem
How to create a mirror effect, basically reflecting.

The Solution
There are a number of ways to do this. But I don't know of a possible solution that you can just render the entire scene once to get a mirror effect.

The general approach:
- Render to Texture.
- Create a render target using D3DXCreateTexture and the flag
D3DUSAGE_RENDERTARGET
- Save the current back buffer.
- Set the newly created texture as a back buffer
- Render your scene from the mirror's view to the render target (texture)
- Replace the old render target (back buffer)
- Render the mirror with the texture applied (render target texture)

- You could also use stenciling to clip the mirror so that only the mirror shows
reflected parts.

I hope this helps a bit bud.

Topic Locked

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

Sign in to reply to this topic.