- glUnmapBuffer( GL_TEXTURE_BUFFER );
-
- glGenTextures( 1, &world->tex_light_entities );
- glBindTexture( GL_TEXTURE_BUFFER, world->tex_light_entities );
- glTexBuffer( GL_TEXTURE_BUFFER, GL_RGBA32F, world->tbo_light_entities );
-
-
- /* 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 );
-
- /* 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
- */
- camera ortho;
-
- v3f extent;
- v3_sub( world->scene_geo->bbx[1], world->scene_geo->bbx[0], extent );
-
- float fl = world->scene_geo->bbx[0][0],
- fr = world->scene_geo->bbx[1][0],
- fb = world->scene_geo->bbx[0][2],
- ft = world->scene_geo->bbx[1][2],
- rl = 1.0f / (fr-fl),
- tb = 1.0f / (ft-fb);
-
- m4x4_zero( ortho.mtx.p );
- ortho.mtx.p[0][0] = 2.0f * rl;
- ortho.mtx.p[2][1] = 2.0f * tb;
- ortho.mtx.p[3][0] = (fr + fl) * -rl;
- ortho.mtx.p[3][1] = (ft + fb) * -tb;
- ortho.mtx.p[3][3] = 1.0f;
- m4x3_identity( ortho.transform );
- camera_update_view( &ortho );
- camera_finalize( &ortho );
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_CULL_FACE);
- render_fb_bind( &world->heightmap );
- shader_blitcolour_use();
- shader_blitcolour_uColour( (v4f){-9999.0f,-9999.0f,-9999.0f,-9999.0f} );
- render_fsquad();
-
- /* todo: hmm?? */
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- glBlendEquation(GL_MAX);
-
- render_world_position( world, &ortho );
- glDisable(GL_BLEND);
- glEnable(GL_DEPTH_TEST);
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-
- }
-
- vg_release_thread_sync();
-
-#if 0
- /*
- * Setup scene collider
- */
- reset_player( 1, (const char *[]){"start"} );
-#endif
-}
-
-VG_STATIC void world_process_resources( world_instance *world )
-{
- vg_info( "Loading textures\n" );
- world->texture_count = world->meta->info.texture_count;
- world->textures = vg_linear_alloc( world_global.generic_heap,
- sizeof(GLuint)*world->texture_count );
-
- vg_acquire_thread_sync();
- {
- /* error texture */
- world->textures[0] = vg_tex2d_new();
- vg_tex2d_set_error();
- vg_tex2d_nearest();
- vg_tex2d_repeat();
-
- for( int i=1; i<world->texture_count; i++ )
- {
- mdl_texture *tex = &world->meta->texture_buffer[i];
-
- if( !tex->pack_offset )
- {
- vg_release_thread_sync();
- vg_fatal_exit_loop( "World models must have packed textures!" );
- }