sfd
authorhgn <hgodden00@gmail.com>
Mon, 1 Aug 2022 16:34:47 +0000 (17:34 +0100)
committerhgn <hgodden00@gmail.com>
Mon, 1 Aug 2022 16:34:47 +0000 (17:34 +0100)
models/mp_dev.mdl
models/rs_scoretext.mdl [new file with mode: 0644]
shaders/scoretext.h [new file with mode: 0644]
shaders/scoretext.vs [new file with mode: 0644]
textures/scoretext.png [new file with mode: 0644]
vg.conf
world.h
world_routes.h
world_sfd.h [new file with mode: 0644]

index 1768051983ff41beacb94cdc6a575e31f5dc9a62..5f0de7ca8ae0946c99a775b65bfea23c4fdebbe5 100644 (file)
Binary files a/models/mp_dev.mdl and b/models/mp_dev.mdl differ
diff --git a/models/rs_scoretext.mdl b/models/rs_scoretext.mdl
new file mode 100644 (file)
index 0000000..5eef656
Binary files /dev/null and b/models/rs_scoretext.mdl differ
diff --git a/shaders/scoretext.h b/shaders/scoretext.h
new file mode 100644 (file)
index 0000000..304715c
--- /dev/null
@@ -0,0 +1,260 @@
+#ifndef SHADER_scoretext_H
+#define SHADER_scoretext_H
+static void shader_scoretext_link(void);
+static void shader_scoretext_register(void);
+static struct vg_shader _shader_scoretext = {
+   .name = "scoretext",
+   .link = shader_scoretext_link,
+   .vs = 
+{
+.orig_file = "../shaders/scoretext.vs",
+.static_src = 
+"layout (location=0) in vec3 a_co;\n"
+"layout (location=1) in vec3 a_norm;\n"
+"layout (location=2) in vec4 a_colour;\n"
+"layout (location=3) in vec2 a_uv;\n"
+"\n"
+"#line      2        0 \n"
+"\n"
+"uniform mat4 uPv;\n"
+"uniform mat4x3 uMdl;\n"
+"\n"
+"uniform vec3 uInfo;\n"
+"\n"
+"out vec4 aColour;\n"
+"out vec2 aUv;\n"
+"out vec3 aNorm;\n"
+"out vec3 aCo;\n"
+"out vec3 aWorldCo;\n"
+"\n"
+"void main()\n"
+"{\n"
+"   float w = a_colour.g + fract(uInfo.z+0.5)-0.75;\n"
+"   float c = -cos(w*0.2);\n"
+"   float s = -sin(w*0.2);\n"
+"   float r = 0.2;\n"
+"\n"
+"   float w1 = clamp( w*4.0 - a_co.y*10.0, -1.0, 1.0 ) *(3.14159265*0.5);\n"
+"   float c1 = cos(w1);\n"
+"   float s1 = sin(w1);\n"
+"\n"
+"   float yoff = step(0.01,fract(uInfo.z))*-0.5;\n"
+"\n"
+"   mat4x3 mlocal;\n"
+"   mlocal[0] = vec3(c1, s1,0.0);\n"
+"   mlocal[1] = vec3(-s1,c1,0.0);\n"
+"   mlocal[2] = vec3(0.0,0.0,1.0);\n"
+"   mlocal[3] = vec3(c*r,uInfo.y*0.875 + s*r,uInfo.x*0.5);\n"
+"\n"
+"   vec3 world_pos = uMdl * vec4(mlocal * vec4(a_co,1.0),1.0);\n"
+"   gl_Position = uPv * vec4( world_pos, 1.0 );\n"
+"   aColour = a_colour;\n"
+"   aUv = a_uv + vec2( floor(uInfo.z+0.5)*(1.0/64.0), yoff );\n"
+"   aNorm = mat3(uMdl) * mat3(mlocal) * a_norm;\n"
+"   aCo = a_co;\n"
+"   aWorldCo = world_pos;\n"
+"}\n"
+""},
+   .fs = 
+{
+.orig_file = "../shaders/vblend.fs",
+.static_src = 
+"out vec4 FragColor;\n"
+"\n"
+"uniform sampler2D uTexGarbage;\n"
+"uniform sampler2D uTexGradients;\n"
+"uniform vec3 uCamera;\n"
+"\n"
+"in vec4 aColour;\n"
+"in vec2 aUv;\n"
+"in vec3 aNorm;\n"
+"in vec3 aCo;\n"
+"in vec3 aWorldCo;\n"
+"\n"
+"#line       1        1 \n"
+"layout (std140) uniform ub_world_lighting\n"
+"{\n"
+"   vec4 g_light_colours[3];\n"
+"   vec4 g_light_directions[3];\n"
+"   vec4 g_ambient_colour;\n"
+"\n"
+"   vec4 g_water_plane;\n"
+"   vec4 g_depth_bounds;\n"
+"   float g_water_fog;\n"
+"   int g_light_count;\n"
+"   int g_light_preview;\n"
+"};\n"
+"\n"
+"uniform sampler2D g_world_depth;\n"
+"\n"
+"// Standard diffuse + spec models\n"
+"// ==============================\n"
+"\n"
+"vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n"
+"{\n"
+"   vec3 vtotal = g_ambient_colour.rgb;\n"
+"\n"
+"   for( int i=0; i<g_light_count; i++ )\n"
+"   {\n"
+"      vec3 vcolour = g_light_colours[i].rgb;\n"
+"      vec3 vdir = g_light_directions[i].xyz;\n"
+"\n"
+"      float flight = max(dot( vdir, wnormal )*0.75+0.25,0.0);\n"
+"      vtotal += vcolour*flight;\n"
+"   }\n"
+"\n"
+"   return vfrag * vtotal;\n"
+"}\n"
+"\n"
+"vec3 do_light_spec( vec3 vfrag, vec3 wnormal, vec3 halfview, float fintensity )\n"
+"{\n"
+"   vec3 vcolour = g_light_colours[0].rgb;\n"
+"   vec3 vdir = g_light_directions[0].xyz;\n"
+"\n"
+"   vec3 specdir = reflect( -vdir, wnormal );\n"
+"   float spec = pow(max(dot( halfview, specdir ), 0.0), 10.0);\n"
+"   return vfrag + vcolour*spec*fintensity;\n"
+"}\n"
+"\n"
+"float world_depth_sample( vec3 pos )\n"
+"{\n"
+"   vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
+"   return texture( g_world_depth, depth_coord ).r;\n"
+"}\n"
+"\n"
+"float shadow_sample( vec3 vdir )\n"
+"{\n"
+"   vec3 sample_pos = aWorldCo + vdir;\n"
+"   float height_sample = world_depth_sample( sample_pos );\n"
+"\n"
+"   float fdelta = height_sample - sample_pos.y;\n"
+"   return clamp( fdelta, 0.1, 0.2 )-0.1;\n"
+"}\n"
+"\n"
+"vec3 do_light_shadowing_old( vec3 vfrag )\n"
+"{\n"
+"   float faccum = 0.0;\n"
+"   faccum += shadow_sample( vec3( 0.0, 0.5, 0.0 ));\n"
+"   faccum += shadow_sample( vec3( 2.0, 0.3, 0.0 ));\n"
+"   faccum += shadow_sample( vec3( 3.0, 1.0, 0.0 ));\n"
+"   faccum += shadow_sample( vec3( 5.0, 1.0, 0.0 ));\n"
+"   faccum += shadow_sample( vec3( 0.0, 0.5, 0.0 )*1.5);\n"
+"   faccum += shadow_sample( vec3( 2.0, 0.3, 0.0 )*1.5);\n"
+"   faccum += shadow_sample( vec3( 3.0, 1.0, 0.0 )*1.5);\n"
+"   faccum += shadow_sample( vec3( 5.0, 1.0, 0.0 )*1.5);\n"
+"   return mix( vfrag, g_ambient_colour.rgb, faccum );\n"
+"}\n"
+"\n"
+"vec3 do_light_shadowing( vec3 vfrag )\n"
+"{\n"
+"   float fspread = g_light_colours[0].w;\n"
+"   vec3  vdir = g_light_directions[0].xyz;\n"
+"   float flength = g_light_directions[0].w;\n"
+"\n"
+"   float famt = 0.0;\n"
+"   famt+=shadow_sample((vdir+vec3(-0.563, 0.550, 0.307)*fspread)*flength*0.1);\n"
+"   famt+=shadow_sample((vdir+vec3( 0.808, 0.686, 0.346)*fspread)*flength*0.2);\n"
+"   famt+=shadow_sample((vdir+vec3( 0.787, 0.074,-0.065)*fspread)*flength*0.3);\n"
+"   famt+=shadow_sample((vdir+vec3(-0.593, 0.071,-0.425)*fspread)*flength*0.4);\n"
+"   famt+=shadow_sample((vdir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n"
+"   famt+=shadow_sample((vdir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n"
+"   famt+=shadow_sample((vdir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n"
+"   famt+=shadow_sample((vdir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n"
+"   return mix( vfrag, g_ambient_colour.rgb, famt );\n"
+"}\n"
+"\n"
+"vec3 apply_fog( vec3 vfrag, float fdist )\n"
+"{\n"
+"   float dist = pow(fdist*0.0008,1.2);\n"
+"   return mix( vfrag, vec3(0.55,0.76,1.0), min( 1.0, dist ) );\n"
+"}\n"
+"\n"
+"#line     14        0 \n"
+"\n"
+"void main()\n"
+"{\n"
+"   vec3 vfrag = vec3(0.5,0.5,0.5);\n"
+"\n"
+"   // ws modulation\n"
+"   vec4 wgarbage = vec4(0.5,0.5,0.5,1.0);//texture( uTexGarbage, aCo.xz * 0.160 );\n"
+"   \n"
+"   // Creating normal patches\n"
+"   vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n"
+"   vec3 qnorm = normalize(floor(aNorm*4.0+modnorm)*0.25) + vec3(0.001,0.0,0.0);\n"
+"\n"
+"   vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0)));\n"
+"   vec3 tangent1 = cross(qnorm,tangent0);\n"
+"   vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.160;\n"
+"   \n"
+"   // Patch local noise\n"
+"   vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n"
+"\n"
+"   // Colour blending\n"
+"   float fblendclip = step(0.380,aColour.r + (rgarbage.r-0.5)*-1.740)*0.320;\n"
+"   vec2 uvgradients = aUv + vec2( fblendclip, 0.0 );\n"
+"\n"
+"   vfrag = texture( uTexGradients, uvgradients ).rgb;\n"
+"   vfrag -= rgarbage.a*0.04;\n"
+"\n"
+"   if( g_light_preview == 1 )\n"
+"   {\n"
+"      vfrag = vec3(0.5);\n"
+"   }\n"
+"\n"
+"   // Lighting\n"
+"   vec3 halfview = uCamera - aWorldCo;\n"
+"   float fdist = length( halfview );\n"
+"   halfview /= fdist;\n"
+"\n"
+"   vfrag = do_light_diffuse( vfrag, qnorm );\n"
+"   vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 );\n"
+"   vfrag = do_light_shadowing( vfrag );\n"
+"   vfrag = apply_fog( vfrag, fdist );\n"
+"\n"
+"   FragColor = vec4(vfrag, 1.0 );\n"
+"}\n"
+""},
+};
+
+static GLuint _uniform_scoretext_uPv;
+static GLuint _uniform_scoretext_uMdl;
+static GLuint _uniform_scoretext_uInfo;
+static GLuint _uniform_scoretext_uTexGarbage;
+static GLuint _uniform_scoretext_uTexGradients;
+static GLuint _uniform_scoretext_uCamera;
+static GLuint _uniform_scoretext_g_world_depth;
+static void shader_scoretext_uPv(m4x4f m){
+   glUniformMatrix4fv( _uniform_scoretext_uPv, 1, GL_FALSE, (float *)m );
+}
+static void shader_scoretext_uMdl(m4x3f m){
+   glUniformMatrix4x3fv( _uniform_scoretext_uMdl, 1, GL_FALSE, (float *)m );
+}
+static void shader_scoretext_uInfo(v3f v){
+   glUniform3fv( _uniform_scoretext_uInfo, 1, v );
+}
+static void shader_scoretext_uTexGarbage(int i){
+   glUniform1i( _uniform_scoretext_uTexGarbage, i );
+}
+static void shader_scoretext_uTexGradients(int i){
+   glUniform1i( _uniform_scoretext_uTexGradients, i );
+}
+static void shader_scoretext_uCamera(v3f v){
+   glUniform3fv( _uniform_scoretext_uCamera, 1, v );
+}
+static void shader_scoretext_g_world_depth(int i){
+   glUniform1i( _uniform_scoretext_g_world_depth, i );
+}
+static void shader_scoretext_register(void){
+   vg_shader_register( &_shader_scoretext );
+}
+static void shader_scoretext_use(void){ glUseProgram(_shader_scoretext.id); }
+static void shader_scoretext_link(void){
+   _uniform_scoretext_uPv = glGetUniformLocation( _shader_scoretext.id, "uPv" );
+   _uniform_scoretext_uMdl = glGetUniformLocation( _shader_scoretext.id, "uMdl" );
+   _uniform_scoretext_uInfo = glGetUniformLocation( _shader_scoretext.id, "uInfo" );
+   _uniform_scoretext_uTexGarbage = glGetUniformLocation( _shader_scoretext.id, "uTexGarbage" );
+   _uniform_scoretext_uTexGradients = glGetUniformLocation( _shader_scoretext.id, "uTexGradients" );
+   _uniform_scoretext_uCamera = glGetUniformLocation( _shader_scoretext.id, "uCamera" );
+   _uniform_scoretext_g_world_depth = glGetUniformLocation( _shader_scoretext.id, "g_world_depth" );
+}
+#endif /* SHADER_scoretext_H */
diff --git a/shaders/scoretext.vs b/shaders/scoretext.vs
new file mode 100644 (file)
index 0000000..bc7db92
--- /dev/null
@@ -0,0 +1,40 @@
+#include "vertex_standard.glsl"
+
+uniform mat4 uPv;
+uniform mat4x3 uMdl;
+
+uniform vec3 uInfo;
+
+out vec4 aColour;
+out vec2 aUv;
+out vec3 aNorm;
+out vec3 aCo;
+out vec3 aWorldCo;
+
+void main()
+{
+   float w = a_colour.g + fract(uInfo.z+0.5)-0.75;
+   float c = -cos(w*0.2);
+   float s = -sin(w*0.2);
+   float r = 0.2;
+
+   float w1 = clamp( w*4.0 - a_co.y*10.0, -1.0, 1.0 ) *(3.14159265*0.5);
+   float c1 = cos(w1);
+   float s1 = sin(w1);
+
+   float yoff = step(0.01,fract(uInfo.z))*-0.5;
+
+   mat4x3 mlocal;
+   mlocal[0] = vec3(c1, s1,0.0);
+   mlocal[1] = vec3(-s1,c1,0.0);
+   mlocal[2] = vec3(0.0,0.0,1.0);
+   mlocal[3] = vec3(c*r,uInfo.y*0.875 + s*r,uInfo.x*0.5);
+
+   vec3 world_pos = uMdl * vec4(mlocal * vec4(a_co,1.0),1.0);
+   gl_Position = uPv * vec4( world_pos, 1.0 );
+   aColour = a_colour;
+   aUv = a_uv + vec2( floor(uInfo.z+0.5)*(1.0/64.0), yoff );
+   aNorm = mat3(uMdl) * mat3(mlocal) * a_norm;
+   aCo = a_co;
+   aWorldCo = world_pos;
+}
diff --git a/textures/scoretext.png b/textures/scoretext.png
new file mode 100644 (file)
index 0000000..e45097b
Binary files /dev/null and b/textures/scoretext.png differ
diff --git a/vg.conf b/vg.conf
index ec19f6aaaf6c1529c40616e72517dcfa2fa814b4..d0429fa41b65964aa805eb01a8ab3a1eb5d16bc4 100644 (file)
--- a/vg.conf
+++ b/vg.conf
@@ -16,3 +16,4 @@ shader sky standard.vs sky.fs
 shader planeinf standard.vs planeinf.fs
 shader gpos standard.vs gpos.fs
 shader route standard.vs route.fs
