better low qual mode
authorhgn <hgodden00@gmail.com>
Sun, 6 Nov 2022 07:10:11 +0000 (07:10 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 6 Nov 2022 07:10:11 +0000 (07:10 +0000)
17 files changed:
bvh.h
play.sh
render.h
scene.h
shaders/alphatest.h
shaders/common_world.glsl
shaders/gpos.h
shaders/route.h
shaders/scoretext.h
shaders/standard.h
shaders/terrain.h
shaders/vblend.h
shaders/viewchar.h
shaders/water.h
shaders/water_fast.h
skaterift.c
world_gen.h

diff --git a/bvh.h b/bvh.h
index 84f4c6b7d675c7b1cfdf9f914722b572424aa347..9e4528604d59c8cf205f20d3d172b671102085e1 100644 (file)
--- a/bvh.h
+++ b/bvh.h
@@ -32,6 +32,7 @@ struct bh_tree
 
    bh_system *system;
    void *user;
+   u32 max_per_leaf;
 
    struct bh_node
    {
@@ -77,6 +78,9 @@ VG_STATIC void bh_subdivide( bh_tree *bh, u32 inode )
 {
    bh_node *node = &bh->nodes[ inode ];
 
+   if( node->count <= bh->max_per_leaf )
+      return;
+
    v3f extent;
    v3_sub( node->bbx[1], node->bbx[0], extent );
 
@@ -135,8 +139,10 @@ VG_STATIC void bh_subdivide( bh_tree *bh, u32 inode )
 }
 
 VG_STATIC bh_tree *bh_create( void *lin_alloc, bh_system *system, 
-                              void *user, u32 item_count )
+                              void *user, u32 item_count, u32 max_per_leaf )
 {
+   assert( max_per_leaf > 0 );
+
    if( item_count == 0 )
    {
       bh_tree *bh = vg_linear_alloc( lin_alloc, sizeof(bh_tree) );
@@ -150,6 +156,7 @@ VG_STATIC bh_tree *bh_create( void *lin_alloc, bh_system *system,
    bh_tree *bh = vg_linear_alloc( lin_alloc, totsize );
    bh->system = system;
    bh->user = user;
+   bh->max_per_leaf = max_per_leaf;
 
    bh_node *root = &bh->nodes[0];
    bh->node_count = 1;
diff --git a/play.sh b/play.sh
index 880141d69e788b8a4c9067bc0bf3d31d45469a27..b2c57c9a4780f2059ac720593ebccc7edad06f71 100755 (executable)
--- a/play.sh
+++ b/play.sh
@@ -1,3 +1,3 @@
 cd bin/skaterift-clang/
-./skaterift
+./skaterift $@
 cd ../../
index 209bed692d5bc5777fbb3db122b4410ab2a96b56..317b30110bc2d6df942816a258f60940871eec82 100644 (file)
--- a/render.h
+++ b/render.h
@@ -49,6 +49,7 @@ VG_STATIC struct pipeline
       float g_water_fog;
       int g_light_count;
       int g_light_preview;
+      int g_shadow_samples;
    }
    ub_world_lighting;
 
@@ -169,6 +170,11 @@ VG_STATIC void render_update_lighting_ub(void)
    winf->g_light_directions[0][3] = gpipeline.shadow_length;
    winf->g_light_colours[0][3] = gpipeline.shadow_spread;
 
+   if( vg.quality_profile == k_quality_profile_low )
+      winf->g_shadow_samples = 0;
+   else
+      winf->g_shadow_samples = 8;
+
    glBindBuffer( GL_UNIFORM_BUFFER, gpipeline.ubo_world_lighting );
    glBufferSubData( GL_UNIFORM_BUFFER, 0, sizeof(struct ub_world_lighting),
          &gpipeline.ub_world_lighting );
diff --git a/scene.h b/scene.h
index 340207582ba94cfe46d4dd017d178c3f89079e8f..5d436875cfd3187a7efd04ec980f5ee55699d2ce 100644 (file)
--- a/scene.h
+++ b/scene.h
@@ -334,7 +334,7 @@ VG_STATIC int scene_raycast( scene *s, bh_tree *bh,
 VG_STATIC bh_tree *scene_bh_create( void *lin_alloc, scene *s )
 {
    u32 triangle_count = s->indice_count / 3;
-   return bh_create( lin_alloc, &bh_system_scene, s, triangle_count );
+   return bh_create( lin_alloc, &bh_system_scene, s, triangle_count, 2 );
 }
 
 #endif
index 9b161c1b86a28950c59c3fd1781977bf033cac06..07908407de8157e18f9d52e01e8cab1cce5f6396 100644 (file)
@@ -67,6 +67,7 @@ static struct vg_shader _shader_alphatest = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -131,6 +132,11 @@ static struct vg_shader _shader_alphatest = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 5e1a8919070e9f1865a1250c745f98f329222ed1..d7b3ccfefc0741947a9bcd380b64e44e24d4a23a 100644 (file)
@@ -9,6 +9,7 @@ layout (std140) uniform ub_world_lighting
    float g_water_fog;
    int g_light_count;
    int g_light_preview;
+   int g_shadow_samples;
 };
 
 uniform sampler2D g_world_depth;
@@ -73,6 +74,11 @@ vec3 do_light_shadowing_old( vec3 vfrag )
 
 vec3 do_light_shadowing( vec3 vfrag )
 {
+   if( g_shadow_samples == 0 )
+   {
+      return vfrag;
+   }
+
    float fspread = g_light_colours[0].w;
    vec3  vdir = g_light_directions[0].xyz;
    float flength = g_light_directions[0].w;
index 8b7dbf416b00c9b3871f2a53b96f05973ec74d40..3c17cbb628280023113fcdf2c814a27f818b89d8 100644 (file)
@@ -64,6 +64,7 @@ static struct vg_shader _shader_gpos = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -128,6 +129,11 @@ static struct vg_shader _shader_gpos = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 271a47f328d68575499328749e9b37d58aa52e09..6ee4761560e7649bdc36843292e987517c58eb3f 100644 (file)
@@ -67,6 +67,7 @@ static struct vg_shader _shader_route = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -131,6 +132,11 @@ static struct vg_shader _shader_route = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index eea32ee1d651dfcbf1a03a8550c4e80e2c4a291e..0a4bc959149ff4e30648483a80f01b8026aa408f 100644 (file)
@@ -85,6 +85,7 @@ static struct vg_shader _shader_scoretext = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -149,6 +150,11 @@ static struct vg_shader _shader_scoretext = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index ac052b0d935f5e4042e1dff2b5be57a8162e7c71..4f6a629bdc26e8d1d545de7175a0ed263c219639 100644 (file)
@@ -67,6 +67,7 @@ static struct vg_shader _shader_standard = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -131,6 +132,11 @@ static struct vg_shader _shader_standard = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 92143b1aaef9e67f50b33a661513ae019791efbb..24eb0ea61bc89fae77af80ebf0ef2ec878e2a8e8 100644 (file)
@@ -68,6 +68,7 @@ static struct vg_shader _shader_terrain = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -132,6 +133,11 @@ static struct vg_shader _shader_terrain = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 61b0ccec1b77eef911b69f4e3d443b10509ba94c..0364f658d657e85a0477abeafbfdb2d23c50e4ce 100644 (file)
@@ -66,6 +66,7 @@ static struct vg_shader _shader_vblend = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -130,6 +131,11 @@ static struct vg_shader _shader_vblend = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 8e6b8fc73beb9a8e6998cd415275ab19a238fd9f..0cd026d9481827fa6f52584323a2994bbd975781 100644 (file)
@@ -75,6 +75,7 @@ static struct vg_shader _shader_viewchar = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -139,6 +140,11 @@ static struct vg_shader _shader_viewchar = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index e334a5c74e38d635a6b519261f69369104a6cde7..a333516e453f3db277b8970a0707e2691b06d8e5 100644 (file)
@@ -74,6 +74,7 @@ static struct vg_shader _shader_water = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -138,6 +139,11 @@ static struct vg_shader _shader_water = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index 7b92ea8a94a486d9e08e4870f2686deec30c8d04..415d477be5759e2aa4a3828ed3183b1a2b0a6817 100644 (file)
@@ -71,6 +71,7 @@ static struct vg_shader _shader_water_fast = {
 "   float g_water_fog;\n"
 "   int g_light_count;\n"
 "   int g_light_preview;\n"
+"   int g_shadow_samples;\n"
 "};\n"
 "\n"
 "uniform sampler2D g_world_depth;\n"
@@ -135,6 +136,11 @@ static struct vg_shader _shader_water_fast = {
 "\n"
 "vec3 do_light_shadowing( vec3 vfrag )\n"
 "{\n"
+"   if( g_shadow_samples == 0 )\n"
+"   {\n"
+"      return vfrag;\n"
+"   }\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"
index e1056218848286f9cec80ad27cad9dc3b6f02de7..91e7e012ababc663c4498cf7d1b8cab5b1eeee00 100644 (file)
@@ -177,8 +177,8 @@ VG_STATIC void render_main_game(void)
     */
 
    int draw_solid = player.is_dead | freecam;
-   
    render_world( vg.pv, camera_mtx );
+
    if( draw_solid )
       draw_player( camera_mtx );
 
index 9ee1e6beb3329d7403f4602a8f3fe5d33d87271e..147c9af489eb2be321b6f40249e65d4ff1fa3671 100644 (file)
@@ -36,6 +36,9 @@ VG_STATIC void world_add_all_if_material( m4x3f transform, scene *pscene,
 /* Sprinkle foliage models over the map on terrain material */
 VG_STATIC void world_apply_procedural_foliage( struct world_material *mat )
 {
+   if( vg.quality_profile == k_quality_profile_low )
+      return;
+
    vg_linear_clear( vg_mem.scratch );
 
    mdl_context *mfoliage =