stk-code_catmod/data/shaders/particle.frag

23 lines
688 B
GLSL
Raw Normal View History

uniform sampler2D tex;
2014-01-27 13:42:48 -05:00
uniform sampler2D dtex;
uniform mat4 invproj;
2014-05-16 20:39:55 -04:00
in float lf;
in vec2 tc;
in vec3 pc;
out vec4 FragColor;
2014-08-13 15:04:03 -04:00
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
void main(void)
{
2014-08-13 15:04:03 -04:00
vec2 xy = gl_FragCoord.xy / screen;
float FragZ = gl_FragCoord.z;
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), InverseProjectionMatrix);
float EnvZ = texture(dtex, xy).x;
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), InverseProjectionMatrix);
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
2014-05-10 14:58:43 -04:00
FragColor = color * alpha * smoothstep(1., 0.8, lf);
}