medfall

A super great game engine
Log | Files | Refs

commit a7a6d64a3f4a4a6a486d3412d9c92286631ee554
parent 849d34a0f7892d76e4680d442f394093fa52f6e6
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Aug 28 19:34:29 +0100

No more variable bias

Diffstat:
shaders/shadowed_vertex_colours.glsl | 3+--
shadow_map.cc | 15+++++----------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/shaders/shadowed_vertex_colours.glsl b/shaders/shadowed_vertex_colours.glsl @@ -15,7 +15,6 @@ layout( std140 ) uniform light_view { layout( std140 ) uniform v_cold { vec3 light_pos; - float bias; }; uniform sampler2D shadowmap; @@ -79,7 +78,7 @@ void main() { for( int y = -1; y <= 1; y++ ) { vec2 offset = vec2( x, y ) * inv_shadowmap_size; float shadow_depth = texture( shadowmap, light_norm.xy + offset ).r; - if( light_norm.z - bias2 <= shadow_depth ) { + if( light_norm.z - bias <= shadow_depth ) { shadow += 1.0 / 9.0; } } diff --git a/shadow_map.cc b/shadow_map.cc @@ -17,13 +17,11 @@ static Mesh square; static UB ub_model; static UB ub_light_view; static UB ub_view; -static UB ub_light_pos_bias; +static UB ub_light; static FB shadow_fb; static Mesh tree_mesh; static Texture blue_noise; -static float bias = 0.00005f; - static const u32 SHADOW_SIZE = 1024; static v3 light_pos( -0, -10, 15 ); @@ -68,7 +66,7 @@ GAME_INIT( game_init ) { ub_model = renderer_new_ub(); ub_light_view = renderer_new_ub(); ub_view = renderer_new_ub(); - ub_light_pos_bias = renderer_new_ub(); + ub_light = renderer_new_ub(); { TextureConfig config; @@ -169,14 +167,12 @@ GAME_FRAME( game_frame ) { } // draw world - bias += ( input->keys[ KEY_EQUALS ] - input->keys[ KEY_MINUS ] ) * 0.00001f; - bias = max( bias, 0.0f ); { - renderer_ub_easy( ub_light_pos_bias, light_pos, bias ); + renderer_ub_easy( ub_light, light_pos ); RenderState render_state; render_state.shader = get_shader( SHADER_SHADOWED_VERTEX_COLOURS ); - render_state.ubs[ UB_VS_COLD ] = ub_light_pos_bias; + render_state.ubs[ UB_VS_COLD ] = ub_light; render_state.ubs[ UB_MODEL ] = ub_model; render_state.ubs[ UB_VIEW ] = ub_view; render_state.ubs[ UB_LIGHT_VIEW ] = ub_light_view; @@ -187,8 +183,7 @@ GAME_FRAME( game_frame ) { } { - const str< 128 > status( "Frame time: {.1}ms FPS: {.1} bias = {}", - dt * 1000.0f, 1.0f / dt, bias ); + const str< 128 > status( "Frame time: {.1}ms FPS: {.1}", dt * 1000.0f, 1.0f / dt ); draw_text( status.c_str(), 2.0f, 2.0f, 16.0f ); } }