Mirror in my racing simulation

Started by
3 comments, last by Eitsch 18 years, 11 months ago
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
Advertisement
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
"I seek knowledge and to help those who also seek it"
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?
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.
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

This topic is closed to new replies.

Advertisement