X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_render.c;h=92aecbe5635578f0f72706d5d49e1d1fb8ecae0b;hb=7122b79f53f4501751d884c0bf2e838ab501c4a3;hp=a37e74e2128b9e67d92664d793758f65193d96fa;hpb=b405845ac2cc8eb8e227eb5785f48f5dde9b0f26;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_render.c b/player_render.c index a37e74e..92aecbe 100644 --- a/player_render.c +++ b/player_render.c @@ -13,6 +13,7 @@ #include "shaders/model_board_view.h" #include "shaders/model_entity.h" #include "shaders/model_board_view.h" +#include "depth_compare.h" static void player_avatar_load( struct player_avatar *av, const char *path ){ mdl_open( &av->meta, path, vg_mem.rtmemory ); @@ -24,6 +25,7 @@ static void player_avatar_load( struct player_avatar *av, const char *path ){ skeleton_setup( sk, vg_mem.rtmemory, &av->meta ); av->id_hip = skeleton_bone_id( sk, "hips" ); + av->id_chest = skeleton_bone_id( sk, "chest" ); av->id_ik_hand_l = skeleton_bone_id( sk, "hand.IK.L" ); av->id_ik_hand_r = skeleton_bone_id( sk, "hand.IK.R" ); av->id_ik_elbow_l = skeleton_bone_id( sk, "elbow.L" ); @@ -169,17 +171,22 @@ static void player__animate(void){ assert( sys->animator_data ); sys->animate(); - sys->pose( sys->animator_data, &localplayer.pose ); + + player_pose *pose = &localplayer.pose; + sys->pose( sys->animator_data, pose ); struct skeleton *sk = &localplayer.playeravatar->sk; if( localplayer.holdout_time > 0.0f ){ - player_pose *pose = &localplayer.pose; skeleton_lerp_pose( sk, pose->keyframes,localplayer.holdout_pose.keyframes, localplayer.holdout_time, pose->keyframes ); + + v3_muladds( pose->root_co, localplayer.holdout_pose.root_co, + localplayer.holdout_time, pose->root_co ); q_nlerp( pose->root_q, localplayer.holdout_pose.root_q, localplayer.holdout_time, pose->root_q ); + localplayer.holdout_time -= vg.time_frame_delta * 2.0f; } @@ -300,25 +307,15 @@ static void render_board( camera *cam, world_instance *world, shader_model_board_view_uTexMain( 0 ); shader_model_board_view_uCamera( cam->transform[3] ); shader_model_board_view_uPv( cam->mtx.pv ); - shader_model_board_view_uTexSceneDepth( 1 ); - render_fb_bind_texture( gpipeline.fb_main, 2, 1 ); - - render_fb_inverse_ratio( gpipeline.fb_main, inverse ); - inverse[2] = skaterift.cam.farz-skaterift.cam.nearz; + shader_model_board_view_uDepthCompare(1); + depth_compare_bind( + shader_model_board_view_uTexSceneDepth, + shader_model_board_view_uInverseRatioDepth, + shader_model_board_view_uInverseRatioMain, + cam ); - shader_model_board_view_uInverseRatioDepth( inverse ); - render_fb_inverse_ratio( NULL, inverse ); - inverse[2] = cam->farz-cam->nearz; - shader_model_board_view_uInverseRatioMain( inverse ); - - world_link_lighting_ub( world, _shader_model_board_view.id ); - world_bind_position_texture( world, _shader_model_board_view.id, - _uniform_model_board_view_g_world_depth, 2 ); - world_bind_light_array( world, _shader_model_board_view.id, - _uniform_model_board_view_uLightsArray, 3 ); - world_bind_light_index( world, _shader_model_board_view.id, - _uniform_model_board_view_uLightsIndex, 4 ); + WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_board_view ); } else if( shader == k_board_shader_entity ){ shader_model_entity_use(); @@ -326,13 +323,7 @@ static void render_board( camera *cam, world_instance *world, shader_model_entity_uCamera( cam->transform[3] ); shader_model_entity_uPv( cam->mtx.pv ); - world_link_lighting_ub( world, _shader_model_entity.id ); - world_bind_position_texture( world, _shader_model_entity.id, - _uniform_model_entity_g_world_depth, 2 ); - world_bind_light_array( world, _shader_model_entity.id, - _uniform_model_entity_uLightsArray, 3 ); - world_bind_light_index( world, _shader_model_entity.id, - _uniform_model_entity_uLightsIndex, 4 ); + WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_entity ); } mesh_bind( &board->mdl.mesh ); @@ -429,32 +420,21 @@ static void render_playermodel( camera *cam, world_instance *world, shader_model_character_view_uCamera( cam->transform[3] ); shader_model_character_view_uPv( cam->mtx.pv ); + shader_model_character_view_uDepthCompare( depth_compare ); if( depth_compare ){ - shader_model_character_view_uTexSceneDepth( 1 ); - render_fb_bind_texture( gpipeline.fb_main, 2, 1 ); - v3f inverse; - render_fb_inverse_ratio( gpipeline.fb_main, inverse ); - inverse[2] = skaterift.cam.farz-skaterift.cam.nearz; - - shader_model_character_view_uInverseRatioDepth( inverse ); - render_fb_inverse_ratio( NULL, inverse ); - inverse[2] = cam->farz-cam->nearz; - shader_model_character_view_uInverseRatioMain( inverse ); + depth_compare_bind( + shader_model_character_view_uTexSceneDepth, + shader_model_character_view_uInverseRatioDepth, + shader_model_character_view_uInverseRatioMain, + cam ); } - shader_model_character_view_uDepthCompare( depth_compare ); - world_link_lighting_ub( world, _shader_model_character_view.id ); - world_bind_position_texture( world, _shader_model_character_view.id, - _uniform_model_character_view_g_world_depth, 2 ); - world_bind_light_array( world, _shader_model_character_view.id, - _uniform_model_character_view_uLightsArray, 3 ); - world_bind_light_index( world, _shader_model_character_view.id, - _uniform_model_character_view_uLightsIndex, 4 ); + WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_character_view ); glUniformMatrix4x3fv( _uniform_model_character_view_uTransforms, skeleton->bone_count, 0, - (f32 *)final_mtx ); + (const GLfloat *)final_mtx ); mesh_bind( &model->mdl.mesh ); mesh_draw( &model->mdl.mesh );