X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fvblend.h;h=53154f6370469c6ccc0518109af339d220d40f98;hb=d57b7661518800479c00300ce57407378696eec9;hp=45782ad90fe506b6bedf2eff6c406cd0566974d8;hpb=168eb5c363f510d60703498e01ffcdb52bf9fd07;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/vblend.h b/shaders/vblend.h index 45782ad..53154f6 100644 --- a/shaders/vblend.h +++ b/shaders/vblend.h @@ -23,14 +23,17 @@ static struct vg_shader _shader_vblend = { "out vec2 aUv;\n" "out vec3 aNorm;\n" "out vec3 aCo;\n" +"out vec3 aWorldCo;\n" "\n" "void main()\n" "{\n" -" gl_Position = uPv * vec4( uMdl * vec4(a_co,1.0), 1.0 );\n" +" vec3 world_pos = uMdl * vec4(a_co,1.0);\n" +" gl_Position = uPv * vec4( world_pos, 1.0 );\n" " aColour = a_colour;\n" " aUv = a_uv;\n" " aNorm = mat3(uMdl) * a_norm;\n" " aCo = a_co;\n" +" aWorldCo = world_pos;\n" "}\n" ""}, .fs = @@ -42,12 +45,12 @@ static struct vg_shader _shader_vblend = { "uniform sampler2D uTexGarbage;\n" "uniform sampler2D uTexGradients;\n" "uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" "\n" "#line 1 1 \n" "layout (std140) uniform ub_world_lighting\n" @@ -102,7 +105,7 @@ static struct vg_shader _shader_vblend = { "\n" "float shadow_sample( vec3 vdir )\n" "{\n" -" vec3 sample_pos = aCo + vdir;\n" +" vec3 sample_pos = aWorldCo + vdir;\n" " float height_sample = world_depth_sample( sample_pos );\n" "\n" " float fdelta = height_sample - sample_pos.y;\n" @@ -154,7 +157,7 @@ static struct vg_shader _shader_vblend = { " vec3 vfrag = vec3(0.5,0.5,0.5);\n" "\n" " // ws modulation\n" -" vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.160 );\n" +" vec4 wgarbage = vec4(0.5,0.5,0.5,1.0);//texture( uTexGarbage, aCo.xz * 0.160 );\n" " \n" " // Creating normal patches\n" " vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n" @@ -180,7 +183,7 @@ static struct vg_shader _shader_vblend = { " }\n" "\n" " // Lighting\n" -" vec3 halfview = uCamera - aCo;\n" +" vec3 halfview = uCamera - aWorldCo;\n" " float fdist = length( halfview );\n" " halfview /= fdist;\n" "\n" @@ -199,7 +202,6 @@ static GLuint _uniform_vblend_uMdl; static GLuint _uniform_vblend_uTexGarbage; static GLuint _uniform_vblend_uTexGradients; static GLuint _uniform_vblend_uCamera; -static GLuint _uniform_vblend_uPlane; static GLuint _uniform_vblend_g_world_depth; static void shader_vblend_uPv(m4x4f m){ glUniformMatrix4fv( _uniform_vblend_uPv, 1, GL_FALSE, (float *)m ); @@ -216,9 +218,6 @@ static void shader_vblend_uTexGradients(int i){ static void shader_vblend_uCamera(v3f v){ glUniform3fv( _uniform_vblend_uCamera, 1, v ); } -static void shader_vblend_uPlane(v4f v){ - glUniform4fv( _uniform_vblend_uPlane, 1, v ); -} static void shader_vblend_g_world_depth(int i){ glUniform1i( _uniform_vblend_g_world_depth, i ); } @@ -232,7 +231,6 @@ static void shader_vblend_link(void){ _uniform_vblend_uTexGarbage = glGetUniformLocation( _shader_vblend.id, "uTexGarbage" ); _uniform_vblend_uTexGradients = glGetUniformLocation( _shader_vblend.id, "uTexGradients" ); _uniform_vblend_uCamera = glGetUniformLocation( _shader_vblend.id, "uCamera" ); - _uniform_vblend_uPlane = glGetUniformLocation( _shader_vblend.id, "uPlane" ); _uniform_vblend_g_world_depth = glGetUniformLocation( _shader_vblend.id, "g_world_depth" ); } #endif /* SHADER_vblend_H */