+shader scoretext scoretext.vs vblend.fs
diff --git a/world.h b/world.h
index f015a63e0ae43c93a9b4cd15b762bc133d3a7b18..73a33c0275208cc9e4312c4c5b6abee059a2319d 100644 (file)
--- a/world.h
+++ b/world.h
@@ -17,6 +17,7 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit );
 
 #include "traffic.h" /*TODO: -> world_traffic.h */
 #include "world_routes.h"
+#include "world_sfd.h"
 
 #include "shaders/terrain.h"
 #include "shaders/sky.h"
@@ -40,6 +41,7 @@ static struct gworld
    u32 spawn_count;
 
    struct subworld_routes routes;
+   struct subworld_sfd sfd;
 
    /* ...
    struct subworld_spawns system_spawns;
@@ -85,6 +87,7 @@ static struct gworld
 world;
 
 static struct subworld_routes *subworld_routes(void) { return &world.routes; }
+static struct subworld_sfd *subworld_sfd(void) { return &world.sfd; }
 
 
 vg_tex2d tex_terrain_colours = { .path = "textures/gradients.qoi",
@@ -122,11 +125,14 @@ static void world_register(void)
    shader_alphatest_register();
 
    world_routes_register();
+   world_sfd_register();
 }
 
 static void world_free(void)
 {
    /* TODO.. */
