+ f32 greyout = 0.0f;
+ if( mdl_entity_id_type(world_static.focused_entity) == k_ent_challenge )
+ greyout = world_static.focus_strength;
+
+ if( greyout > 0.0f ){
+ glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
+ shader_blitcolour_use();
+ shader_blitcolour_uColour( (v4f){ 0.5f, 0.5f, 0.5f, greyout*0.56f } );
+ render_fsquad();
+
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+ glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0,
+ GL_COLOR_ATTACHMENT1 } );
+ }
+
+ render_world_fxglow( world, cam, layer_depth );
+}
+
+
+static
+void render_world_override_pass( world_instance *world,
+ struct world_pass *pass ){
+ for( int i=0; i<world->surface_count; i++ ){
+ struct world_surface *mat = &world->surfaces[i];
+
+ if( mat->info.flags & k_material_flag_ghosts ) continue;
+
+ mdl_submesh *sm;
+ if( pass->geo_type == k_world_geo_type_solid )
+ sm = &mat->sm_geo;
+ else
+ sm = &mat->sm_no_collide;
+
+ if( !sm->indice_count )
+ continue;
+
+ m4x3f mmdl;
+ m4x3_identity( mmdl );
+ pass->fn_set_mdl( mmdl );
+ pass->fn_set_uPvmPrev( pass->cam->mtx_prev.pv );
+ pass->fn_bind_textures( world, mat );
+ mdl_draw_submesh( sm );
+ }
+}
+
+static void render_world_override( world_instance *world ){
+ struct world_pass pass = {
+ .cam = &skaterift.cam,
+ .fn_bind_textures = bindpoint_override,
+ .fn_set_mdl = shader_scene_override_uMdl,
+ .fn_set_uPvmPrev = shader_scene_override_uPvmPrev,
+ .shader = k_shader_override
+ };
+
+ shader_scene_override_use();
+ respawn_chooser_shader_uniforms();
+ shader_scene_override_uTexGarbage(0);
+ shader_scene_override_uTexMain(1);
+ shader_scene_override_uPv( pass.cam->mtx.pv );
+
+ world_link_lighting_ub( world, _shader_scene_override.id );
+ world_bind_position_texture( world, _shader_scene_override.id,
+ _uniform_scene_override_g_world_depth, 2 );
+ world_bind_light_array( world, _shader_scene_override.id,
+ _uniform_scene_override_uLightsArray, 3 );
+ world_bind_light_index( world, _shader_scene_override.id,
+ _uniform_scene_override_uLightsIndex, 4 );
+
+ bind_terrain_noise();
+ shader_scene_override_uCamera( pass.cam->transform[3] );
+
+ glDisable( GL_CULL_FACE );
+ mesh_bind( &world->mesh_geo );
+ pass.geo_type = k_world_geo_type_solid;
+ render_world_override_pass( world, &pass );
+ mesh_bind( &world->mesh_no_collide );
+ pass.geo_type = k_world_geo_type_nonsolid;
+ render_world_override_pass( world, &pass );
+ glEnable( GL_CULL_FACE );
+}
+
+static void render_cubemap_side( world_instance *world, ent_cubemap *cm,
+ u32 side ){
+ camera cam;
+ glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X + side, cm->texture_id, 0 );
+ glClear( GL_DEPTH_BUFFER_BIT );
+
+ v3f forward[6] = {
+ { -1.0f, 0.0f, 0.0f },
+ { 1.0f, 0.0f, 0.0f },
+ { 0.0f, -1.0f, 0.0f },
+ { 0.0f, 1.0f, 0.0f },
+ { 0.0f, 0.0f, -1.0f },
+ { 0.0f, 0.0f, 1.0f }
+ };
+ v3f up[6] = {
+ { 0.0f, -1.0f, 0.0f },
+ { 0.0f, -1.0f, 0.0f },
+ { 0.0f, 0.0f, 1.0f },
+ { 0.0f, 0.0f, -1.0f },
+ { 0.0f, -1.0f, 0.0f },
+ { 0.0f, -1.0f, 0.0f }
+ };
+
+ v3_zero( cam.angles );
+ v3_copy( cm->co, cam.pos );
+
+ v3_copy( forward[side], cam.transform[2] );
+ v3_copy( up[side], cam.transform[1] );
+ v3_cross( up[side], forward[side], cam.transform[0] );
+ v3_copy( cm->co, cam.transform[3] );
+ m4x3_invert_affine( cam.transform, cam.transform_inverse );
+
+ camera_update_view( &cam );
+
+ cam.nearz = 0.1f;
+ cam.farz = 1000.0f;
+ cam.fov = 90.0f;
+ m4x4_copy( cam.mtx.p, cam.mtx_prev.p );
+ m4x4_projection( cam.mtx.p, cam.fov, 1.0f, cam.nearz, cam.farz );
+ camera_finalize( &cam );
+ camera_finalize( &cam );
+
+ render_world( world, &cam, -1 );
+}
+
+static void render_world_cubemaps( world_instance *world ){
+ if( world->cubemap_cooldown )
+ world->cubemap_cooldown --;
+ else{
+ world->cubemap_cooldown = 60;
+
+ glViewport( 0, 0, WORLD_CUBEMAP_RES, WORLD_CUBEMAP_RES );
+ for( u32 i=0; i<mdl_arrcount( &world->ent_cubemap ); i++ ){
+ ent_cubemap *cm = mdl_arritm( &world->ent_cubemap, i );
+ glBindFramebuffer( GL_FRAMEBUFFER, cm->framebuffer_id );
+
+ world->cubemap_side ++;
+ if( world->cubemap_side >= 6 )
+ world->cubemap_side = 0;
+
+ render_cubemap_side( world, cm, world->cubemap_side );
+ }