我想用橙色覆盖我的立方体对象,我试图通过从深度纹理采样来做到这一点:如果有深度值< 1.0 then there is cube so paint fragment to orange color.
所有纹理和窗口都有 1280x720 大小
有我的顶点着色器
#version 410 core
uniform vec2 bound[4] = vec2[](vec2(-1.0f, 1.0f),
vec2(-1.0f, -1.0f), vec2(1.0f, 1.0f), vec2(1.0f, -1.0f)); // just rectangular rendering in trinagle_stripped mode
void main(){
gl_Position = vec4(bound[gl_VertexID], 1.0f, 1.0f);`
}
这是我的片段着色器
#version 410 core
out vec4 out_color;
uniform sampler2D depth; //depth texture
uniform vec2 icoord; // (1/1280, 1/720) inverse window size
uniform vec3 color; // orange color
void main(){
float o = texture(depth, icoord * gl_FragCoord.xy).r;
if(o < 1.0f)
out_color = vec4(color, 0.4f);
else
discard;
}
直接渲染传递,但我不明白是什么导致了这种行为。
我尝试使用不同的混合模式,但似乎问题不在这里,所以我只是禁用它。