1

我有一个大小为 16x16x6 的 GL_TEXTURE_3D,它已在计算着色器中填充了浮点数,我正在尝试在片段着色器中对其进行采样。

为了使其可用于片段着色器,我在绘制调用之前有以下代码:

//Set the active texture and bind it
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D, textureID);

//Add the sampler uniform
glUniform1i(glGetUniformLocation(textureID, "TextureSampler"), 0);

然后在片段着色器本身:

uniform sampler3D TextureSampler;

然后测试纹理是否正确通过:

vec4 test = texture(TextureSampler, ivec3(0,0,0));

color = vec4(1.0,0.0,0.0,1.0) * test.x; //or test.y, test.z, test.w

基于此,看起来每个纹素值都是(0.0,0.0,0.0,1.0)

我想不通这是为什么?我希望坐标(0,0,0)值是(16.0,0.0,0.0,0.0)或者(16.0,16.0,16.0,16.0)基于我在计算着色器中设置的值

PS 可能值得注意的是,这些值被正确写入纹理我检查计算和片段着色器调用之间使用glGetTexImage()

4

0 回答 0