fov slider input maps menu stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / water.h
index 13a718f2eb2102bccefc8b83d2ad6a8d78ef4dd0..a333516e453f3db277b8970a0707e2691b06d8e5 100644 (file)
@@ -11,13 +11,15 @@ static struct vg_shader _shader_water = {
 .static_src = 
 "layout (location=0) in vec3 a_co;\n"
 "layout (location=1) in vec3 a_norm;\n"
-"layout (location=2) in vec4 a_colour;\n"
-"layout (location=3) in vec2 a_uv;\n"
+"layout (location=2) in vec2 a_uv;\n"
+"layout (location=3) in vec4 a_colour;\n"
+"layout (location=4) in vec4 a_weights;\n"
+"layout (location=5) in ivec4 a_groups;\n"
 "\n"
 "#line      2        0 \n"
 "\n"
-"uniform mat4 uPv;\n"
 "uniform mat4x3 uMdl;\n"
+"uniform mat4 uPv;\n"
 "\n"
 "out vec4 aColour;\n"
 "out vec2 aUv;\n"
@@ -51,6 +53,9 @@ static struct vg_shader _shader_water = {
 "uniform vec3 uCamera;\n"
 "uniform float uSurfaceY;\n"
 "\n"
+"uniform vec3 uShoreColour;\n"
+"uniform vec3 uOceanColour;\n"
+"\n"
 "in vec4 aColour;\n"
 "in vec2 aUv;\n"
 "in vec3 aNorm;\n"
@@ -69,6 +74,7 @@ static struct vg_shader _shader_water = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -133,6 +139,11 @@ static struct vg_shader _shader_water = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\n"
+"\n"
 "   float fspread = g_light_colours[0].w;\n"
 "   vec3  vdir = g_light_directions[0].xyz;\n"
 "   float flength = g_light_directions[0].w;\n"
@@ -155,14 +166,12 @@ static struct vg_shader _shader_water = {
 "   return mix( vfrag, vec3(0.55,0.76,1.0), min( 1.0, dist ) );\n"
 "}\n"
 "\n"
-"#line     19        0 \n"
+"#line     22        0 \n"
 "\n"
 "vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue, \n"
 "      vec4 beneath, vec4 above )\n"
 "{\n"
-"   vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );\n"
-"   vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );\n"
-"   vec3 surface_tint = mix(colour_shore, colour_ocean, depthvalue);\n"
+"   vec3 surface_tint = mix(uShoreColour, uOceanColour, depthvalue);\n"
 "\n"
 "   float ffresnel = pow(1.0-dot( vnorm, halfview ),5.0);\n"
 "\n"
@@ -218,8 +227,8 @@ static struct vg_shader _shader_water = {
 ""},
 };
 
-static GLuint _uniform_water_uPv;
 static GLuint _uniform_water_uMdl;
+static GLuint _uniform_water_uPv;
 static GLuint _uniform_water_uTexMain;
 static GLuint _uniform_water_uTexDudv;
 static GLuint _uniform_water_uTexBack;
@@ -227,13 +236,15 @@ static GLuint _uniform_water_uInvRes;
 static GLuint _uniform_water_uTime;
 static GLuint _uniform_water_uCamera;
 static GLuint _uniform_water_uSurfaceY;
+static GLuint _uniform_water_uShoreColour;
+static GLuint _uniform_water_uOceanColour;
 static GLuint _uniform_water_g_world_depth;
-static void shader_water_uPv(m4x4f m){
-   glUniformMatrix4fv( _uniform_water_uPv, 1, GL_FALSE, (float *)m );
-}
 static void shader_water_uMdl(m4x3f m){
    glUniformMatrix4x3fv( _uniform_water_uMdl, 1, GL_FALSE, (float *)m );
 }
+static void shader_water_uPv(m4x4f m){
+   glUniformMatrix4fv( _uniform_water_uPv, 1, GL_FALSE, (float *)m );
+}
 static void shader_water_uTexMain(int i){
    glUniform1i( _uniform_water_uTexMain, i );
 }
@@ -255,6 +266,12 @@ static void shader_water_uCamera(v3f v){
 static void shader_water_uSurfaceY(float f){
    glUniform1f( _uniform_water_uSurfaceY, f );
 }
+static void shader_water_uShoreColour(v3f v){
+   glUniform3fv( _uniform_water_uShoreColour, 1, v );
+}
+static void shader_water_uOceanColour(v3f v){
+   glUniform3fv( _uniform_water_uOceanColour, 1, v );
+}
 static void shader_water_g_world_depth(int i){
    glUniform1i( _uniform_water_g_world_depth, i );
 }
@@ -263,8 +280,8 @@ static void shader_water_register(void){
 }
 static void shader_water_use(void){ glUseProgram(_shader_water.id); }
 static void shader_water_link(void){
-   _uniform_water_uPv = glGetUniformLocation( _shader_water.id, "uPv" );
    _uniform_water_uMdl = glGetUniformLocation( _shader_water.id, "uMdl" );
+   _uniform_water_uPv = glGetUniformLocation( _shader_water.id, "uPv" );
    _uniform_water_uTexMain = glGetUniformLocation( _shader_water.id, "uTexMain" );
    _uniform_water_uTexDudv = glGetUniformLocation( _shader_water.id, "uTexDudv" );
    _uniform_water_uTexBack = glGetUniformLocation( _shader_water.id, "uTexBack" );
@@ -272,6 +289,8 @@ static void shader_water_link(void){
    _uniform_water_uTime = glGetUniformLocation( _shader_water.id, "uTime" );
    _uniform_water_uCamera = glGetUniformLocation( _shader_water.id, "uCamera" );
    _uniform_water_uSurfaceY = glGetUniformLocation( _shader_water.id, "uSurfaceY" );
+   _uniform_water_uShoreColour = glGetUniformLocation( _shader_water.id, "uShoreColour" );
+   _uniform_water_uOceanColour = glGetUniformLocation( _shader_water.id, "uOceanColour" );
    _uniform_water_g_world_depth = glGetUniformLocation( _shader_water.id, "g_world_depth" );
 }
 #endif /* SHADER_water_H */