X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fscene_override.h;h=c84a5baaa62b0ac9f7b79501a3be8ca2aed3283a;hb=217627b6b4eef904ac89b5f7f7f819b3a0970b20;hp=d0c7ab924ac175300f217f3ee3903898bd94f7c4;hpb=1a7f4a35e88698bdb45c90f646f1645589d5511c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/scene_override.h b/shaders/scene_override.h index d0c7ab9..c84a5ba 100644 --- a/shaders/scene_override.h +++ b/shaders/scene_override.h @@ -71,9 +71,15 @@ static struct vg_shader _shader_scene_override = { "uniform vec4 uPlayerPos; /* w: distance to uSpawnPos */\n" "uniform vec4 uSpawnPos; /* w: inverse distance to uPlayerPos */\n" "uniform bool uAlphatest;\n" +"uniform vec4 uMapInfo; /* x: min, y: max, z: iso line amount */\n" "\n" "#line 1 1 \n" "// :D\n" +"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" +"\n" +"#line 12 0 \n" +"#line 1 2 \n" +"// :D\n" "\n" "in vec2 aUv;\n" "in vec4 aNorm;\n" @@ -233,8 +239,9 @@ static struct vg_shader _shader_scene_override = { " g_sunset_phase );\n" "\n" " vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max(0.0,dot(normal,g_sun_dir.xyz)*0.75+0.25) \n" -" * g_sun_colour.rgb * g_day_phase;\n" +" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" +" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" +" ) * g_sun_colour.rgb * g_day_phase;\n" "\n" " float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" " vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" @@ -439,8 +446,8 @@ static struct vg_shader _shader_scene_override = { " return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" "}\n" "\n" -"#line 11 0 \n" -"#line 1 2 \n" +"#line 13 0 \n" +"#line 1 3 \n" "const float k_motion_lerp_amount = 0.01;\n" "\n" "#line 2 0 \n" @@ -459,7 +466,7 @@ static struct vg_shader _shader_scene_override = { " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" -"#line 12 0 \n" +"#line 14 0 \n" "\n" "vec2 smin( float a, float b, float k ){\n" " float h = max( k-abs(a-b), 0.0 )/k;\n" @@ -478,11 +485,15 @@ static struct vg_shader _shader_scene_override = { " float dither = fract( vDither.g / 71.0 ) - 0.5;\n" "\n" " float dcam = (-8.0+distance( aCo, uCamera ))/4.0;\n" -" if( min(aCo.y*0.5 + dither, dcam + dither) < 0.51 ) discard;\n" +" float dy0 = aCo.y - uMapInfo.x;\n" +" float dy1 = uMapInfo.y - aCo.y;\n" +"\n" +" if( min(min(dy0,dy1)*0.5, dcam) + dither < 0.51 ) \n" +" discard;\n" "\n" " compute_motion_vectors();\n" "\n" -" vec3 vfrag = vec3(0.7);\n" +" vec3 vfrag = vec3(0.898,0.811,0.716);\n" " vec3 qnorm = aNorm.xyz;\n" "\n" " qnorm = normalize(floor(aNorm.xyz*4.0)*0.25);\n" @@ -515,7 +526,15 @@ static struct vg_shader _shader_scene_override = { " float d3 = distance(p0,aCo);\n" " emit += vec3(fract(t*0.2-g_realtime+d3*0.2)*max(0.0,1.0-d3*0.2));\n" "\n" -" oColour = vec4( vfrag+emit, 1.0 );\n" +" vfrag += emit;\n" +"\n" +" if( uMapInfo.z > 0.0 ){\n" +" float height = fract( aCo.y * 0.1 );\n" +" float lg = 2.0*length(vec2(dFdx(height), dFdy(height)));\n" +" vfrag *= 1.0f+(lg*0.2*uMapInfo.z);\n" +" }\n" +"\n" +" oColour = vec4( vfrag, 1.0 );\n" " //oColour = vec4( vfrag, 1.0 );\n" "}\n" ""}, @@ -532,6 +551,7 @@ static GLuint _uniform_scene_override_uPlane; static GLuint _uniform_scene_override_uPlayerPos; static GLuint _uniform_scene_override_uSpawnPos; static GLuint _uniform_scene_override_uAlphatest; +static GLuint _uniform_scene_override_uMapInfo; static GLuint _uniform_scene_override_g_world_depth; static GLuint _uniform_scene_override_uLightsArray; static GLuint _uniform_scene_override_uLightsIndex; @@ -568,6 +588,9 @@ static void shader_scene_override_uSpawnPos(v4f v){ static void shader_scene_override_uAlphatest(int b){ glUniform1i(_uniform_scene_override_uAlphatest,b); } +static void shader_scene_override_uMapInfo(v4f v){ + glUniform4fv(_uniform_scene_override_uMapInfo,1,v); +} static void shader_scene_override_g_world_depth(int i){ glUniform1i(_uniform_scene_override_g_world_depth,i); } @@ -587,6 +610,7 @@ static void shader_scene_override_link(void){ _uniform_scene_override_uPlayerPos = glGetUniformLocation( _shader_scene_override.id, "uPlayerPos" ); _uniform_scene_override_uSpawnPos = glGetUniformLocation( _shader_scene_override.id, "uSpawnPos" ); _uniform_scene_override_uAlphatest = glGetUniformLocation( _shader_scene_override.id, "uAlphatest" ); + _uniform_scene_override_uMapInfo = glGetUniformLocation( _shader_scene_override.id, "uMapInfo" ); _uniform_scene_override_g_world_depth = glGetUniformLocation( _shader_scene_override.id, "g_world_depth" ); _uniform_scene_override_uLightsArray = glGetUniformLocation( _shader_scene_override.id, "uLightsArray" ); _uniform_scene_override_uLightsIndex = glGetUniformLocation( _shader_scene_override.id, "uLightsIndex" );