0

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!

4

1 回答 1

1

我认为您应该渲染到附加到 FBO 的纹理。纹理可以具有您想要的任何较低分辨率。在大多数平台上,纹理实际上是唯一在 OpenGL ES 1.1 和 2.0 中真正有用的 FBO 附件。

谢谢安东。

Andon 的建议是,您可以使用 OpenGL ES 2.0 理解的普通 GL_RGBA 格式渲染纹理,但以更有效的方式打包/编码颜色。如果您只使用该纹理来使用自定义片段着色器进行渲染,该着色器可以解包/解码您放入的自定义格式,则可以执行此操作。例如,您从纹理采样器读取的值实际上可以是您想要的任何格式。

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;
于 2013-10-04T23:12:46.320 回答