reworked lighting uniforms
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / gpos.fs
diff --git a/shaders/gpos.fs b/shaders/gpos.fs
new file mode 100644 (file)
index 0000000..b21f7a7
--- /dev/null
@@ -0,0 +1,30 @@
+out vec4 FragColor;
+
+uniform vec3 uCamera;
+
+in vec4 aColour;
+in vec2 aUv;
+in vec3 aNorm;
+in vec3 aCo;
+
+#include "common_world.glsl"
+
+// Water blending
+// ==============
+
+float water_depth( vec3 pos, vec3 halfview )
+{
+   vec3 pnorm = g_water_plane.xyz;
+   float pdist = g_water_plane.w;
+
+   float d = dot( pnorm, halfview );
+   float t = dot((pnorm*pdist - pos), pnorm) / d;
+   return t * g_water_fog;
+}
+
+void main()
+{
+   vec3 halfview = normalize( uCamera - aCo );
+   vec3 world_pos = vec3( aCo.y, aCo.x, aCo.z );
+   FragColor = vec4( world_pos, water_depth( aCo, halfview ) );
+}