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
44 lines
996 B
GLSL
44 lines
996 B
GLSL
#version 130
|
|
uniform sampler2D tex;
|
|
uniform vec2 screen;
|
|
uniform vec2 dir;
|
|
uniform vec2 dir2;
|
|
|
|
in vec2 uv;
|
|
in vec2 edger_uv;
|
|
in float camdist;
|
|
|
|
void main()
|
|
{
|
|
vec2 tc = uv;
|
|
|
|
vec4 col = vec4(0.0);
|
|
const float maxlen = 0.02;
|
|
|
|
float horiz = texture2D(tex, tc + dir).x;
|
|
float vert = texture2D(tex, (tc.yx + dir2) * vec2(0.9)).x;
|
|
|
|
vec2 offset = vec2(horiz, vert);
|
|
offset *= 2.0;
|
|
offset -= 1.0;
|
|
|
|
// Fade according to distance to cam
|
|
float fade = 1.0 - smoothstep(1.0, 100.0, camdist);
|
|
|
|
// Fade according to distance from the edges
|
|
vec2 edger = edger_uv;
|
|
const float mindist = 0.1;
|
|
fade *= smoothstep(0.0, mindist, edger.x) * smoothstep(0.0, mindist, edger.y) *
|
|
(1.0 - smoothstep(1.0 - mindist, 1.0, edger.x)) *
|
|
(1.0 - smoothstep(1.0 - mindist, 1.0, edger.y));
|
|
|
|
offset *= 50.0 * fade * maxlen;
|
|
|
|
col.r = step(offset.x, 0.0) * -offset.x;
|
|
col.g = step(0.0, offset.x) * offset.x;
|
|
col.b = step(offset.y, 0.0) * -offset.y;
|
|
col.a = step(0.0, offset.y) * offset.y;
|
|
|
|
gl_FragColor = col;
|
|
}
|