commit 880eb059c952bf96bf7c276d9587ed5c562c2995 parent 97fa632a1b9385dfebd8ea69106f125b416466a6 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Nov 27 11:26:32 +0200 Pass V and P instead of V and VP to terrain_render Diffstat:
hm.cc | | | 3 | +-- |
terrain_manager.cc | | | 16 | ++++++++-------- |
terrain_manager.h | | | 2 | +- |
diff --git a/hm.cc b/hm.cc @@ -271,10 +271,9 @@ extern "C" GAME_FRAME( game_frame ) { m4 P = m4_perspective( 120.0f, ( float ) WIDTH / ( float ) HEIGHT, NEAR_PLANE_DEPTH, FAR_PLANE_DEPTH ); m4 V = camera_to_view( game->pos, game->angles ); - m4 VP = V * P; // TODO: WTF skybox_render( &game->skybox, game->angles, game->test_sun ); - terrain_render( &game->tm, V, VP, game->test_sun, current_time ); + terrain_render( &game->tm, V, P, game->test_sun, current_time ); glDisable( GL_DEPTH_TEST ); glUseProgram( game->test_shader ); diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -20,14 +20,14 @@ static const char * vert_src = GLSL( out vec3 smooth_position; layout( std140 ) uniform v_hot { - mat4 v; - mat4 vp; + mat4 V; + mat4 P; }; void main() { - gl_Position = vp * vec4( position, 1.0 ); + gl_Position = P * V * vec4( position, 1.0 ); smooth_position = position; - vpos = v * vec4( position, 1.0 ); + vpos = V * vec4( position, 1.0 ); } ); @@ -376,8 +376,8 @@ void terrain_update( TerrainManager * tm, v3 position ) { } struct VSData { - m4 v; - m4 vp; + m4 V; + m4 P; }; struct FSData { @@ -385,7 +385,7 @@ struct FSData { float sun; }; -void terrain_render( TerrainManager * tm, m4 V, m4 VP, float sun, double current_time ) { +void terrain_render( TerrainManager * tm, const m4 & V, const m4 & P, float sun, double current_time ) { u32 inited = 0; for( u16 vy = 0; vy < VIEW_SIZE; vy++ ) { for( u16 vx = 0; vx < VIEW_SIZE; vx++ ) { @@ -417,7 +417,7 @@ void terrain_render( TerrainManager * tm, m4 V, m4 VP, float sun, double current } } - VSData vsdata = { V, VP }; + VSData vsdata = { V, P }; FSData fsdata = { v2( TILE_SIZE, TILE_SIZE ), sun }; renderer_ub_data( tm->vertex_uniforms, &vsdata, sizeof( vsdata ) ); diff --git a/terrain_manager.h b/terrain_manager.h @@ -79,7 +79,7 @@ struct TerrainManager { void terrain_init( TerrainManager * tm, const char * tiles_dir, MemoryArena * arena, WorkQueue * background_tasks ); void terrain_teleport( TerrainManager * tm, v3 position ); void terrain_update( TerrainManager * tm, v3 position ); -void terrain_render( TerrainManager * tm, m4 V, m4 VP, float sun, double current_time ); +void terrain_render( TerrainManager * tm, const m4 & V, const m4 & P, float sun, double current_time ); float terrain_height( const TerrainManager * tm, v3 position ); #endif // _TERRAIN_MANAGER_H_