2017-10-13 12:19:59 -04:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform sampler2D dtex;
|
2018-02-02 11:21:59 -05:00
|
|
|
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)
|
|
|
|
{
|
2022-09-08 21:41:32 -04:00
|
|
|
vec4 color = texture(tex, tc) * pc;
|
2018-01-25 02:36:34 -05:00
|
|
|
#if defined(Advanced_Lighting_Enabled)
|
2017-12-25 01:00:10 -05:00
|
|
|
vec2 xy = gl_FragCoord.xy / u_screen;
|
2017-10-13 12:19:59 -04:00
|
|
|
float FragZ = gl_FragCoord.z;
|
2017-12-25 01:00:10 -05:00
|
|
|
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), u_inverse_projection_matrix);
|
2017-10-13 12:19:59 -04:00
|
|
|
float EnvZ = texture(dtex, xy).x;
|
2017-12-25 01:00:10 -05:00
|
|
|
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.);
|
2022-09-08 21:41:32 -04:00
|
|
|
// TODO remove this later if possible when implementing GE
|
|
|
|
alpha = mix(alpha, texture(tex, tc).a, billboard);
|
2018-01-25 02:36:34 -05:00
|
|
|
#else
|
|
|
|
float alpha = 1.0;
|
|
|
|
#endif
|
2022-09-08 21:41:32 -04:00
|
|
|
color = vec4(color.rgb * color.a * alpha, color.a * alpha);
|
|
|
|
FragColor = color;
|
2017-10-13 12:19:59 -04:00
|
|
|
}
|