stk-code_catmod/data/shaders/simple_particle.frag

28 lines
815 B
GLSL
Raw Normal View History

2017-10-13 12:19:59 -04:00
uniform sampler2D tex;
uniform sampler2D dtex;
uniform float billboard;
2017-10-13 12:19:59 -04:00
in vec2 tc;
in vec4 pc;
out vec4 FragColor;
#stk_include "utils/getPosFromUVDepth.frag"
void main(void)
{
float billboard_alpha = mix(1.0, texture(tex, tc).a, billboard);
2021-03-07 02:41:00 -05:00
vec4 color = texture(tex, tc);
#if defined(Advanced_Lighting_Enabled)
vec2 xy = gl_FragCoord.xy / u_screen;
2017-10-13 12:19:59 -04:00
float FragZ = gl_FragCoord.z;
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), u_inverse_projection_matrix);
2017-10-13 12:19:59 -04:00
float EnvZ = texture(dtex, xy).x;
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), u_inverse_projection_matrix);
2017-10-13 12:19:59 -04:00
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
#else
float alpha = 1.0;
#endif
2021-03-07 02:41:00 -05:00
color = vec4(color.rgb * color.a, color.a);
FragColor = color * billboard_alpha * pc * alpha;
2017-10-13 12:19:59 -04:00
}