+
+   world_sfd_free();
 }
 
 static void render_world_depth( m4x4f projection, m4x3f camera );
@@ -497,11 +503,16 @@ static void world_init(void)
    world.dome_lower = *mdl_node_submesh( msky, nlower, 0 );
    world.dome_upper = *mdl_node_submesh( msky, nupper, 0 );
    free(msky);
+
+
+   /* Other systems */
+   world_sfd_init();
 }
 
 static void world_update(void)
 {
    world_routes_debug();
+   sfd_update( &world.sfd.tester );
 
 #if 0
    rb_solver_reset();
@@ -685,6 +696,16 @@ static void render_world( m4x4f projection, m4x3f camera )
    render_world_vb( projection, camera[3] );
    render_world_alphatest( projection, camera[3] );
    render_terrain( projection, camera[3] );
+
+   m4x3f identity_matrix;
+   m4x3_identity( identity_matrix );
+   identity_matrix[3][1] = 125.0f;
+
+   v4f t;
+   q_axis_angle( t, (v3f){0.0f,1.0f,0.0f}, 2.3f );
+   q_m3x3( t, identity_matrix );
+
+   sfd_render( &world.sfd.tester, projection, camera[3], identity_matrix );
 }
 
 static void render_world_depth( m4x4f projection, m4x3f camera )
