From: hgn Date: Thu, 23 Nov 2023 07:56:44 +0000 (+0000) Subject: shader overrides X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=bdd98e4458be4a143cd415e5077b373129b1b0d9;hp=83592cbfd2ab1085598249a09ef257769cc92448;p=carveJwlIkooP6JGAAIwe30JlM.git shader overrides --- diff --git a/ent_miniworld.c b/ent_miniworld.c index af4d668..e425fa2 100644 --- a/ent_miniworld.c +++ b/ent_miniworld.c @@ -87,7 +87,7 @@ static void ent_miniworld_render( world_instance *host_world, camera *cam ){ return; render_world_override( dest_world, host_world, global_miniworld.mmdl, cam, - NULL, 0.0f ); + NULL, (v4f){-10000.0f,10000.0f,0.0f,0.0f} ); render_world_routes( dest_world, host_world, global_miniworld.mmdl, cam, 0, 1 ); diff --git a/maps_src/dev_hub/main.mdl b/maps_src/dev_hub/main.mdl index 4eecbca..49a245e 100644 Binary files a/maps_src/dev_hub/main.mdl and b/maps_src/dev_hub/main.mdl differ diff --git a/maps_src/mp_mtzero/main.mdl b/maps_src/mp_mtzero/main.mdl index fd22f64..40e488e 100644 Binary files a/maps_src/mp_mtzero/main.mdl and b/maps_src/mp_mtzero/main.mdl differ diff --git a/maps_src/mp_spawn/main.mdl b/maps_src/mp_spawn/main.mdl index e195aa6..c42dc1b 100644 Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ diff --git a/shaders/scene_override.fs b/shaders/scene_override.fs index 237fe6b..42e97b4 100644 --- a/shaders/scene_override.fs +++ b/shaders/scene_override.fs @@ -6,7 +6,7 @@ uniform vec4 uPlane; uniform vec4 uPlayerPos; /* w: distance to uSpawnPos */ uniform vec4 uSpawnPos; /* w: inverse distance to uPlayerPos */ uniform bool uAlphatest; -uniform float uIsoAmt; +uniform vec4 uMapInfo; /* x: min, y: max, z: iso line amount */ #include "common_scene.glsl" #include "motion_vectors_fs.glsl" @@ -28,7 +28,11 @@ void main(){ float dither = fract( vDither.g / 71.0 ) - 0.5; float dcam = (-8.0+distance( aCo, uCamera ))/4.0; - if( min(aCo.y*0.5 + dither, dcam + dither) < 0.51 ) discard; + float dy0 = aCo.y - uMapInfo.x; + float dy1 = uMapInfo.y - aCo.y; + + if( min(min(dy0,dy1)*0.5, dcam) + dither < 0.51 ) + discard; compute_motion_vectors(); @@ -67,10 +71,10 @@ void main(){ vfrag += emit; - if( uIsoAmt > 0.0 ){ + if( uMapInfo.z > 0.0 ){ float height = fract( aCo.y * 0.1 ); float lg = 2.0*length(vec2(dFdx(height), dFdy(height))); - vfrag *= 1.0f+(lg*0.2*uIsoAmt); + vfrag *= 1.0f+(lg*0.2*uMapInfo.z); } oColour = vec4( vfrag, 1.0 ); diff --git a/shaders/scene_override.h b/shaders/scene_override.h index 6ef67c9..602cda4 100644 --- a/shaders/scene_override.h +++ b/shaders/scene_override.h @@ -71,7 +71,7 @@ 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" @@ -518,10 +518,10 @@ 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.2*uIsoAmt);\n" +" vfrag *= 1.0f+(lg*0.2*uMapInfo.z);\n" " }\n" "\n" " oColour = vec4( vfrag, 1.0 );\n" @@ -541,7 +541,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; @@ -578,8 +578,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); @@ -600,7 +600,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" ); diff --git a/skaterift.c b/skaterift.c index c23d022..2bc0e4c 100644 --- a/skaterift.c +++ b/skaterift.c @@ -464,7 +464,8 @@ static void render_scene(void){ m4x3f identity; m4x3_identity( identity ); render_world_override( world, world, identity, &skaterift.cam, - respawn_chooser.spawn, 1.0f ); + respawn_chooser.spawn, + (v4f){world->tar_min, world->tar_max, 1.0f, 0.0f}); render_world_routes( world, world, identity, &skaterift.cam, 0, 1 ); return; } diff --git a/world.h b/world.h index 0a67abf..0235501 100644 --- a/world.h +++ b/world.h @@ -85,6 +85,7 @@ struct world_instance { water; f64 time; + f32 tar_min, tar_max; /* STD140 */ struct ub_world_lighting{ diff --git a/world_entity.c b/world_entity.c index 1466836..cbe7432 100644 --- a/world_entity.c +++ b/world_entity.c @@ -212,6 +212,19 @@ static void world_gen_entities_init( world_instance *world ){ world->entity_bh = bh_create( world->heap, &bh_system_entity_list, world, indexed_count, 2 ); + + world->tar_min = world->entity_bh->nodes[0].bbx[0][1]; + world->tar_max = world->entity_bh->nodes[0].bbx[1][1] + 20.0f; + + for( u32 i=0; ient_marker); i++ ){ + ent_marker *marker = mdl_arritm( &world->ent_marker, i ); + + if( MDL_CONST_PSTREQ( &world->meta, marker->pstr_alias, "tar_min" ) ) + world->tar_min = marker->transform.co[1]; + + if( MDL_CONST_PSTREQ( &world->meta, marker->pstr_alias, "tar_max" ) ) + world->tar_max = marker->transform.co[1]; + } } static diff --git a/world_render.c b/world_render.c index 3f87a12..04db5a0 100644 --- a/world_render.c +++ b/world_render.c @@ -985,7 +985,7 @@ static void render_world_override( world_instance *world, world_instance *lighting_source, m4x3f mmdl, camera *cam, - ent_spawn *dest_spawn, f32 iso_amt ){ + ent_spawn *dest_spawn, v4f map_info ){ struct world_pass pass = { .cam = cam, .fn_bind_textures = bindpoint_override, @@ -999,7 +999,7 @@ static void render_world_override( world_instance *world, shader_scene_override_uTexGarbage(0); shader_scene_override_uTexMain(1); shader_scene_override_uPv( pass.cam->mtx.pv ); - shader_scene_override_uIsoAmt( iso_amt ); + shader_scene_override_uMapInfo( map_info ); WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( lighting_source, scene_override ); bind_terrain_noise(); diff --git a/world_render.h b/world_render.h index 402ca60..f6d629d 100644 --- a/world_render.h +++ b/world_render.h @@ -84,7 +84,7 @@ static void render_world_override( world_instance *world, world_instance *lighting_source, m4x3f mmdl, camera *cam, - ent_spawn *dest_spawn, f32 iso_amt ); + ent_spawn *dest_spawn, v4f map_info ); #define WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( WORLD, SHADER ) \ world_link_lighting_ub( WORLD, _shader_##SHADER.id ); \