Jump to content
  • Advertisement
Sign in to follow this  
rahulpawar

OpenGL Mirror Reflections

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

This is My Scene It is in C++ using DX9

Here the character and the SEO are drawn using their own custom shaders.
Also u can see light source it causes real time shadows.
Now I got a scene graph that hold this info culls it( using camera view frustum culling ) all texture shader data are provided by respected scene objects during rendering.

TestCase2.jpg

My question is how to arrange the rendering pipeline so that I can get,

Real time reflection in the mirror of all those different objects ( i.e. Custom Shaded Objects, Skinned Normal Mapped Character, Dynamic Shadows)

Now I figured this by some Googling that for getting such reflection u need to do a Render-To-Texture in 1st pass and then use it in 2nd pass to create the reflection..............Now this can be achieved easily in single shader program ................but how can i carry all those data from all those different objects with different shaders attached ...............

However, an article i read somewhere, it was in OpenGL but, it suggested use of Render-To-CubeMap(6 pass Rendering) of entire scene using their respective shaders and then using it as environment map for mirrors texture in its pixel shader [ sorry i don't have the link for that article now]..........the article just suggested this method.............but

Can anyone explain how this can be achieved , what ordered steps should be followed to get everything reflected properly...? or any method which could be used ?

Share this post


Link to post
Share on other sites
Advertisement
Hi,

To achieve what you want to, you should render the scene to a paraboloid render target and then perform environment mapping with the paraboloid render target to draw the mirror.

Read this article It will teach you how to create a dual paraboloid environment map.

Basically you render everything except the mirror to a render target and then you pass the render target to the mirror shader as a shader resource view, so you can sample it and draw the refelection

Share this post


Link to post
Share on other sites
There is also sample code in the article that Tiago linked to, so you can have a reference implementation too...

Share this post


Link to post
Share on other sites
Why would you use a paraboloid environment map for a simple flat mirror? A planar reflection should give the best result I think.

Just flip the camera over the mirror's plane, and draw the scene as you would normally with all your shaders, and then when you draw the mirror sample from it using projective texturing. Should give a much less distorted image than an environment map.

Share this post


Link to post
Share on other sites

Why would you use a paraboloid environment map for a simple flat mirror? A planar reflection should give the best result I think.

Just flip the camera over the mirror's plane, and draw the scene as you would normally with all your shaders, and then when you draw the mirror sample from it using projective texturing. Should give a much less distorted image than an environment map.

That's right - for some reason I thought the OP was asking about environment mapping techniques (implying non-flat geometry) so I assumed he wanted to see something like that. Planar reflections are a good solution to the 'flat-mirror' type effect, as karwosts mentioned.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!