2014-01-04 19:08:00 -05:00
|
|
|
#version 130
|
2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform int hastex;
|
|
|
|
uniform int viz;
|
|
|
|
uniform int wireframe;
|
|
|
|
uniform float objectid;
|
|
|
|
|
2014-01-08 19:17:28 -05:00
|
|
|
in vec2 uv;
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
2014-01-08 19:17:28 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
vec4 encdepth(float v) {
|
|
|
|
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
|
|
|
enc = fract(enc);
|
|
|
|
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
|
|
|
return enc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
|
|
if (hastex != 0) {
|
2014-01-19 12:53:35 -05:00
|
|
|
float alpha = texture(tex, uv).a;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
if (alpha < 0.5)
|
|
|
|
discard;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viz < 1)
|
|
|
|
{
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (wireframe > 0)
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(1.0);
|
2013-11-30 16:33:06 -05:00
|
|
|
else
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = texture(tex, uv);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|