From: hgn Date: Mon, 7 Aug 2023 17:54:34 +0000 (+0100) Subject: unlock rendering X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=5bfb36032928ba9f8d12e72961af68bfab9ea648;p=carveJwlIkooP6JGAAIwe30JlM.git unlock rendering --- diff --git a/blender_export.py b/blender_export.py index 70bb5ef..52f674f 100644 --- a/blender_export.py +++ b/blender_export.py @@ -476,7 +476,8 @@ class ent_challenge(Structure):#{ #} class ent_unlock(Structure):#{ - _fields_ = [("pstr_alias",c_uint32), + _fields_ = [("transform",mdl_transform), + ("pstr_alias",c_uint32), ("target",c_uint32), ("target_event",c_uint32), ("status",c_uint32)] @@ -1874,6 +1875,7 @@ def sr_compile( collection ): elif ent_type == 'ent_unlock':#{ unlock = ent_unlock() obj_data = obj.SR_data.ent_unlock[0] + compile_obj_transform( obj, unlock.transform ) unlock.pstr_alias = sr_compile_string( obj_data.alias ) unlock.target = sr_entity_id( obj_data.target ) unlock.target_event = obj_data.target_event diff --git a/entity.h b/entity.h index 9e0424f..8920eef 100644 --- a/entity.h +++ b/entity.h @@ -440,6 +440,7 @@ struct ent_challenge{ }; struct ent_unlock{ + mdl_transform transform; u32 pstr_alias, target, target_event, diff --git a/maps_src/mp_spawn/main.mdl b/maps_src/mp_spawn/main.mdl index fcd2e0a..6c489f8 100644 Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ diff --git a/shaders/model_font.fs b/shaders/model_font.fs index 31e4e8d..d2f1438 100644 --- a/shaders/model_font.fs +++ b/shaders/model_font.fs @@ -1,4 +1,4 @@ -out vec4 FragColor; +layout (location = 0) out vec4 oColour; uniform sampler2D uTexMain; uniform vec4 uColour; @@ -13,5 +13,5 @@ in vec3 aCo; void main() { compute_motion_vectors(); - FragColor = texture( uTexMain, aUv ) * uColour; + oColour = texture( uTexMain, aUv ) * uColour; } diff --git a/shaders/model_font.h b/shaders/model_font.h index 65d53e3..6c6027d 100644 --- a/shaders/model_font.h +++ b/shaders/model_font.h @@ -68,7 +68,7 @@ static struct vg_shader _shader_model_font = { { .orig_file = "shaders/model_font.fs", .static_src = -"out vec4 FragColor;\n" +"layout (location = 0) out vec4 oColour;\n" "\n" "uniform sampler2D uTexMain;\n" "uniform vec4 uColour;\n" @@ -102,7 +102,7 @@ static struct vg_shader _shader_model_font = { "void main()\n" "{\n" " compute_motion_vectors();\n" -" FragColor = texture( uTexMain, aUv ) * uColour;\n" +" oColour = texture( uTexMain, aUv ) * uColour;\n" "}\n" ""}, }; diff --git a/world_entity.c b/world_entity.c index b95961d..5ec52f7 100644 --- a/world_entity.c +++ b/world_entity.c @@ -97,7 +97,8 @@ VG_STATIC void world_gen_entities_init( world_instance *world ){ indexables[] = { { k_ent_gate, &world->ent_gate }, { k_ent_challenge, &world->ent_challenge }, - { k_ent_volume, &world->ent_volume } + { k_ent_volume, &world->ent_volume }, + { k_ent_unlock, &world->ent_unlock } }; for( u32 i=0; ient_volume, index ); return volume->transform.co[axis]; } + else if( type == k_ent_unlock ){ + ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index ); + return unlock->transform.co[axis]; + } else { vg_fatal_error( "Programming error\n" ); return INFINITY; diff --git a/world_render.c b/world_render.c index 0b5b399..ec2ec8a 100644 --- a/world_render.c +++ b/world_render.c @@ -7,6 +7,8 @@ #include "world.h" #include "world_render.h" +#include "font.h" +#include "gui.h" static int ccmd_set_time( int argc, const char *argv[] ){ if( argc == 1 ){ @@ -410,28 +412,43 @@ VG_STATIC void render_world_alphatest( world_instance *world, camera *cam ){ VG_STATIC void world_render_challenges( world_instance *world, struct world_pass *pass, - v3f pos ){ + v3f pos, int layer_depth ){ if( !world ) return; - glDisable( GL_CULL_FACE ); - mesh_bind( &world->mesh_no_collide ); - - u32 last_material = 0; - + /* sort lists */ const f32 radius = 40.0f; - bh_iter it; bh_iter_init_range( 0, &it, pos, radius ); i32 idx; + u32 challenge_list[ 32 ], + unlock_list[ 32 ]; + + u32 challenge_count = 0, + unlock_count = 0; + while( bh_next( world->entity_bh, &it, &idx ) ){ u32 id = world->entity_list[ idx ], type = mdl_entity_id_type( id ), index = mdl_entity_id_id( id ); - if( type != k_ent_challenge ) continue; + if( type == k_ent_challenge ) { + if( challenge_count < vg_list_size(challenge_list) ) + challenge_list[ challenge_count ++ ] = index; + } + else if( type == k_ent_unlock ){ + if( unlock_count < vg_list_size(unlock_list) ) + unlock_list[ unlock_count ++ ] = index; + } + } - ent_challenge *challenge = mdl_arritm(&world->ent_challenge,index); + /* render challenges */ + glDisable( GL_CULL_FACE ); + mesh_bind( &world->mesh_no_collide ); + u32 last_material = 0; + for( u32 i=0; ient_challenge, index ); if( challenge->flags & k_ent_challenge_hidden ) continue; f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius), @@ -456,11 +473,22 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, mdl_draw_submesh( sm ); } } -} -VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){ - //glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } ); + /* render texts */ + font3d_bind( &gui.font, &skaterift.cam ); + shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); + + for( u32 i=0; ient_unlock, index ); + m4x3f mmdl; + mdl_transform_m4x3( &unlock->transform, mmdl ); + font3d_simple_draw( &gui.font, 0, "Test!", &skaterift.cam, mmdl ); + } +} +VG_STATIC void render_world_fxglow( world_instance *world, camera *cam, + int layer_depth ){ shader_scene_fxglow_use(); shader_scene_fxglow_uTexMain(1); shader_scene_fxglow_uPv( cam->mtx.pv ); @@ -485,10 +513,9 @@ VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){ }; world_render_both_stages( world, &pass ); - world_render_challenges( world, &pass, cam->pos ); + world_render_challenges( world, &pass, cam->pos, layer_depth ); glEnable(GL_CULL_FACE); - //glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 } ); } VG_STATIC void bindpoint_terrain( world_instance *world, @@ -678,7 +705,7 @@ VG_STATIC void render_world( world_instance *world, camera *cam, render_world_vb( world, cam ); render_world_alphatest( world, cam ); - render_world_fxglow( world, cam ); + render_world_fxglow( world, cam, layer_depth ); render_terrain( world, cam ); if( layer_depth == 0 ){