【问题标题】:Using Sampler3D to read from a 3D texture in OpenGL ES 3.x在 OpenGL ES 3.x 中使用 Sampler3D 从 3D 纹理中读取
【发布时间】:2017-11-05 04:00:21
【问题描述】:

我正在使用 OpenGL ES 3.2 从片段着色器中的 3D 纹理读取并将该值写入 FBO。然后我使用 glReadPixels 从 FBO 附件中读取,并打印出获得的值。

我将采样器附加为:

GLuint texLoc = glGetUniformLocation(shader_program_new, "input_tex");
glUniform1i(texLoc, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D, texture_output);

在着色器中,我从纹理中读取为:

#version 300 es
precision highp float;
precision highp sampler3D;
    
uniform sampler3D input_tex;
in vec3 tex_pos;
out vec4 fragmentColor;
    
void main() {
    fragmentColor = texture(input_tex, vec3(0.0, 0.0, 0.0)); // nonzero z co-ordinate doesn't work    
}

在读取纹理时,我只能读取 z 坐标为 0 的值。从任何其他深度读取值会给出垃圾值或 NAN。

3D 纹理不应该允许我使用 (x, y, z) 值作为纹理坐标,其中 x、y 和 甚至 z 可以介于 0.0 和 1.0 之间?

【问题讨论】:

    标签: opengl-es 3d-texture opengl-es-3.1


    【解决方案1】:

    让我猜猜:你没有正确初始化纹理。
    请显示纹理创建代码。

    【讨论】:

      【解决方案2】:

      这很可能是由于 3D 纹理没有被绑定为分层。

      看看这个:Compute shader not modifying 3d texture

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-14
        • 1970-01-01
        • 2017-11-09
        • 1970-01-01
        • 2019-08-12
        • 1970-01-01
        相关资源
        最近更新 更多