stk-code_catmod/data/shaders/shadowimportance.vert
vincentlj 42c16b32cb OGL32CTX: Replace deprecated "varying" by in/out semantic and make them explicit.
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
2014-01-09 00:17:28 +00:00

32 lines
616 B
GLSL

#version 130
uniform sampler2D dtex;
uniform mat4 ipvmat;
uniform mat4 shadowmat;
out vec3 wpos;
out vec2 texc;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
void main()
{
texc = gl_Vertex.xy / vec2(32767.0);
float z = decdepth(vec4(texture2D(dtex, texc).xyz, 0.0));
vec3 tmp = vec3(texc, z);
tmp = tmp * 2.0 - 1.0;
vec4 xpos = vec4(tmp, 1.0);
xpos = ipvmat * xpos;
xpos.xyz /= xpos.w;
wpos = xpos.xyz;
// Now we have this pixel's world-space position. Convert to shadow space.
vec4 pos = shadowmat * vec4(xpos.xyz, 1.0);
gl_Position = pos;
}