From 5bfb36032928ba9f8d12e72961af68bfab9ea648 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 7 Aug 2023 18:54:34 +0100 Subject: [PATCH] unlock rendering --- blender_export.py | 4 ++- entity.h | 1 + maps_src/mp_spawn/main.mdl | Bin 13231304 -> 13231504 bytes shaders/model_font.fs | 4 +-- shaders/model_font.h | 4 +-- world_entity.c | 7 ++++- world_render.c | 57 +++++++++++++++++++++++++++---------- 7 files changed, 56 insertions(+), 21 deletions(-) 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 fcd2e0ac4af4797c8e40807158d3cb7caf410968..6c489f8bbf0592fffd58110788b0bc065d2c2dbd 100644 GIT binary patch delta 3114 zcmY+_30xCb9tZFwWL^@PQG_U$P*X)f0jVcPk{3`b9w46J1)`vG2#R1ql(FIgS`@@O zRPkIxMmUV5rzl6bM=kxh8@UD5s|Nm%eK1|BK zI85r}6}>}bGFeJyPGW9mM%IFK{DG(VUPY$DL!rK3u}R?(7JOeOQ=)V<*jnafCoNo< zy1>>@W_lo#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B{%K0WTN}-Y^cvgAe$^1n>hj_(K3Z3Xj1=m;@S_ z41o{?Qy>^ZU@A<5P|(732!n8lfX6`xzknGq6Z8-XQ7{XlVK&6T9GDBSFc0D&9umL+ zMi9XS63mBR!U9NyCm;!)gk*RMo`z>21yW%lq`@Ls49~(6NQdXZ3>ok%SPGf&JS>Cd zV1X>ih8)O+Jg`DO6u=57gq2VP#ZUq^D1}w98p@y?Dxeb9zzbl9weTWT!8&*eszHYJ zumLtg4Qzs1*bH^B1zv`FXnD{O=9&Q2YSH?F6e`P WI1V4e2{;L-;3GKA9Q6ZNm;MK^pezgk 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 ){ -- 2.25.1