From b405845ac2cc8eb8e227eb5785f48f5dde9b0f26 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 6 Oct 2023 07:04:02 +0100 Subject: [PATCH] nametag rendering --- ent_skateshop.c | 32 ++--- font.h | 205 +++++++++++++++++++------------- gui.h | 41 ++----- menu.h | 7 +- models_src/rs_icons.mdl | Bin 26688 -> 28256 bytes player_remote.c | 47 +++++++- player_render.c | 5 + shaders/depth_compare.glsl | 28 +++++ shaders/model_board_view.h | 70 ++++++----- shaders/model_character_view.fs | 32 +---- shaders/model_character_view.h | 70 ++++++----- shaders/model_font.fs | 5 +- shaders/model_font.h | 55 ++++++++- skaterift.c | 1 + world_render.c | 40 +------ world_render.h | 1 + world_routes.c | 13 +- 17 files changed, 373 insertions(+), 279 deletions(-) create mode 100644 shaders/depth_compare.glsl diff --git a/ent_skateshop.c b/ent_skateshop.c index f471f42..87e7509 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -469,7 +469,7 @@ fade_out:; float scale = 0.2f, thickness = 0.03f; - font3d_bind( &gui.font, &skaterift.cam ); + font3d_bind( &gui.font, k_font_shader_default, 0, world, &skaterift.cam ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); /* Selection counter @@ -490,12 +490,10 @@ fade_out:; i+=highscore_intl( buf+i, addon_count(k_addon_type_board), 3 ); buf[i++] = '\0'; - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - buf, &skaterift.cam, mmdl ); + font3d_simple_draw( 0, buf, &skaterift.cam, mmdl ); } else{ - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - "Nothing installed", &skaterift.cam, mmdl ); + font3d_simple_draw( 0, "Nothing installed", &skaterift.cam, mmdl ); } u16 cache_id = skateshop_selected_cache_id(); @@ -535,28 +533,24 @@ fade_out:; * ----------------------------------------------------------------- */ m3x3_zero( mlocal ); m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &gui.font, 0, - global_skateshop.render.item_title ); + mlocal[3][0] = -font3d_string_width( 0, global_skateshop.render.item_title ); mlocal[3][0] *= scale*0.5f; mlocal[3][1] = 0.1f; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - global_skateshop.render.item_title, + font3d_simple_draw( 0, global_skateshop.render.item_title, &skaterift.cam, mmdl ); /* Author name * ----------------------------------------------------------------- */ scale *= 0.4f; m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &gui.font, 0, - global_skateshop.render.item_desc ); + mlocal[3][0] = -font3d_string_width( 0, global_skateshop.render.item_desc ); mlocal[3][0] *= scale*0.5f; mlocal[3][1] = 0.0f; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - global_skateshop.render.item_desc, + font3d_simple_draw( 0, global_skateshop.render.item_desc, &skaterift.cam, mmdl ); SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); @@ -631,27 +625,25 @@ static void skateshop_render_worldshop( ent_skateshop *shop ){ m4x3f mtext,mlocal,mtextmdl; mdl_transform_m4x3( &mark_info->transform, mtext ); - font3d_bind( &gui.font, &skaterift.cam ); + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, &skaterift.cam ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); float scale = 0.2f, thickness = 0.015f, scale1 = 0.08f; m3x3_zero( mlocal ); m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &gui.font, 0, buftext ); + mlocal[3][0] = -font3d_string_width( 0, buftext ); mlocal[3][0] *= scale*0.5f; mlocal[3][1] = 0.1f; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mtextmdl ); - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - buftext, &skaterift.cam, mtextmdl ); + font3d_simple_draw( 0, buftext, &skaterift.cam, mtextmdl ); m3x3_setdiagonalv3( mlocal, (v3f){ scale1, scale1, thickness } ); - mlocal[3][0] = -font3d_string_width( &gui.font, 0, bufsubtext ); + mlocal[3][0] = -font3d_string_width( 0, bufsubtext ); mlocal[3][0] *= scale1*0.5f; mlocal[3][1] = -scale1*0.3f; m4x3_mul( mtext, mlocal, mtextmdl ); - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - bufsubtext, &skaterift.cam, mtextmdl ); + font3d_simple_draw( 0, bufsubtext, &skaterift.cam, mtextmdl ); /* pointcloud */ m4x3f mmdl; diff --git a/font.h b/font.h index b979732..c49bc66 100644 --- a/font.h +++ b/font.h @@ -6,6 +6,7 @@ #include "camera.h" #include "shaders/model_font.h" #include "shaders/scene_font.h" +#include "world_render.h" enum efont_SRglyph{ k_SRglyph_end = 0x00, /* control characters */ @@ -69,8 +70,7 @@ struct font3d{ glyphs; }; -static void font3d_load( font3d *font, const char *mdl_path, void *alloc ) -{ +static void font3d_load( font3d *font, const char *mdl_path, void *alloc ){ mdl_open( &font->mdl, mdl_path, alloc ); mdl_load_metadata_block( &font->mdl, alloc ); @@ -99,14 +99,12 @@ static void font3d_load( font3d *font, const char *mdl_path, void *alloc ) mdl_close( &font->mdl ); } -static void font3d_init(void) -{ +static void font3d_init(void){ shader_model_font_register(); shader_scene_font_register(); } -static u32 font3d_find_variant( font3d *font, const char *name ) -{ +static u32 font3d_find_variant( font3d *font, const char *name ){ for( u32 i=0; ifont_variants ); i ++ ){ ent_font_variant *variant = mdl_arritm( &font->font_variants, i ); @@ -118,20 +116,77 @@ static u32 font3d_find_variant( font3d *font, const char *name ) return 0; } -static void font3d_bind( font3d *font, camera *cam ) -{ - shader_model_font_use(); - shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); - shader_model_font_uTexMain( 1 ); - glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, font->texture ); +struct _font3d_render{ + v4f offset; + font3d *font; + u32 variant_id; - shader_model_font_uPv( cam->mtx.pv ); + enum font_shader { + k_font_shader_default, + k_font_shader_world + } + shader; +} +static gui_font3d; + +/* + * world can be null if not using world shader + */ +static void font3d_bind( font3d *font, enum font_shader shader, + int depth_compare, world_instance *world, + camera *cam ){ + gui_font3d.shader = shader; + gui_font3d.font = font; + glActiveTexture( GL_TEXTURE1 ); + glBindTexture( GL_TEXTURE_2D, font->texture ); + + if( shader == k_font_shader_default ){ + shader_model_font_use(); + shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); + shader_model_font_uTexMain( 1 ); + + shader_model_font_uDepthCompare( depth_compare ); + if( depth_compare ){ + /* TODO: Compress with code in player_render.c */ + shader_model_font_uTexSceneDepth( 2 ); + render_fb_bind_texture( gpipeline.fb_main, 2, 2 ); + v3f inverse; + render_fb_inverse_ratio( gpipeline.fb_main, inverse ); + inverse[2] = skaterift.cam.farz-skaterift.cam.nearz; + + shader_model_font_uInverseRatioDepth( inverse ); + render_fb_inverse_ratio( NULL, inverse ); + inverse[2] = cam->farz-cam->nearz; + shader_model_font_uInverseRatioMain( inverse ); + } + + shader_model_font_uPv( cam->mtx.pv ); + } + else if( shader == k_font_shader_world ){ + assert( world ); + shader_scene_font_use(); + shader_scene_font_uTexGarbage(0); + shader_scene_font_uTexMain(1); + + shader_scene_font_uPv( skaterift.cam.mtx.pv ); + shader_scene_font_uTime( vg.time ); + + /* TODO: Code dupe... */ + world_link_lighting_ub( world, _shader_scene_font.id ); + world_bind_position_texture( world, _shader_scene_font.id, + _uniform_scene_font_g_world_depth, 2 ); + world_bind_light_array( world, _shader_scene_font.id, + _uniform_scene_font_uLightsArray, 3 ); + world_bind_light_index( world, _shader_scene_font.id, + _uniform_scene_font_uLightsIndex, 4 ); + + bind_terrain_noise(); + shader_scene_font_uCamera( skaterift.cam.transform[3] ); + } mesh_bind( &font->mesh ); } -static ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ) -{ +static ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ){ if( utf32 < font->info.glyph_utf32_base ) return NULL; if( utf32 >= font->info.glyph_utf32_base+font->info.glyph_count) return NULL; @@ -141,94 +196,88 @@ static ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ) return mdl_arritm( &font->glyphs, index ); } -struct font3d_render{ - v4f offset; - font3d *font; - const u8 *u8pch; - u32 variant_id; - - enum font_shader { - k_font_shader_default, - k_font_shader_world - } - shader; -}; - -static -void font3d_begin( const char *text, - camera *cam, m4x3f transform, struct font3d_render *render ) -{ - v4_copy( (v4f){0.0f,0.0f,0.0f,1.0f}, render->offset ); +static void font3d_set_transform( const char *text, + camera *cam, m4x3f transform ){ + v4_copy( (v4f){0.0f,0.0f,0.0f,1.0f}, gui_font3d.offset ); m4x4f prev_mtx; m4x3_expand( transform, prev_mtx ); m4x4_mul( cam->mtx_prev.pv, prev_mtx, prev_mtx ); - if( render->shader == k_font_shader_default ){ + if( gui_font3d.shader == k_font_shader_default ){ shader_model_font_uPvmPrev( prev_mtx ); shader_model_font_uMdl( transform ); } - else if( render->shader == k_font_shader_world ){ + else if( gui_font3d.shader == k_font_shader_world ){ shader_scene_font_uPvmPrev( prev_mtx ); shader_scene_font_uMdl( transform ); } - - render->u8pch = (u8*)text; } -static void font3d_setoffset( struct font3d_render *render, v4f offset ){ - if( render->shader == k_font_shader_default ) +static void font3d_setoffset( v4f offset ){ + if( gui_font3d.shader == k_font_shader_default ) shader_model_font_uOffset( offset ); - else if( render->shader == k_font_shader_world ) + else if( gui_font3d.shader == k_font_shader_world ) shader_scene_font_uOffset( offset ); } -static void font3d_draw( struct font3d_render *render ) -{ +static void font3d_setcolour( v4f colour ){ + if( gui_font3d.shader == k_font_shader_default ) + shader_model_font_uColour( colour ); +#if 0 + else if( gui_font3d.shader == k_font_shader_world ) + shader_scene_font_uColour( colour ); +#endif +} + +static void font3d_draw( const char *text ){ + u8 *u8pch = (u8*)text; + u32 max_chars = 512; - while( render->u8pch && max_chars ){ + while( u8pch && max_chars ){ max_chars --; - u32 c0 = *render->u8pch, c1; - render->u8pch ++; + u32 c0 = *u8pch, c1; + u8pch ++; if( !c0 ) break; - ent_glyph *glyph0 = font3d_glyph( render->font, render->variant_id, c0 ), + ent_glyph *glyph0 = font3d_glyph( gui_font3d.font, + gui_font3d.variant_id, c0 ), *glyph1 = NULL; /* multibyte characters */ if( c0 >= 1 && c0 < k_SRglyph_ascii_min ){ - c1 = *render->u8pch; + c1 = *u8pch; if( !c1 ) break; - glyph1 = font3d_glyph( render->font, render->variant_id, c1 ); + glyph1 = font3d_glyph( gui_font3d.font, gui_font3d.variant_id, c1 ); } if( c0 == k_SRglyph_ctrl_variant ){ - render->variant_id = c1; - render->u8pch ++; + gui_font3d.variant_id = c1; + u8pch ++; continue; } else if( c0 == k_SRglyph_ctrl_size ){ - render->offset[3] = (float)c1 * (1.0f/255.0f); - render->u8pch ++; + gui_font3d.offset[3] = (float)c1 * (1.0f/255.0f); + u8pch ++; continue; } else if( c0 == k_SRglyph_ctrl_baseline ){ - render->offset[1] = 0.0f; + gui_font3d.offset[1] = 0.0f; continue; } else if( c0 == k_SRglyph_ctrl_center ){ if( glyph1 ){ - float diff = glyph1->size[1] - glyph1->size[1]*render->offset[3]; - render->offset[1] = diff * 0.5f; + float diff = glyph1->size[1] - glyph1->size[1]*gui_font3d.offset[3]; + gui_font3d.offset[1] = diff * 0.5f; } continue; } else if( c0 == k_SRglyph_ctrl_top ){ if( glyph1 ){ - float diff = glyph1->size[1] - glyph1->size[1]*render->offset[3]; - render->offset[1] = diff; + float diff = glyph1->size[1] - glyph1->size[1]*gui_font3d.offset[3]; + gui_font3d.offset[1] = diff; } continue; } @@ -238,46 +287,34 @@ static void font3d_draw( struct font3d_render *render ) if( glyph1 && (c0 == k_SRglyph_mod_square || c0 == k_SRglyph_mod_circle)){ v4f v0; v2_sub( glyph0->size, glyph1->size, v0 ); - v2_muladds( render->offset, v0, -0.5f, v0 ); - v0[2] = render->offset[2]; - v0[3] = render->offset[3]; + v2_muladds( gui_font3d.offset, v0, -0.5f, v0 ); + v0[2] = gui_font3d.offset[2]; + v0[3] = gui_font3d.offset[3]; - font3d_setoffset( render, v0 ); + font3d_setoffset( v0 ); mesh_drawn( glyph0->indice_start, glyph0->indice_count ); continue; } else{ - font3d_setoffset( render, render->offset ); + font3d_setoffset( gui_font3d.offset ); mesh_drawn( glyph0->indice_start, glyph0->indice_count ); } - render->offset[0] += glyph0->size[0]*render->offset[3]; + gui_font3d.offset[0] += glyph0->size[0]*gui_font3d.offset[3]; } - - render->u8pch = NULL; } -static -float font3d_simple_draw( font3d *font, u32 variant_id, enum font_shader shader, - const char *text, - camera *cam, m4x3f transform ) -{ +static f32 font3d_simple_draw( u32 variant_id, const char *text, + camera *cam, m4x3f transform ){ if( !text ) return 0.0f; - struct font3d_render render = { - .font = font, - .variant_id = variant_id, - .shader = shader, - }; - - font3d_begin( text, cam, transform, &render ); - font3d_draw( &render ); - return render.offset[0]; + gui_font3d.variant_id = variant_id; + font3d_set_transform( text, cam, transform ); + font3d_draw( text ); + return gui_font3d.offset[0]; } -static -float font3d_string_width( font3d *font, u32 variant_id, const char *text ) -{ +static f32 font3d_string_width( u32 variant_id, const char *text ){ if( !text ) return 0.0f; float width = 0.0f; @@ -286,7 +323,7 @@ float font3d_string_width( font3d *font, u32 variant_id, const char *text ) u32 c = buf[i]; if(!c) break; - ent_glyph *glyph = font3d_glyph( font, variant_id, c ); + ent_glyph *glyph = font3d_glyph( gui_font3d.font, variant_id, c ); if( !glyph ) continue; width += glyph->size[0]; diff --git a/gui.h b/gui.h index 18b3dbd..5cfe468 100644 --- a/gui.h +++ b/gui.h @@ -113,16 +113,14 @@ void gui_draw(void) camera_finalize( &ortho ); - - - /* icons */ - font3d_bind( &gui.font, &ortho ); + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, &ortho ); + mesh_bind( &gui.icons_mesh ); + m4x3f mmdl; m4x3_identity( mmdl ); shader_model_font_uMdl( mmdl ); - mesh_bind( &gui.icons_mesh ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, gui.icons_texture ); @@ -141,8 +139,6 @@ void gui_draw(void) - - gui.factive = vg_lerpf( gui.factive, gui.helper_count?1.0f:0.0f, vg.time_frame_delta*2.0f ); @@ -181,18 +177,17 @@ void gui_draw(void) v3_zero( mmdl[3] ); f32 pad = dy*0x1p-4f*0.125f; - f32 w = font3d_string_width( &gui.font,2,gui.location ); + f32 w = font3d_string_width( 2, gui.location ); mmdl[3][0] = fr*0.5f - w*scale*0.5f; mmdl[3][1] = 0.3f*ft+pad*2.0f; - font3d_bind( &gui.font, &ortho ); + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, &ortho ); shader_model_font_uColour( (v4f){1.2f,1.2f,1.2f,o} ); - font3d_simple_draw( &gui.font, 2, k_font_shader_default, - gui.location, &ortho, mmdl ); + font3d_simple_draw( 2, gui.location, &ortho, mmdl ); } - - font3d_bind( &gui.font, &ortho ); + else + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, &ortho ); float dy = ft/0.79f, scale = dy*0x1p-4f*0.75f; @@ -208,24 +203,14 @@ void gui_draw(void) for( u32 i=0; ibindstr, &ortho, mmdl, &render ); - font3d_draw( &render ); + font3d_setcolour( (v4f){1.0f,1.0f,1.0f,1.0f} ); + font3d_simple_draw( 2, helper->bindstr, &ortho, mmdl ); const char *make_smaller = "\x02\xaf\x03 "; - render.u8pch = (const u8*)make_smaller; - font3d_draw( &render ); - - render.u8pch = (u8*)helper->text; - font3d_draw( &render ); + font3d_draw( make_smaller ); + font3d_draw( helper->text ); - float w = render.offset[0]+1.0f; + float w = gui_font3d.offset[0]+1.0f; mmdl[3][0] += w*scale; } diff --git a/menu.h b/menu.h index 243bebf..0985706 100644 --- a/menu.h +++ b/menu.h @@ -761,7 +761,7 @@ static void menu_render(void){ m4x3f local; m4x3_identity( local ); - font3d_bind( &gui.font, &menu.view ); + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, &menu.view ); for( u32 i=0; ibinding.font_variant; menu_binding_string( buf, item->binding.pstr_bind ); - f32 offset = font3d_string_width( &gui.font, variant, buf ); + f32 offset = font3d_string_width( variant, buf ); local[3][0] = -0.5f * offset; m4x3_mul( transform, local, transform ); - font3d_simple_draw( &gui.font, variant, k_font_shader_default, buf, - &menu.view, transform ); + font3d_simple_draw( variant, buf, &menu.view, transform ); } } diff --git a/models_src/rs_icons.mdl b/models_src/rs_icons.mdl index 92858f23063c6d0e33122cd1f91426bca04e4d81..84f31291d6d77059e237be94365b131714179067 100644 GIT binary patch delta 1776 zcmX?bf$_l|#tAC2H4F?4j6hsmQk0pOUJPVGfB+K%1KUJLan=fE5F=Jxwt)qr(gvs? zHzg-NH?btOC^In!r2fFfiPDT0Cawh$C#9_}K$YqMrBd@s;*%3|Q;QNo3W0zXLJ0sV zkTHpQnLv{=^Yg%RljRttSV2lwPqt+gmlFtOV9*B|21H=RnRzLh$*B+nE~HK_V(b!F zy5{EY%;fyM__U(T)Vvgi&3_mT7`a`0mFyh~7T7smOPRc%Nmc}8Dae~(*Fy9&Og3P? zqw@jiJ$szZ}FtcA_wc2gse=FI{u54`I^D$=#L z?*^#=ndEWhq5A*-_4WaITWmy2tL^^-0Z1GMkWB=MA*=t8TZy3_WGl=C$m$Oqm9hn@ zug9tZn}a|ausJCC!)fb?*cJ>A)%VltWmy=8`gK!TY`4ausR!E6U@|#or?3Me=t&FH#Q5(&ONZfumGsOZ&BxNY#xYue$J*In-3mj?Anb8B18!3Z8~6s zErh1-ytx}&6#SU9-3D6}n6$ z=>_S7sRyZr*#(rZ2TSk*1^IxOABsU`zaSI~0cl|<76HqJL!Rs&`bBUW5ifCZw`2B;u6 zB_}>Nu_U!9GZAC}L%_s|(u@fc*Mf+X(pCvjr8+>V)Vz}T#4 zVvsS3d6__yGV}9*{0S_Rplayermodel_view_slot ); @@ -341,6 +343,7 @@ static void remote_player_debug_update(void){ } static void remote_player_nametag( m4x4f pv, v3f co, const char *name ){ + return; vg_ui.font = &vg_ui_font_big; v4f wpos; v3_copy( co, wpos ); @@ -579,7 +582,6 @@ static void animate_remote_players(void){ * Draw remote players */ static void render_remote_players( world_instance *world, camera *cam ){ - SDL_AtomicLock( &addon_system.sl_cache_using_resources ); for( u32 i=0; iactive ) continue; + if( player->active_world != world ) continue; + + struct player_avatar *av = localplayer.playeravatar; + render_remote_player_nametag( + netplayers.final_mtx[av->sk.bone_count*i][3], + player->username ); + } + + glDisable(GL_BLEND); +} + static void remote_players_init(void){ for( u32 i=0; imeta, path, vg_mem.rtmemory ); @@ -285,6 +286,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 ); diff --git a/shaders/depth_compare.glsl b/shaders/depth_compare.glsl new file mode 100644 index 0000000..5e02144 --- /dev/null +++ b/shaders/depth_compare.glsl @@ -0,0 +1,28 @@ +uniform sampler2D uTexSceneDepth; +uniform vec3 uInverseRatioDepth; +uniform vec3 uInverseRatioMain; +uniform bool uDepthCompare; + +float linear_depth( float depth, float near, float far ) { + float z = depth * 2.0 - 1.0; + return (2.0 * near * far) / (far + near - z * (far - near)); +} + +void depth_compare_dither(){ + if( uDepthCompare ){ + vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy + * uInverseRatioDepth.xy; + float back_depth = texture( uTexSceneDepth, back_coord ).r; + float front_depth = gl_FragCoord.z/gl_FragCoord.w; + + back_depth = linear_depth( back_depth, 0.1, 2100.0 ); + float diff = back_depth - front_depth; + + vec2 ssuv = gl_FragCoord.xy; + vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) ); + float dither = fract( vDither.g / 71.0 ) - 0.5; + + if( step(0.0,diff)+dither<0.3 ) + discard; + } +} diff --git a/shaders/model_board_view.h b/shaders/model_board_view.h index d1e7f65..3a1ba9c 100644 --- a/shaders/model_board_view.h +++ b/shaders/model_board_view.h @@ -67,11 +67,7 @@ static struct vg_shader _shader_model_board_view = { .orig_file = "shaders/model_character_view.fs", .static_src = "uniform sampler2D uTexMain;\n" -"uniform sampler2D uTexSceneDepth;\n" "uniform vec3 uCamera;\n" -"uniform vec3 uInverseRatioDepth;\n" -"uniform vec3 uInverseRatioMain;\n" -"uniform bool uDepthCompare;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" @@ -381,7 +377,7 @@ static struct vg_shader _shader_model_board_view = { " return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" "}\n" "\n" -"#line 15 0 \n" +"#line 11 0 \n" "#line 1 2 \n" "const float k_motion_lerp_amount = 0.01;\n" "\n" @@ -401,25 +397,19 @@ static struct vg_shader _shader_model_board_view = { " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" -"#line 16 0 \n" +"#line 12 0 \n" +"#line 1 3 \n" +"uniform sampler2D uTexSceneDepth;\n" +"uniform vec3 uInverseRatioDepth;\n" +"uniform vec3 uInverseRatioMain;\n" +"uniform bool uDepthCompare;\n" "\n" -"float linear_depth( float depth, float near, float far ) \n" -"{\n" +"float linear_depth( float depth, float near, float far ) {\n" " float z = depth * 2.0 - 1.0;\n" " return (2.0 * near * far) / (far + near - z * (far - near)); \n" "}\n" "\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 qnorm = aNorm;\n" -" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n" -" vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n" -"\n" -" float dist = distance( aWorldCo, uCamera ) - 0.08;\n" -" float opacity = clamp( dist*dist, 0.0, 1.0 );\n" -"\n" +"void depth_compare_dither(){\n" " if( uDepthCompare ){\n" " vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" " * uInverseRatioDepth.xy;\n" @@ -436,6 +426,20 @@ static struct vg_shader _shader_model_board_view = { " if( step(0.0,diff)+dither<0.3 )\n" " discard;\n" " }\n" +"}\n" +"\n" +"#line 13 0 \n" +"\n" +"void main(){\n" +" depth_compare_dither();\n" +" compute_motion_vectors();\n" +"\n" +" vec3 qnorm = aNorm;\n" +" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n" +" vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n" +"\n" +" float dist = distance( aWorldCo, uCamera ) - 0.08;\n" +" float opacity = clamp( dist*dist, 0.0, 1.0 );\n" "\n" " oColour = vec4( composite, opacity );\n" "}\n" @@ -446,14 +450,14 @@ static GLuint _uniform_model_board_view_uMdl; static GLuint _uniform_model_board_view_uPv; static GLuint _uniform_model_board_view_uPvmPrev; static GLuint _uniform_model_board_view_uTexMain; -static GLuint _uniform_model_board_view_uTexSceneDepth; static GLuint _uniform_model_board_view_uCamera; -static GLuint _uniform_model_board_view_uInverseRatioDepth; -static GLuint _uniform_model_board_view_uInverseRatioMain; -static GLuint _uniform_model_board_view_uDepthCompare; static GLuint _uniform_model_board_view_g_world_depth; static GLuint _uniform_model_board_view_uLightsArray; static GLuint _uniform_model_board_view_uLightsIndex; +static GLuint _uniform_model_board_view_uTexSceneDepth; +static GLuint _uniform_model_board_view_uInverseRatioDepth; +static GLuint _uniform_model_board_view_uInverseRatioMain; +static GLuint _uniform_model_board_view_uDepthCompare; static void shader_model_board_view_uMdl(m4x3f m){ glUniformMatrix4x3fv(_uniform_model_board_view_uMdl,1,GL_FALSE,(float*)m); } @@ -466,12 +470,15 @@ static void shader_model_board_view_uPvmPrev(m4x4f m){ static void shader_model_board_view_uTexMain(int i){ glUniform1i(_uniform_model_board_view_uTexMain,i); } -static void shader_model_board_view_uTexSceneDepth(int i){ - glUniform1i(_uniform_model_board_view_uTexSceneDepth,i); -} static void shader_model_board_view_uCamera(v3f v){ glUniform3fv(_uniform_model_board_view_uCamera,1,v); } +static void shader_model_board_view_g_world_depth(int i){ + glUniform1i(_uniform_model_board_view_g_world_depth,i); +} +static void shader_model_board_view_uTexSceneDepth(int i){ + glUniform1i(_uniform_model_board_view_uTexSceneDepth,i); +} static void shader_model_board_view_uInverseRatioDepth(v3f v){ glUniform3fv(_uniform_model_board_view_uInverseRatioDepth,1,v); } @@ -481,9 +488,6 @@ static void shader_model_board_view_uInverseRatioMain(v3f v){ static void shader_model_board_view_uDepthCompare(int b){ glUniform1i(_uniform_model_board_view_uDepthCompare,b); } -static void shader_model_board_view_g_world_depth(int i){ - glUniform1i(_uniform_model_board_view_g_world_depth,i); -} static void shader_model_board_view_register(void){ vg_shader_register( &_shader_model_board_view ); } @@ -493,13 +497,13 @@ static void shader_model_board_view_link(void){ _uniform_model_board_view_uPv = glGetUniformLocation( _shader_model_board_view.id, "uPv" ); _uniform_model_board_view_uPvmPrev = glGetUniformLocation( _shader_model_board_view.id, "uPvmPrev" ); _uniform_model_board_view_uTexMain = glGetUniformLocation( _shader_model_board_view.id, "uTexMain" ); - _uniform_model_board_view_uTexSceneDepth = glGetUniformLocation( _shader_model_board_view.id, "uTexSceneDepth" ); _uniform_model_board_view_uCamera = glGetUniformLocation( _shader_model_board_view.id, "uCamera" ); - _uniform_model_board_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioDepth" ); - _uniform_model_board_view_uInverseRatioMain = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioMain" ); - _uniform_model_board_view_uDepthCompare = glGetUniformLocation( _shader_model_board_view.id, "uDepthCompare" ); _uniform_model_board_view_g_world_depth = glGetUniformLocation( _shader_model_board_view.id, "g_world_depth" ); _uniform_model_board_view_uLightsArray = glGetUniformLocation( _shader_model_board_view.id, "uLightsArray" ); _uniform_model_board_view_uLightsIndex = glGetUniformLocation( _shader_model_board_view.id, "uLightsIndex" ); + _uniform_model_board_view_uTexSceneDepth = glGetUniformLocation( _shader_model_board_view.id, "uTexSceneDepth" ); + _uniform_model_board_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioDepth" ); + _uniform_model_board_view_uInverseRatioMain = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioMain" ); + _uniform_model_board_view_uDepthCompare = glGetUniformLocation( _shader_model_board_view.id, "uDepthCompare" ); } #endif /* SHADER_model_board_view_H */ diff --git a/shaders/model_character_view.fs b/shaders/model_character_view.fs index efee606..6330f9b 100644 --- a/shaders/model_character_view.fs +++ b/shaders/model_character_view.fs @@ -1,9 +1,5 @@ uniform sampler2D uTexMain; -uniform sampler2D uTexSceneDepth; uniform vec3 uCamera; -uniform vec3 uInverseRatioDepth; -uniform vec3 uInverseRatioMain; -uniform bool uDepthCompare; in vec4 aColour; in vec2 aUv; @@ -13,15 +9,10 @@ in vec3 aWorldCo; #include "common_world.glsl" #include "motion_vectors_fs.glsl" +#include "depth_compare.glsl" -float linear_depth( float depth, float near, float far ) -{ - float z = depth * 2.0 - 1.0; - return (2.0 * near * far) / (far + near - z * (far - near)); -} - -void main() -{ +void main(){ + depth_compare_dither(); compute_motion_vectors(); vec3 qnorm = aNorm; @@ -31,22 +22,5 @@ void main() float dist = distance( aWorldCo, uCamera ) - 0.08; float opacity = clamp( dist*dist, 0.0, 1.0 ); - if( uDepthCompare ){ - vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy - * uInverseRatioDepth.xy; - float back_depth = texture( uTexSceneDepth, back_coord ).r; - float front_depth = gl_FragCoord.z/gl_FragCoord.w; - - back_depth = linear_depth( back_depth, 0.1, 2100.0 ); - float diff = back_depth - front_depth; - - vec2 ssuv = gl_FragCoord.xy; - vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) ); - float dither = fract( vDither.g / 71.0 ) - 0.5; - - if( step(0.0,diff)+dither<0.3 ) - discard; - } - oColour = vec4( composite, opacity ); } diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h index bae5d38..060e5b2 100644 --- a/shaders/model_character_view.h +++ b/shaders/model_character_view.h @@ -75,11 +75,7 @@ static struct vg_shader _shader_model_character_view = { .orig_file = "shaders/model_character_view.fs", .static_src = "uniform sampler2D uTexMain;\n" -"uniform sampler2D uTexSceneDepth;\n" "uniform vec3 uCamera;\n" -"uniform vec3 uInverseRatioDepth;\n" -"uniform vec3 uInverseRatioMain;\n" -"uniform bool uDepthCompare;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" @@ -389,7 +385,7 @@ static struct vg_shader _shader_model_character_view = { " return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" "}\n" "\n" -"#line 15 0 \n" +"#line 11 0 \n" "#line 1 2 \n" "const float k_motion_lerp_amount = 0.01;\n" "\n" @@ -409,25 +405,19 @@ static struct vg_shader _shader_model_character_view = { " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" -"#line 16 0 \n" +"#line 12 0 \n" +"#line 1 3 \n" +"uniform sampler2D uTexSceneDepth;\n" +"uniform vec3 uInverseRatioDepth;\n" +"uniform vec3 uInverseRatioMain;\n" +"uniform bool uDepthCompare;\n" "\n" -"float linear_depth( float depth, float near, float far ) \n" -"{\n" +"float linear_depth( float depth, float near, float far ) {\n" " float z = depth * 2.0 - 1.0;\n" " return (2.0 * near * far) / (far + near - z * (far - near)); \n" "}\n" "\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 qnorm = aNorm;\n" -" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n" -" vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n" -"\n" -" float dist = distance( aWorldCo, uCamera ) - 0.08;\n" -" float opacity = clamp( dist*dist, 0.0, 1.0 );\n" -"\n" +"void depth_compare_dither(){\n" " if( uDepthCompare ){\n" " vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" " * uInverseRatioDepth.xy;\n" @@ -444,6 +434,20 @@ static struct vg_shader _shader_model_character_view = { " if( step(0.0,diff)+dither<0.3 )\n" " discard;\n" " }\n" +"}\n" +"\n" +"#line 13 0 \n" +"\n" +"void main(){\n" +" depth_compare_dither();\n" +" compute_motion_vectors();\n" +"\n" +" vec3 qnorm = aNorm;\n" +" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n" +" vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n" +"\n" +" float dist = distance( aWorldCo, uCamera ) - 0.08;\n" +" float opacity = clamp( dist*dist, 0.0, 1.0 );\n" "\n" " oColour = vec4( composite, opacity );\n" "}\n" @@ -453,26 +457,29 @@ static struct vg_shader _shader_model_character_view = { static GLuint _uniform_model_character_view_uPv; static GLuint _uniform_model_character_view_uTransforms; static GLuint _uniform_model_character_view_uTexMain; -static GLuint _uniform_model_character_view_uTexSceneDepth; static GLuint _uniform_model_character_view_uCamera; -static GLuint _uniform_model_character_view_uInverseRatioDepth; -static GLuint _uniform_model_character_view_uInverseRatioMain; -static GLuint _uniform_model_character_view_uDepthCompare; static GLuint _uniform_model_character_view_g_world_depth; static GLuint _uniform_model_character_view_uLightsArray; static GLuint _uniform_model_character_view_uLightsIndex; +static GLuint _uniform_model_character_view_uTexSceneDepth; +static GLuint _uniform_model_character_view_uInverseRatioDepth; +static GLuint _uniform_model_character_view_uInverseRatioMain; +static GLuint _uniform_model_character_view_uDepthCompare; static void shader_model_character_view_uPv(m4x4f m){ glUniformMatrix4fv(_uniform_model_character_view_uPv,1,GL_FALSE,(float*)m); } static void shader_model_character_view_uTexMain(int i){ glUniform1i(_uniform_model_character_view_uTexMain,i); } -static void shader_model_character_view_uTexSceneDepth(int i){ - glUniform1i(_uniform_model_character_view_uTexSceneDepth,i); -} static void shader_model_character_view_uCamera(v3f v){ glUniform3fv(_uniform_model_character_view_uCamera,1,v); } +static void shader_model_character_view_g_world_depth(int i){ + glUniform1i(_uniform_model_character_view_g_world_depth,i); +} +static void shader_model_character_view_uTexSceneDepth(int i){ + glUniform1i(_uniform_model_character_view_uTexSceneDepth,i); +} static void shader_model_character_view_uInverseRatioDepth(v3f v){ glUniform3fv(_uniform_model_character_view_uInverseRatioDepth,1,v); } @@ -482,9 +489,6 @@ static void shader_model_character_view_uInverseRatioMain(v3f v){ static void shader_model_character_view_uDepthCompare(int b){ glUniform1i(_uniform_model_character_view_uDepthCompare,b); } -static void shader_model_character_view_g_world_depth(int i){ - glUniform1i(_uniform_model_character_view_g_world_depth,i); -} static void shader_model_character_view_register(void){ vg_shader_register( &_shader_model_character_view ); } @@ -493,13 +497,13 @@ static void shader_model_character_view_link(void){ _uniform_model_character_view_uPv = glGetUniformLocation( _shader_model_character_view.id, "uPv" ); _uniform_model_character_view_uTransforms = glGetUniformLocation( _shader_model_character_view.id, "uTransforms" ); _uniform_model_character_view_uTexMain = glGetUniformLocation( _shader_model_character_view.id, "uTexMain" ); - _uniform_model_character_view_uTexSceneDepth = glGetUniformLocation( _shader_model_character_view.id, "uTexSceneDepth" ); _uniform_model_character_view_uCamera = glGetUniformLocation( _shader_model_character_view.id, "uCamera" ); - _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" ); - _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" ); - _uniform_model_character_view_uDepthCompare = glGetUniformLocation( _shader_model_character_view.id, "uDepthCompare" ); _uniform_model_character_view_g_world_depth = glGetUniformLocation( _shader_model_character_view.id, "g_world_depth" ); _uniform_model_character_view_uLightsArray = glGetUniformLocation( _shader_model_character_view.id, "uLightsArray" ); _uniform_model_character_view_uLightsIndex = glGetUniformLocation( _shader_model_character_view.id, "uLightsIndex" ); + _uniform_model_character_view_uTexSceneDepth = glGetUniformLocation( _shader_model_character_view.id, "uTexSceneDepth" ); + _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" ); + _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" ); + _uniform_model_character_view_uDepthCompare = glGetUniformLocation( _shader_model_character_view.id, "uDepthCompare" ); } #endif /* SHADER_model_character_view_H */ diff --git a/shaders/model_font.fs b/shaders/model_font.fs index d0d2851..fa8c6e7 100644 --- a/shaders/model_font.fs +++ b/shaders/model_font.fs @@ -8,9 +8,10 @@ in vec4 aNorm; in vec3 aCo; #include "motion_vectors_fs.glsl" +#include "depth_compare.glsl" -void main() -{ +void main(){ + depth_compare_dither(); compute_motion_vectors(); oColour = texture( uTexMain, aUv ) * uColour; } diff --git a/shaders/model_font.h b/shaders/model_font.h index e3361ab..67ce50d 100644 --- a/shaders/model_font.h +++ b/shaders/model_font.h @@ -93,9 +93,40 @@ static struct vg_shader _shader_model_font = { "}\n" "\n" "#line 11 0 \n" +"#line 1 2 \n" +"uniform sampler2D uTexSceneDepth;\n" +"uniform vec3 uInverseRatioDepth;\n" +"uniform vec3 uInverseRatioMain;\n" +"uniform bool uDepthCompare;\n" +"\n" +"float linear_depth( float depth, float near, float far ) {\n" +" float z = depth * 2.0 - 1.0;\n" +" return (2.0 * near * far) / (far + near - z * (far - near)); \n" +"}\n" "\n" -"void main()\n" -"{\n" +"void depth_compare_dither(){\n" +" if( uDepthCompare ){\n" +" vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" +" * uInverseRatioDepth.xy;\n" +" float back_depth = texture( uTexSceneDepth, back_coord ).r;\n" +" float front_depth = gl_FragCoord.z/gl_FragCoord.w;\n" +"\n" +" back_depth = linear_depth( back_depth, 0.1, 2100.0 );\n" +" float diff = back_depth - front_depth;\n" +"\n" +" vec2 ssuv = gl_FragCoord.xy;\n" +" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" +" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" +"\n" +" if( step(0.0,diff)+dither<0.3 )\n" +" discard;\n" +" }\n" +"}\n" +"\n" +"#line 12 0 \n" +"\n" +"void main(){\n" +" depth_compare_dither();\n" " compute_motion_vectors();\n" " oColour = texture( uTexMain, aUv ) * uColour;\n" "}\n" @@ -108,6 +139,10 @@ static GLuint _uniform_model_font_uPvmPrev; static GLuint _uniform_model_font_uOffset; static GLuint _uniform_model_font_uTexMain; static GLuint _uniform_model_font_uColour; +static GLuint _uniform_model_font_uTexSceneDepth; +static GLuint _uniform_model_font_uInverseRatioDepth; +static GLuint _uniform_model_font_uInverseRatioMain; +static GLuint _uniform_model_font_uDepthCompare; static void shader_model_font_uMdl(m4x3f m){ glUniformMatrix4x3fv(_uniform_model_font_uMdl,1,GL_FALSE,(float*)m); } @@ -126,6 +161,18 @@ static void shader_model_font_uTexMain(int i){ static void shader_model_font_uColour(v4f v){ glUniform4fv(_uniform_model_font_uColour,1,v); } +static void shader_model_font_uTexSceneDepth(int i){ + glUniform1i(_uniform_model_font_uTexSceneDepth,i); +} +static void shader_model_font_uInverseRatioDepth(v3f v){ + glUniform3fv(_uniform_model_font_uInverseRatioDepth,1,v); +} +static void shader_model_font_uInverseRatioMain(v3f v){ + glUniform3fv(_uniform_model_font_uInverseRatioMain,1,v); +} +static void shader_model_font_uDepthCompare(int b){ + glUniform1i(_uniform_model_font_uDepthCompare,b); +} static void shader_model_font_register(void){ vg_shader_register( &_shader_model_font ); } @@ -137,5 +184,9 @@ static void shader_model_font_link(void){ _uniform_model_font_uOffset = glGetUniformLocation( _shader_model_font.id, "uOffset" ); _uniform_model_font_uTexMain = glGetUniformLocation( _shader_model_font.id, "uTexMain" ); _uniform_model_font_uColour = glGetUniformLocation( _shader_model_font.id, "uColour" ); + _uniform_model_font_uTexSceneDepth = glGetUniformLocation( _shader_model_font.id, "uTexSceneDepth" ); + _uniform_model_font_uInverseRatioDepth = glGetUniformLocation( _shader_model_font.id, "uInverseRatioDepth" ); + _uniform_model_font_uInverseRatioMain = glGetUniformLocation( _shader_model_font.id, "uInverseRatioMain" ); + _uniform_model_font_uDepthCompare = glGetUniformLocation( _shader_model_font.id, "uDepthCompare" ); } #endif /* SHADER_model_font_H */ diff --git a/skaterift.c b/skaterift.c index 73dd44e..388e37e 100644 --- a/skaterift.c +++ b/skaterift.c @@ -484,6 +484,7 @@ static void render_player_transparent(void){ /* Draw player to window buffer and blend background ontop */ player__render( &small_cam ); + render_remote_players_tags( localplayer.viewable_world, &skaterift.cam ); } static void render_scene(void){ diff --git a/world_render.c b/world_render.c index 37b095c..2d23737 100644 --- a/world_render.c +++ b/world_render.c @@ -142,8 +142,7 @@ static void render_world_depth( world_instance *world, camera *cam ); * Rendering */ -static void bind_terrain_noise(void) -{ +static void bind_terrain_noise(void){ glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, world_render.tex_terrain_noise ); } @@ -529,30 +528,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, } /* render texts */ - shader_scene_font_use(); - shader_scene_font_uTexGarbage(0); - shader_scene_font_uTexMain(1); - - shader_scene_font_uPv( skaterift.cam.mtx.pv ); - shader_scene_font_uTime( vg.time ); - - /* TODO: Code dupe... */ - world_link_lighting_ub( world, _shader_scene_font.id ); - world_bind_position_texture( world, _shader_scene_font.id, - _uniform_scene_font_g_world_depth, 2 ); - world_bind_light_array( world, _shader_scene_font.id, - _uniform_scene_font_uLightsArray, 3 ); - world_bind_light_index( world, _shader_scene_font.id, - _uniform_scene_font_uLightsIndex, 4 ); - - bind_terrain_noise(); - shader_scene_font_uCamera( skaterift.cam.transform[3] ); - - //shader_scene_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); - glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, gui.font.texture ); - - mesh_bind( &gui.font.mesh ); + font3d_bind( &gui.font, k_font_shader_world, 0, world, &skaterift.cam ); char buf[32]; u32 count = 0; @@ -568,7 +544,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_challenge), 3 ); buf[c++] = '\0'; - f32 w = font3d_string_width( &gui.font, 1, buf ); + f32 w = font3d_string_width( 1, buf ); m4x3f mlocal; m3x3_identity( mlocal ); mlocal[3][0] = -w*0.5f; @@ -593,15 +569,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, shader_scene_font_uOpacity( scale ); shader_scene_font_uColourize( colour ); - - struct font3d_render render = { - .font = &gui.font, - .variant_id = 1, - .shader = k_font_shader_world - }; - - font3d_begin( buf, &skaterift.cam, mmdl, &render ); - font3d_draw( &render ); + font3d_simple_draw( 1, buf, &skaterift.cam, mmdl ); } } diff --git a/world_render.h b/world_render.h index a28221f..ac0a0f2 100644 --- a/world_render.h +++ b/world_render.h @@ -77,5 +77,6 @@ static void render_world_depth( world_instance *world, camera *cam ); static void render_world( world_instance *world, camera *cam, int layer_depth ); static void render_world_cubemaps( world_instance *world ); +static void bind_terrain_noise(void); #endif /* WORLD_RENDER_H */ diff --git a/world_routes.c b/world_routes.c index 53ccb90..beb4c2c 100644 --- a/world_routes.c +++ b/world_routes.c @@ -1023,8 +1023,7 @@ static void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); -static void world_routes_update_timer_texts( world_instance *world ) -{ +static void world_routes_update_timer_texts( world_instance *world ){ world_render.timer_text_count = 0; for( u32 i=0; ient_route); i++ ){ @@ -1096,8 +1095,9 @@ static void world_routes_update_timer_texts( world_instance *world ) highscore_intr( text->text+2, route->checkpoints_count+1, 1, ' ' ); text->text[3] = '\0'; } - - float align_r = font3d_string_width( &gui.font, 0, text->text ); + + gui_font3d.font = &gui.font; + float align_r = font3d_string_width( 0, text->text ); align_r *= size; v3f positions[] = { @@ -1237,7 +1237,7 @@ static void render_world_routes( world_instance *world, camera *cam, /* timers * ---------------------------------------------------- */ if( layer_depth == 0 ){ - font3d_bind( &gui.font, cam ); + font3d_bind( &gui.font, k_font_shader_default, 0, world, cam ); for( u32 i=0; iroute->factive; shader_model_font_uColour( colour ); - font3d_simple_draw( &gui.font, 0, k_font_shader_default, - text->text, cam, text->transform ); + font3d_simple_draw( 0, text->text, cam, text->transform ); } shader_model_font_uOffset( (v4f){0.0f,0.0f,0.0f,1.0f} ); -- 2.25.1