X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_render.c;h=92aecbe5635578f0f72706d5d49e1d1fb8ecae0b;hb=137d40d96fe923600d8378b8e138e3c276f27ff4;hp=3f72657b1d8ed87c89bfce9504f88a0100d90774;hpb=825c3bce18272c0f81659e0eac469709d0462836;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_render.c b/player_render.c index 3f72657..92aecbe 100644 --- a/player_render.c +++ b/player_render.c @@ -12,6 +12,8 @@ #include "shaders/model_character_view.h" #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 ); @@ -23,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" ); @@ -168,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; } @@ -285,6 +293,10 @@ static void render_board( camera *cam, world_instance *world, { if( !board ) return; + /* TODO: + * adding depth compare to this shader + */ + v3f inverse; glActiveTexture( GL_TEXTURE0 ); @@ -295,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 ); + 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 ); - inverse[2] = skaterift.cam.farz-skaterift.cam.nearz; - - 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(); @@ -321,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 ); @@ -424,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 );