numerous
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / gpos.fs
1 out vec4 FragColor;
2
3 uniform vec3 uCamera;
4
5 in vec4 aColour;
6 in vec2 aUv;
7 in vec3 aNorm;
8 in vec3 aCo;
9 in vec3 aWorldCo;
10
11 #include "common_world.glsl"
12
13 // Water blending
14 // ==============
15
16 float water_depth( vec3 pos, vec3 halfview )
17 {
18 vec3 pnorm = g_water_plane.xyz;
19 float pdist = g_water_plane.w;
20
21 float d = dot( pnorm, halfview );
22 float t = dot((pnorm*pdist - pos), pnorm) / d;
23 return t * g_water_fog;
24 }
25
26 void main()
27 {
28 vec3 halfview = normalize( uCamera - aCo );
29 vec3 world_pos = vec3( aCo.y, aCo.x, aCo.z );
30 FragColor = vec4( world_pos, water_depth( aCo, halfview ) );
31 }