简体   繁体   中英

Is it possible to downsample an OpenGL ES depth buffer WITHOUT GL_OES_depth_texture?

I'm working on a game for mobile platforms, and I'd like to render my effects to a lower resolution render target than the screen. The issue is, I need to start with the depth buffer from the full screen.

If the hardware supported GL_OES_depth_texture, I imagine it would be relatively straightforward, but unfortunately I don't, so I am wondering if there is any other way to get the depth information from the full screen render and use that for my lower resolution render.

If I can't actually downsample the render buffer, could I bind the higher resolution depth buffer to a render target with a lower resolution color buffer? I can't find any documentation that says that the resolutions of all the different attachments to the frame buffer object have to match in resolution, but I strongly suspect that is a requirement.

Thanks for your help!

I think you should render to a texture attached to an FBO. The texture could have whatever lower resolution you want. Textures are really the only FBO attachments that are actually useful in OpenGL ES 1.1 and 2.0, on most platforms.

Thanks Andon.

What Andon is suggesting is that you could render into a texture with an ordinary GL_RGBA format that OpenGL ES 2.0 understands, but packing/encoding the color in some more efficient way. You can do this if you only use that texture to render with a custom fragment shader that unpacks/decodes the custom format you put it in. For example, the values you read from a texture sampler can really be in any format you want.

float fR = texture2D(gsuTexture0, gsvTexCoord0).r;
float fG = texture2D(gsuTexture0, gsvTexCoord0).g;
float fB = texture2D(gsuTexture0, gsvTexCoord0).b;
float fA = texture2D(gsuTexture0, gsvTexCoord0).a;

float fDepth = fR;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM