将帧缓冲区对象附加到具有 8 位内部格式的 3D 纹理是否正确

发布于 2024-09-18 19:54:59 字数 485 浏览 1 评论 0原文

基本上,我的程序使用帧缓冲区对象来渲染 3D 纹理。 如果我附加到 fbo 的 3D 纹理是 GL_RGB8 格式,即每个纹素 24 位,则没有问题。仅使用其中的 8 位。 当我尝试使用 GL_ALPHA8(每个纹理元素 8 位)作为 3D 纹理的内部格式时,会出现问题,渲染结果为空白。 我用来渲染到 fbo 的 cg 片段着色器看起来像这样:

void F_PureDecoder(
    float3 vIndexCoord : TEXCOORD0,   
    out float color :COLOR)
{
        ... ...
    color=float4(fL3,fL3,fL3,fL3);
}

我做错了什么或者 fbo 不支持渲染到 8 位纹理像素纹理吗?我主要不确定片段着色器的输出格式是否正确。因为帧缓冲区是 8 位,但输出是 24 位。我应该修改片段着色器的输出格式吗?如果是这样,我应该使用什么格式?

非常感谢您的任何意见!

Basically, my program uses frame buffer object to render to a 3D texture.
If the 3D texture which I attach to fbo is in GL_RGB8 format, which is 24 bits per texel, there is no problem. Only 8-bits of them are used.
The problem happens when I try to use GL_ALPHA8 (8 bits per texel) as the internal format for the 3D texture, the rendering result is blank.
The cg fragment shader which I used to render to fbo looks like this:

void F_PureDecoder(
    float3 vIndexCoord : TEXCOORD0,   
    out float color :COLOR)
{
        ... ...
    color=float4(fL3,fL3,fL3,fL3);
}

Am I doing something wrong or fbo doesn't support to render to 8-bit texel texture? I am primarily unsure if the output format of fragment shader is correct. Coz the framebuffer is 8 bits but the output is 24 bits. Should I modify the output format from fragment shader? If so, what format should I use?

Thanks very much for any input!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆沫 2024-09-25 19:54:59

要渲染到一个/两个组件纹理,您必须使用 GL_ARB_texture_rg 扩展,它不适用于任何其他格式。请参阅 扩展规范 了解它不起作用的原因:

还希望能够渲染为一和二 
使用帧缓冲区等功能的组件格式纹理 
对象 (FBO),但渲染为 I/L/LA 格式未指定
(具体来说如何将 R/G/B/A 值映射到 I/L/A 纹理通道)。

因此,使用 GL_R8 内部格式。要写入它,只需写入完整的 RGBA 输出,但只会写入 R 分量。

To render to one/two component textures, you MUST use the GL_ARB_texture_rg extension, it will NOT work with any other format. See the extension specification for why it doesn't work:

It is also desirable to be able to render to one- and two- 
component format textures using capabilities such as framebuffer 
objects (FBO), but rendering to I/L/LA formats is under-specified
(specifically how to map R/G/B/A values to I/L/A texture channels).

So, use the GL_R8 internalFormat. To write to it, just write the full RGBA output, but only the R component will be written.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文