执行以下片段着色器时出现错误:
#version 430 core
in vec4 pos; // <-- input (x,y,z) position normalized to [0, 1]
in vec4 screenPos; // <-- input screen position normalized to [-1, 1]
out vec4 outColor;
uniform sampler3D volumeTex; // <-- a volume
uniform sampler2D backFaceTex; // <-- the backface of a cube previously saved to texture
void main()
{
if(gl_FrontFacing) {
vec4 front = pos;
vec4 back = texture(backFaceTex, (screenPos.xy/screenPos.w+1.0)/2.0);
// only one of the following 4 lines is uncommented at a time
outColor = front; // <-- Ok
outColor = back; // <-- Ok
outColor = texture(volumeTex, front.xyz); // <-- Ok
outColor = texture(volumeTex, back.xyz); // <-- Error
}
else {
discard;
}
}
正如您从我的评论中看到的那样,该程序运行良好,在前三种情况下渲染了我期望的图像,但在第四种情况下失败了(我唯一需要的)。
没有呈现任何内容,并且我从主应用程序中的 glGetError() 收到错误。
似乎禁止使用纹素作为另一个纹理提取操作的坐标参数。
谁能告诉我问题出在哪里?