X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_render.c;h=2cf0e283e5736109f61f914a0bd5f4a8e6e1c7b4;hb=a7d144c7905105909cc4434e0ab43008bbb8f89f;hp=3f72657b1d8ed87c89bfce9504f88a0100d90774;hpb=825c3bce18272c0f81659e0eac469709d0462836;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_render.c b/player_render.c index 3f72657..2cf0e28 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 ); @@ -285,6 +287,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 +301,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(); @@ -321,13 +317,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,27 +414,16 @@ 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,