Patrik
Patrik

Reputation: 2692

Copy depth texture to RGBA texture

I have created a texture using

glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, CONSENSUS_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);

This texture is used in other code and filled with depth. Now I want to copy the depth values to an RGBA texture (doesn't matter which color channel).

How can I do this?

Upvotes: 1

Views: 464

Answers (1)

warhead
warhead

Reputation: 446

If it needs to be fast, I'd say render an orthograhic quad the size of the texture and use a shader to read from the depth texture and write to the target texture.

If performance doesn't matter that much you can use PBOs (might even be faster depending on your render pipeline but stalls the CPU). Here's an overview on said PBOs

I don't know of any inherent OpenGL method to do this.

Upvotes: 3

Related Questions