shader vacuuming
[carveJwlIkooP6JGAAIwe30JlM.git] / world_gen.h
index 2b2ba57d91b2eaa4ece165ec559d0f4765d9ff8b..5cfc9d102af3a94996e032ac177193ffc7ff4836 100644 (file)
@@ -596,6 +596,36 @@ VG_STATIC void world_post_process( world_instance *world )
 
    vg_acquire_thread_sync();
    {
+      /* Upload lighting uniform buffer */
+      if( world->water.enabled )
+         v4_copy( world->water.plane, world->ub_lighting.g_water_plane );
+
+      v4f info_vec;
+      v3f *bounds = world->scene_geo->bbx;
+
+      info_vec[0] = bounds[0][0];
+      info_vec[1] = bounds[0][2];
+      info_vec[2] = 1.0f/ (bounds[1][0]-bounds[0][0]);
+      info_vec[3] = 1.0f/ (bounds[1][2]-bounds[0][2]);
+      v4_copy( info_vec, world->ub_lighting.g_depth_bounds );
+
+      /* add scene lights */
+      for( int i=0; i<world->light_count; i++ )
+      {
+         struct world_light *light = &world->lights[i];
+
+         v3_muls( light->colour, light->colour[3] * 2.0f,
+                  world->ub_lighting.g_point_light_colours[i] );
+         v3_copy( light->co, 
+                  world->ub_lighting.g_point_light_positions[i] );
+      }
+
+      /* upload full buffer */
+      glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
+      glBufferSubData( GL_UNIFORM_BUFFER, 0, 
+                       sizeof(struct ub_world_lighting), &world->ub_lighting );
+
+
       /* 
        * Rendering the depth map
        */
@@ -634,39 +664,11 @@ VG_STATIC void world_post_process( world_instance *world )
       glBlendFunc(GL_ONE, GL_ONE);
       glBlendEquation(GL_MAX);
 
-      render_world_depth( world, &ortho );
+      render_world_position( world, &ortho );
       glDisable(GL_BLEND);
       glEnable(GL_DEPTH_TEST);
       glBindFramebuffer( GL_FRAMEBUFFER, 0 );
 
-      /* Upload lighting uniform buffer */
-      if( world->water.enabled )
-         v4_copy( world->water.plane, world->ub_lighting.g_water_plane );
-
-      v4f info_vec;
-      v3f *bounds = world->scene_geo->bbx;
-
-      info_vec[0] = bounds[0][0];
-      info_vec[1] = bounds[0][2];
-      info_vec[2] = 1.0f/ (bounds[1][0]-bounds[0][0]);
-      info_vec[3] = 1.0f/ (bounds[1][2]-bounds[0][2]);
-      v4_copy( info_vec, world->ub_lighting.g_depth_bounds );
-
-      /* add scene lights */
-      for( int i=0; i<world->light_count; i++ )
-      {
-         struct world_light *light = &world->lights[i];
-
-         v3_muls( light->colour, light->colour[3] * 2.0f,
-                  world->ub_lighting.g_point_light_colours[i] );
-         v3_copy( light->co, 
-                  world->ub_lighting.g_point_light_positions[i] );
-      }
-
-      /* upload full buffer */
-      glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
-      glBufferSubData( GL_UNIFORM_BUFFER, 0, 
-                       sizeof(struct ub_world_lighting), &world->ub_lighting );
    }
 
    vg_release_thread_sync();