PDA

View Full Version : Mirror using a texture is slow



Jambolo
04-27-2002, 11:29 AM
I have implemented a mirror by rendering the reflected scene and copying to a texture. Unfortunately, copying to a texture is very slow and I can't use the render-to-texture extension. I can speed it up somewhat by using a smaller reflection texture, but the quality of the reflection image is already low and that only makes it worse.

All the examples I've looked at use this technique: render the reflected scene, then clear the depth buffer, then render the mirror, then render the scene normally. This technique is much faster because it doesn't involve copying to a texture.

However, I don't want to use this technique because I see two important limitations:

1. You can only have one mirror plane.
2. You can't perturb the reflection.

Are these limitations real? How would I get around them?

[This message has been edited by Jambolo (edited 05-07-2002).]

zed
04-27-2002, 12:43 PM
to get greatest speed with copying to a texture use glTexSubImage2D(..) + chosse the correct format eg in 32 bit colour for my gf2mx this method is the quickest
BGRA -- UNSIGNED_INT_8_8_8_8_REV 130.056 Mpixels/sec

davepermen
04-27-2002, 12:43 PM
what gpu do you use? and what drivers for it?

MPech
04-27-2002, 01:17 PM
if your reflected scene is rather simple, a technik consist in replacing your textured polygon (your mirror) with a blended one and draw the same scene in both side of the mirror. It's not a joke ! in many case it's faster than using render-to-texture technik.

Cem UZUNLAR
04-27-2002, 03:12 PM
Originally posted by zed:
to get greatest speed with copying to a texture use glTexSubImage2D(..) + chosse the correct format eg in 32 bit colour for my gf2mx this method is the quickest
BGRA -- UNSIGNED_INT_8_8_8_8_REV 130.056 Mpixels/sec

I think that you mean 24 bits color + 8 bits alpha in pixelformat by saying 32 bits. Because if you use 32 bits color and 0 bit alpha in pixelformat, glcopytexsubimage2d to a gl_rgba is not accelerated. So isnt using
format: gl_rgba
internalformat: gl_rgba8
type: gl_unsigned_byte

gives the same performance as BGRA -- UNSIGNED_INT_8_8_8_8_REV ?

[This message has been edited by Cem UZUNLAR (edited 04-27-2002).]

irionar
04-30-2002, 01:33 AM
Why can you have only one mirror plane ?
I use the stencil buffer to give each mirror plane an id. Then I render the mirrored scene for each mirror with stencil test.
--Alex

Jambolo
05-07-2002, 09:29 PM
Originally posted by daveperman:
what gpu do you use? and what drivers for it?


I have a Savage 4 and the latest drivers I can find. I suppose I could get a new video card.


Originally posted by irionar:
Why can you have only one mirror plane ?


Good question...I'm not using a stencil buffer, so the number or mirrors is definitely limited to one. However, with a stencil buffer, I can have more than one mirror if they don't intersect and I draw back to front. Cool.

dorbie
05-08-2002, 01:23 AM
Savage 4 is a pretty old card now.

This survey may interest you:
http://valve.speakeasy.net/