stk-code_catmod/data/shaders/particle.frag
vincentlj 53e32a9848 GPUParticles: bump shaders version to 140 to enable texture buffer support.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14971 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2014-01-08 19:09:04 +00:00

26 lines
737 B
GLSL

#version 140
uniform sampler2D texture;
uniform sampler2D normals_and_depth;
uniform mat4 invproj;
uniform vec2 screen;
in float lf;
in vec2 tc;
out vec4 color;
void main(void)
{
vec2 xy = gl_FragCoord.xy / screen;
float FragZ = gl_FragCoord.z;
float EnvZ = texture2D(normals_and_depth, xy).a;
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
FragmentPos /= FragmentPos.w;
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
EnvPos /= EnvPos.w;
float len = dot(vec3(1.0), abs(texture2D(normals_and_depth, xy).xyz));
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
color = texture2D(texture, tc);
color.a *= alpha * smoothstep(1., 0.8, lf);
}