次のフラグメント シェーダーの実行中にエラーが発生します。
#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;
}
}
私のコメントから読み取れるように、最初の 3 つのケースではプログラムは正常に動作し、期待どおりの画像をレンダリングしますが、4 つ目のケース (必要な唯一のもの) では失敗します。
何もレンダリングされず、メイン アプリの glGetError() からエラーが発生します。
別のテクスチャ フェッチ操作の座標パラメータとしてテクセルを使用することは禁止されているようです。
誰が問題がどこにあるのか教えてもらえますか?