Sign in to follow this  

Mirror in my racing simulation

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

i want to create a mirror on my vehicles in the game. my first idea was: create second viewport (small) and render the scene for the image of the mirror readthepixels from the viewport draw the normal scene in the other viewport and bind the texture over the mirror but have worries about the performace. are there better methods? hope you understand me thanks

Share this post


Link to post
Share on other sites
Hmm mirror in a car, as long as your talking about rear view mirrors for a first person style racing game, you can use the stencil buffer, to cut out your mirror, then draw the back ground in the cut out section. or you could Render a texture of your mirror and then use that texture, useing pbuffers/fbo or whatever you prefer. If you have any questions just ask =D

Share this post


Link to post
Share on other sites
the problem is: i think the generation of the texture is slow. the glReadPixels and the Texturegeneration. i don't understand your description with the stencil buffer. if i use the stencilbuffer and glScissor i still have to render the scene 2 times because of the different view right?

Share this post


Link to post
Share on other sites
Quote:
Original post by Eitsch
the problem is: i think the generation of the texture is slow. the glReadPixels and the Texturegeneration.

Don't use ReadPixels. It will kill performance, since your data will make a roundtrip over the AGP to the CPU and back. So either use glCopyTexSubImage2D() (keeping everything on VRAM), or render directly to the texture through pbuffers / FBO.

Quote:

i don't understand your description with the stencil buffer. if i use the stencilbuffer and glScissor i still have to render the scene 2 times because of the different view right?

You'll have to render it twice anyway, even if you render to a texture: once from the reflected view point, and once the actual player view. But since the mirror surface is usually very small compared to your actual screen size, you will be able to cull away a large percentage of the geometry when rendering the reflection. Using glScissor() in addition to geometric culling will help with fillrate.

Share this post


Link to post
Share on other sites
thanks. only one thing: do you have a good example or tutorial on pbuffers and FBO. i have never read something about it so far and i have no idea how to program it.

thanks

Share this post


Link to post
Share on other sites

This topic is 4593 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this