X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fscene_override.h;h=c84a5baaa62b0ac9f7b79501a3be8ca2aed3283a;hb=e311bbe2fa903a7e2a922f202f389b799193195d;hp=74caeffcdfa1430a73d30f7de8703839d6ad6456;hpb=6e96ba64e805ea8a39ca46171e28426c6bc86ab6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/scene_override.h b/shaders/scene_override.h index 74caeff..c84a5ba 100644 --- a/shaders/scene_override.h +++ b/shaders/scene_override.h @@ -71,10 +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 float uIsoAmt;\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" @@ -234,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" @@ -440,8 +446,8 @@ static struct vg_shader _shader_scene_override = { " return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" "}\n" "\n" -"#line 12 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" @@ -460,7 +466,7 @@ static struct vg_shader _shader_scene_override = { " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" -"#line 13 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" @@ -479,7 +485,11 @@ 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" @@ -518,13 +528,12 @@ static struct vg_shader _shader_scene_override = { "\n" " vfrag += emit;\n" "\n" -" if( uIsoAmt > 0.0 ){\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.4*uIsoAmt);\n" +" vfrag *= 1.0f+(lg*0.2*uMapInfo.z);\n" " }\n" "\n" -"\n" " oColour = vec4( vfrag, 1.0 );\n" " //oColour = vec4( vfrag, 1.0 );\n" "}\n" @@ -542,7 +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_uIsoAmt; +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; @@ -579,8 +588,8 @@ 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_uIsoAmt(float f){ - glUniform1f(_uniform_scene_override_uIsoAmt,f); +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); @@ -601,7 +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_uIsoAmt = glGetUniformLocation( _shader_scene_override.id, "uIsoAmt" ); + _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" );