index 82d5da7925b0ee67749bb35f91ba77ec1e658fe0..4c198e1a429a23001ed299045790297353e96575 100644 (file)
@@ -58,11 +58,6 @@ struct subworld_routes
 
 static struct subworld_routes *subworld_routes(void);
 
-/* 
- * TODO list:
- *      when a gate is passed through it needs to trigger into an active state
- */      
-
 static void debug_sbpath( struct route_node *rna, struct route_node *rnb,
                           u32 colour, float xoffset )
 {
diff --git a/world_sfd.h b/world_sfd.h
new file mode 100644 (file)
index 0000000..88f7331
--- /dev/null
@@ -0,0 +1,232 @@
+#ifndef SFD_H
+#define SFD_H
+
+#include "common.h"
+#include "model.h"
+#include "world.h"
+
+#include "shaders/scoretext.h"
+#include "shaders/vblend.h"
+
+vg_tex2d tex_scoretext = { .path = "textures/scoretext.qoi",
+                           .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST };
+
+struct sfd_instance
+{
+   float *buffer;
+
+   u32 w,h;
+};
+
+
+struct subworld_sfd
+{
+   scene mesh;
+   mdl_submesh *sm_module, *sm_card;
+   glmesh temp;
+
+   struct sfd_instance tester;
+};
+
+static struct subworld_sfd *subworld_sfd(void);
+
+
+float sfd_encode_glyph( char c )
+{
+   int value = 0;
+   if( c >= 'a' && c <= 'z' )
+      value = c-'a'+11;
+   else if( c >= '0' && c <= '9' )
+      value = c-'0'+1;
+   else if( c >= 'A' && c <= 'Z' )
+      value = c-'A'+11;
+   else if( c >= '\x01' && c <= '\x01'+10 )
+      value = 63-c;
+   else
+   {
+      int base = 'A'+11+27;
+
+      switch( c )
+      {
+         case '!': value=base+0; break;
+         case '?': value=base+1; break;
+         case ',': value=base+2; break;
+         case '.': value=base+3; break;
+         case '#': value=base+4; break;
+         case '$': value=base+5; break;
+         case '%': value=base+6; break;
+         case '*': value=base+7; break;
+         case '+': value=base+8; break;
+         case '-': value=base+9; break;
+         case ':': value=base+10; break;
+         case '/': value=base+11; break;
+         default: value=0; break;
+      }
+   }
+
+   return (float)value;
+}
+
+static void sfd_encode( struct sfd_instance *display, u32 row, const char *str )
+{
+   int end=0;
+   for( int i=0; i<display->w; i++ )
+   {
+      if( end )
+      {
+         display->buffer[display->w*row + i] = 0.0f;
+      }
+      else
+      {
+         if( !str[i] )
+            end = 1;
+
+         display->buffer[display->w*row + i] = sfd_encode_glyph( str[i] );
+      }
+   }
+}
+
+static void sfd_new( struct sfd_instance *display, u32 w, u32 h )
+{
+   display->w = w;
+   display->h = h;
+   display->buffer = malloc( w*h*sizeof(float)*2 );
+
+   for( int i=0; i<w*h*2; i++ )
+      display->buffer[i] = 0.0f;
+}
+
+static void sfd_update( struct sfd_instance *display )
+{
+   for( int i=0; i<display->w*display->h; i++ )
+   {
+      float *target = &display->buffer[i],
+            *cur = target+display->w*display->h;
+      
+      float const rate = ktimestep*15.2313131414f;
+      float d1 = *target-*cur;
+      
+      if( fabsf(d1) > rate )
+      {
+         *cur += rate;
+         if( *cur > 60.0f )
+            *cur -= 60.0f;
+      }
+      else
+         *cur = *target;
+   }
+}
+
+static void sfd_render( struct sfd_instance *display, 
+                        m4x4f projection, v3f camera, m4x3f transform )
+{
+   struct subworld_sfd *sfd = subworld_sfd();
+   scene_bind( &sfd->mesh );
+
+   shader_scoretext_use();
+   shader_scoretext_uTexGarbage(0);
+   shader_scoretext_uTexGradients(1);
+   shader_link_standard_ub( _shader_scoretext.id, 2 );
+   bind_terrain_textures();
+   vg_tex2d_bind( &tex_scoretext, 1 );
+
+   shader_scoretext_uPv( projection );
+   shader_scoretext_uMdl( transform );
+   shader_scoretext_uCamera( camera );
+
+   for( int y=0;y<display->h; y++ )
+   {
+      for( int x=0; x<display->w; x++ )
+      {
+         float value = display->buffer[display->h*display->w+y*display->w+x];
+         shader_scoretext_uInfo( (v3f){ x,y, value } );
+         scene_draw( &sfd->mesh );
+      }
+   }
+
+   shader_vblend_use();
+   shader_vblend_uTexGarbage(0);
+   shader_vblend_uTexGradients(1);
+   shader_link_standard_ub( _shader_vblend.id, 2 );
+   bind_terrain_textures();
+
+   shader_vblend_uPv( projection );
+   shader_vblend_uMdl( transform );
+   shader_vblend_uCamera( camera );
+   
+   mesh_bind( &sfd->temp );
+   mesh_draw( &sfd->temp );
+}
+
+static int world_sfd_test( int argc, const char *argv[] )
+{
+   struct subworld_sfd *sfd = subworld_sfd();
+
+   if( argc == 2 )
+   {
+      int row = vg_min(vg_max(atoi(argv[0]),0),sfd->tester.h);
+      sfd_encode( &sfd->tester, row, argv[1] );
+   }
+
+   return 0;
+}
+
+static void world_sfd_init(void)
+{
+   struct subworld_sfd *sfd = subworld_sfd();
+
+       vg_function_push( (struct vg_cmd){
+               .name = "sfd",
+               .function = world_sfd_test
+       });
+
+   mdl_header *mboard = mdl_load( "models/rs_scoretext.mdl" );
+   
+   scene_init( &sfd->mesh );
+
+   mdl_node *pn_card = mdl_node_from_name( mboard, "score_card" );
+   mdl_submesh *card = mdl_submesh_from_id( mboard, pn_card->submesh_start );
+
+   mdl_node *pn_backer = mdl_node_from_name( mboard, "backer" );
+   mdl_submesh *backer = mdl_submesh_from_id( mboard, pn_backer->submesh_start);
+   mdl_unpack_submesh( mboard, &sfd->temp, backer );
+
+   m4x3f identity;
+   m4x3_identity( identity );
+
+   for( int i=0;i<8;i++ )
+   {
+      u32 vert_start = sfd->mesh.vertex_count;
+      scene_add_submesh( &sfd->mesh, mboard, card, identity );
+
+      for( int j=0; j<card->vertex_count; j++ )
+      {
+         mdl_vert *vert = &sfd->mesh.verts[ vert_start+j ];
+
+         float const k_glyph_uvw = 1.0f/64.0f;
+         vert->uv[0] -= k_glyph_uvw * (float)(i-4);
+         vert->colour[0] = 0.0f;
+         vert->colour[1] = i-4;
+      }
+   }
+
+   scene_upload( &sfd->mesh );
+   scene_free_offline_buffers( &sfd->mesh );
+
+   free( mboard );
+   vg_tex2d_init( (vg_tex2d *[]){ &tex_scoretext }, 1 );
+
+   sfd_new( &sfd->tester, 16, 8 );
+}
+
+static void world_sfd_register(void)
+{
+   shader_scoretext_register();
+}
+
+static void world_sfd_free(void)
+{
+   vg_tex2d_free( (vg_tex2d *[]){ &tex_scoretext }, 1 );
+}
+
+#endif /* SFD_H */