nametag rendering
authorhgn <hgodden00@gmail.com>
Fri, 6 Oct 2023 06:04:02 +0000 (07:04 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 6 Oct 2023 06:04:02 +0000 (07:04 +0100)
17 files changed:
ent_skateshop.c
font.h
gui.h
menu.h
models_src/rs_icons.mdl
player_remote.c
player_render.c
shaders/depth_compare.glsl [new file with mode: 0644]
shaders/model_board_view.h
shaders/model_character_view.fs
shaders/model_character_view.h
shaders/model_font.fs
shaders/model_font.h
skaterift.c
world_render.c
world_render.h
world_routes.c

index f471f42b1359c6309d5cd3f9840f08e3e120a0fc..87e7509304a48719fa15471e98f8ae26c4c98fb1 100644 (file)
@@ -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 b979732804a2fc6da21c1605f23bcb1ce895cb15..c49bc6639f396a5fb27d9a55f2b78b06f2d98add 100644 (file)
--- 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; i<mdl_arrcount( &font->font_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 18b3dbd5eac91d28b4cd5e8cbf36ecab56710571..5cfe468501b8bcb27fb9359f72d03beaca56d959 100644 (file)
--- 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; i<gui.helper_count; i++ ){
       struct gui_helper *helper = &gui.helpers[i];
 
-      shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
-
-      struct font3d_render render = {
-         .font = &gui.font,
-         .variant_id = 2,
-         .shader = k_font_shader_default
-      };
-      font3d_begin( helper->bindstr, &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 243bebfd70fb742ce7084aca2be32733a4892880..098570608e53248d174e42a745da54ba30bc41db 100644 (file)
--- 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; i<text_count; i++ ){
       ent_menuitem *item = text_list[ i ];
       m4x3f transform;
@@ -769,13 +769,12 @@ static void menu_render(void){
 
       u32 variant = item->binding.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 );
    }
 }
 
index 92858f23063c6d0e33122cd1f91426bca04e4d81..84f31291d6d77059e237be94365b131714179067 100644 (file)
Binary files a/models_src/rs_icons.mdl and b/models_src/rs_icons.mdl differ
index 8cbbed6eed8cab2983f47c48c940b37dd93205e9..b533d389e5af955ea6bc8dd9b0aa76d7c79cb604 100644 (file)
@@ -3,6 +3,8 @@
 #include "player_render.h"
 #include "network_common.h"
 #include "addon.h"
+#include "font.h"
+#include "gui.h"
 
 static void player_remote_clear( struct network_player *player ){
    addon_cache_unwatch( k_addon_type_player, player->playermodel_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; i<NETWORK_MAX_PLAYERS; i ++ ){
@@ -609,6 +611,49 @@ static void render_remote_players( world_instance *world, camera *cam ){
    SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
 }
 
+static void render_remote_player_nametag( v3f co, const char *name ){
+   m4x3f mlocal;
+   m4x3_identity( mlocal );
+   mlocal[3][0] -= font3d_string_width( 2, name ) * 0.5f;
+
+   m4x3f mmdl;
+   m3x3_identity( mmdl );
+   for( int i=0; i<3; i++ )
+      v3_muls( skaterift.cam.mtx.v[i], 0.2f, mmdl[i] );
+   m3x3_transpose( mmdl, mmdl );
+   v3_add( co, (v3f){0.0f,2.0f,0.0f}, mmdl[3] );
+
+   m4x3_mul( mmdl, mlocal, mmdl );
+   font3d_simple_draw( 2, name, &skaterift.cam, mmdl );
+}
+
+static void render_remote_players_tags( world_instance *world, camera *cam ){
+   glEnable(GL_BLEND);
+   glEnable(GL_DEPTH_TEST);
+   glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+   glBlendEquation(GL_FUNC_ADD);
+
+   font3d_bind( &gui.font, k_font_shader_default, 1, NULL, &skaterift.cam );
+   font3d_setcolour( (v4f){1.0f,1.0f,1.0f,1.0f} );
+
+   render_remote_player_nametag( 
+         localplayer.final_mtx[0][3], 
+         steam_username_at_startup );
+
+   for( u32 i=0; i<NETWORK_MAX_PLAYERS; i ++ ){
+      struct network_player *player = &netplayers.list[i];
+      if( !player->active ) 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; i<NETWORK_SFX_QUEUE_LENGTH; i ++ ){
       netplayers.sfx_queue[i].system = k_player_subsystem_invalid;
index 3f72657b1d8ed87c89bfce9504f88a0100d90774..a37e74e2128b9e67d92664d793758f65193d96fa 100644 (file)
@@ -12,6 +12,7 @@
 #include "shaders/model_character_view.h"
 #include "shaders/model_board_view.h"
 #include "shaders/model_entity.h"
+#include "shaders/model_board_view.h"
 
 static void player_avatar_load( struct player_avatar *av, const char *path ){
    mdl_open( &av->meta, 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 (file)
index 0000000..5e02144
--- /dev/null
@@ -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;
+   }
+}
index d1e7f652c564d55177466892877970994453564a..3a1ba9ca2644818341f9f1dc79655054bf0c37b5 100644 (file)
@@ -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 */
index efee606c86b7b0151505dd268d258af035f9d8cd..6330f9bf13ebf5635c694ae3d6cfdbaeaf41813b 100644 (file)
@@ -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 );
 }
index bae5d38721bcd9c285308f4a3c88059d61ae9348..060e5b2419c3fd715fcf9c1c5e7447ba12749c20 100644 (file)
@@ -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 */
index d0d285106708153a6d4552d5a0ef0a9c4efdca5e..fa8c6e78b89ad2815bb085763135c80753153639 100644 (file)
@@ -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;
 }
index e3361ab8c6e91d199d9a3313416167472e7befae..67ce50d090f32deaac5e64a5495a14f88fa034a3 100644 (file)
@@ -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 */
index 73dd44e04cf88a9d86486e812ab082f05c0cb9a3..388e37ebeac21af80f77375cad69cecfb0cc9b85 100644 (file)
@@ -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){
index 37b095c7bd8939816e4d30115e06dc1018baab68..2d23737c3f5325247b0db045ed2da4bd18cce028 100644 (file)
@@ -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 );
    }
 }
 
index a28221fb2af9717ce4f9ba6a79cfe123b4685e4e..ac0a0f2a82160b1e9e5e8e1d5ff98cc854031a27 100644 (file)
@@ -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 */
index 53ccb90e0bb7236d35db4bda4fc6bf895745df32..beb4c2c8f7c8e15f99c730794f407430dafd933d 100644 (file)
@@ -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; i<mdl_arrcount(&world->ent_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; i<world_render.timer_text_count; i++ ){
          struct timer_text *text = &world_render.timer_texts[i];
@@ -1248,8 +1248,7 @@ static void render_world_routes( world_instance *world, camera *cam,
          colour[3] = 1.0f-text->route->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} );