I am rendering textured quads (in screen space) and I want to specify the texture in the vertex data, send as a flat output to the fragment shader, and use to select the texture. The value is being changed during this process. In RenderDoc the VS input is 2 and output is 1073741824 (for every vertex). anyone have any idea why? (4.6 core context, shaders #version 460). I am uploading 6 vertices per quad and using glDrawArrays(). Texture stage 0 works, but any non-zero value is transformed.
layout(location=0) in vec3 coord3d;
layout(location=1) in vec2 uvIn;
layout(location=2) in vec3 colorIn;
layout(location=3) in unsigned int textureStageIn;
out vec4 color;
out vec2 uv;
flat out unsigned int textureStage;
void main(void)
{
gl_Position = vec4( coord3d, 1.0 );
color = vec4(colorIn,1.0);
uv = uvIn;
textureStage = textureStageIn;
}
in vec4 color;
in vec2 uv;
flat in unsigned int textureStage;
uniform sampler2D tex00;
uniform sampler2D tex01;
uniform sampler2D tex02;
out vec4 outpColor;
void main(void)
{
vec2 uvDx = dFdx(uv);
vec2 uvDy = dFdy(uv);
switch ( textureStage )
{
case 0:
outpColor = textureGrad(tex00, uv, uvDx, uvDy );
break;
case 1:
outpColor = textureGrad(tex01, uv, uvDx, uvDy );
break;
case 2:
outpColor = textureGrad(tex02, uv, uvDx, uvDy );
break;
default:
outpColor = color;
break;
}
}
glVertexAttribIPointer(focus onI) for the specification of integral attributes. In compare toglVertexAttribPointerfor floating point attributes. SeeglVertexAttribPointer