medfall

A super great game engine
Log | Files | Refs

commit eb6fe36ad0d6a80f245ceb3080aab457d16bdaac
parent b97a41cd27e31c9c7cac8452301c6ab0e5e3b13f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Sep  3 22:23:34 +0300

Remove the v_cold UBO

Diffstat:
renderer.cc | 2+-
renderer.h | 13++++++-------
shaders/shadowed_vertex_colours.glsl | 8++------
shaders/write_shadow_map.glsl | 6+++---
shadow_map.cc | 3+--
5 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/renderer.cc b/renderer.cc @@ -545,7 +545,7 @@ Shader renderer_new_shader( ShaderConfig config ) { return INVALID_SHADER; } - const char * ubo_names[] = { "v_cold", "view", "model", "light_view", "window", "sun", "sky" }; + const char * ubo_names[] = { "view", "model", "light_view", "window", "sun", "sky" }; for( GLuint i = 0; i < ARRAY_COUNT( ubo_names ); i++ ) { GLuint idx = glGetUniformBlockIndex( program, ubo_names[ i ] ); if( idx != GL_INVALID_INDEX ) { diff --git a/renderer.h b/renderer.h @@ -15,13 +15,12 @@ typedef u32 Texture; typedef u32 TextureBufferObject; typedef u32 FramebufferObject; -const u32 UNIFORM_VS_COLD = 0; -const u32 UNIFORM_VIEW = 1; -const u32 UNIFORM_MODEL = 2; -const u32 UNIFORM_LIGHT_VIEW = 3; -const u32 UNIFORM_WINDOW = 4; -const u32 UNIFORM_SUN = 5; -const u32 UNIFORM_SKY = 6; +const u32 UNIFORM_VIEW = 0; +const u32 UNIFORM_MODEL = 1; +const u32 UNIFORM_LIGHT_VIEW = 2; +const u32 UNIFORM_WINDOW = 3; +const u32 UNIFORM_SUN = 4; +const u32 UNIFORM_SKY = 5; #define RENDERER_MAX_TEXTURES 4 #define RENDERER_MAX_TEXTURE_BUFFERS 4 diff --git a/shaders/shadowed_vertex_colours.glsl b/shaders/shadowed_vertex_colours.glsl @@ -9,11 +9,7 @@ layout( std140 ) uniform view { }; layout( std140 ) uniform light_view { - mat4 lightV; - mat4 lightP; -}; - -layout( std140 ) uniform v_cold { + mat4 lightVP; vec3 light_pos; }; @@ -38,7 +34,7 @@ out VSOut v2f; void main() { vec4 world_space = M * vec4( position, 1.0 ); gl_Position = P * V * world_space; - v2f.light_space_position = lightP * lightV * world_space; + v2f.light_space_position = lightVP * world_space; v2f.position = world_space.xyz; v2f.normal = mat3( M ) * normal; v2f.colour = colour; diff --git a/shaders/write_shadow_map.glsl b/shaders/write_shadow_map.glsl @@ -7,12 +7,12 @@ layout( std140 ) uniform model { }; layout( std140 ) uniform light_view { - mat4 V; - mat4 P; + mat4 VP; + vec3 light_pos; }; void main() { - gl_Position = P * V * M * vec4( position, 1.0 ); + gl_Position = VP * M * vec4( position, 1.0 ); } #else diff --git a/shadow_map.cc b/shadow_map.cc @@ -129,7 +129,7 @@ GAME_FRAME( game_frame ) { const m4 lightP = m4_perspective( 90, 1, NEAR_PLANE_DEPTH, 500.0f ); m4 lightV = m4_lookat( light_pos, target, world_up ); - light_view_uniforms = renderer_uniforms( lightV, lightP ); + light_view_uniforms = renderer_uniforms( lightP * lightV, light_pos ); } // fill shadow map @@ -160,7 +160,6 @@ GAME_FRAME( game_frame ) { { RenderState render_state; render_state.shader = get_shader( SHADER_SHADOWED_VERTEX_COLOURS ); - render_state.uniforms[ UNIFORM_VS_COLD ] = renderer_uniforms( light_pos ); render_state.uniforms[ UNIFORM_VIEW ] = renderer_uniforms( V, P, game->pos ); render_state.uniforms[ UNIFORM_LIGHT_VIEW ] = light_view_uniforms; render_state.textures[ 0 ] = shadow_fb.texture;