Render to texture

Is there a specific optimized way to render two textures into a third ? I’d like to compose a texture with some others, adding layers one after another, and specifying an amount for each layer. (only plain 2D textures)

Will it be the same if I want to render small textures into a bigger one (as instance small particles z-sorted in an impostor) ?

Will it be the same if I render 3D meshes into a texture ?

I read kinda everywhere that WGL_ARB_render_texture should be left alone, and that everybody should use glCopyTexSubImage2D, why is that ?

Thanks,
SeskaPeel.

To maximize rendering into texture performance you should combine pbuffers with render to texture…

As for your problem, please be more specific…

n3rvu5

Combining two textures can be done with simple multitexturing. You can either just use the two textures (ie. no need to actually combine them) or you could render a quad into your 3rd texture using multitexture (or multipass - whatever suits).

As for the other uses you mentioned, yes they are the same principles. You can create imposters by rendering your geometry to a texture and then use that texture on a billboard. And you could use the same for particle engine imposters (though I can’t see how that would benefit you).

The Render-to-texture vs CopyTexSubImage argument depends on both your hardware and the resolution of the texture you are creating.

If your texture is high resolution, then Render to texture is the way to go. If it’s small then CopyTexSubImage is best choice. This is for two reasons. With pbuffers, the context switch can be quite expensive (I’m just talking nVidia here - I haven’t used any ATI hardware) and with small textures you can Copy far quicker than you can swap contexts.

However if the texture is larger than your window, you have to use pbuffers (theres been plenty of discussion about that sort of issue on this forum). Plus the context switch becomes more efficient above a certain size because of the number of pixels that would need to be copied otherwise.

Unfortunately I haven’t done the tests to be able to tell you at what level a texture stops being “small” (ie. Copy) and becomes “big” (ie. Render to texture).