42c16b32cb
gl_Texcoord[]/gl_Color should be explocitly passed as in/out. Compilers can pack varyings if the architecture does benefit from it (for instance intel mesa driver) but on the other hand they usually don't change size of varying even if there is only a single component used. So storing vec2 into vec4 may waste performances. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14974 178a84e3-b1eb-0310-8ba1-8eac791a3b58
38 lines
613 B
GLSL
38 lines
613 B
GLSL
#version 130
|
|
uniform sampler2D tex;
|
|
uniform int hastex;
|
|
uniform int viz;
|
|
uniform int wireframe;
|
|
uniform float objectid;
|
|
|
|
in vec2 uv;
|
|
|
|
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) {
|
|
float alpha = texture2D(tex, uv).a;
|
|
|
|
if (alpha < 0.5)
|
|
discard;
|
|
}
|
|
|
|
if (viz < 1)
|
|
{
|
|
gl_FragColor = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
|
}
|
|
else {
|
|
if (wireframe > 0)
|
|
gl_FragColor = vec4(1.0);
|
|
else
|
|
gl_FragColor = texture2D(tex, uv);
|
|
}
|
|
}
|
|
|