my fragment shader is as simple as:
#version 130
out vec4 oColor;
uniform sampler2D depthTexture;
smooth in vec4 oPosition;
smooth in vec4 texPosition;
void main(void)
{
texPosition.x /= texPosition.w;
texPosition.y /= texPosition.w;
texPosition.z /= texPosition.w;
float depth = texture(depthTexture, texPosition.xy).r;
float dis = texPosition.z - depth;
if(dis < 0.0001)
oColor = vec4(0.01, 0.01, 0.01, 0.0);
else if (dis <0.00015)
oColor = vec4( 0, 0.01 , 0.01, 0);
else
oColor = vec4(0, 0, 0.01, 0);
}
when I compile, the compiler said:
error C7565: assignment to varying in texPosition
three times.
I cannot find out the problem with the three lines above:
texPosition.x /= texPosition.w;
texPosition.y /= texPosition.w;
texPosition.z /= texPosition.w;