Repository: godotengine/godot
File: servers/rendering/renderer_rd/environment/sky.cpp (C++)

Code before:
			}

			float fog_detail_spread = fog->spread; // Reverse lookup.
			if (fog_detail_spread > 0.0) {
				sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0 / fog_detail_spread;
			} else {
				sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0;
			}

			sky_scene_state.fog_uniform_set = fog->sky_uniform_set;
		}
	}

	Projection correction;
	correction.add_jitter_offset(p_jitter);

	sky_scene_state.view_count = p_view_count;
	sky_scene_state.cam_transform = p_cam_transform;
	sky_scene_state.cam_projection = correction * p_cam_projection; // We only use this when rendering a single view.

	// Our info in our UBO is only used if we're rendering stereo.
	for (uint32_t i = 0; i < p_view_count; i++) {
		Projection view_inv_projection = (correction * p_view_projections[i]).inverse();
		if (p_view_count > 1) {
			RendererRD::MaterialStorage::store_camera(p_cam_projection * view_inv_projection, sky_scene_state.ubo.combined_reprojection[i]);
		} else {
			Projection ident;
			RendererRD::MaterialStorage::store_camera(correction, sky_scene_state.ubo.combined_reprojection[i]);
		}

		RendererRD::MaterialStorage::store_camera(view_inv_projection, sky_scene_state.ubo.view_inv_projections[i]);
		sky_scene_state.ubo.view_eye_offsets[i][0] = p_view_eye_offsets[i].x;
		sky_scene_state.ubo.view_eye_offsets[i][1] = p_view_eye_offsets[i].y;
		sky_scene_state.ubo.view_eye_offsets[i][2] = p_view_eye_offsets[i].z;
		sky_scene_state.ubo.view_eye_offsets[i][3] = 0.0;
	}

	sky_scene_state.ubo.z_far = p_view_projections[0].get_z_far(); // Should be the same for all projection.
	sky_scene_state.ubo.fog_enabled = RendererSceneRenderRD::get_singleton()->environment_get_fog_enabled(p_env);
	sky_scene_state.ubo.fog_density = RendererSceneRenderRD::get_singleton()->environment_get_fog_density(p_env);
	sky_scene_state.ubo.fog_aerial_perspective = RendererSceneRenderRD::get_singleton()->environment_get_fog_aerial_perspective(p_env);
	Color fog_color = RendererSceneRenderRD::get_singleton()->environment_get_fog_light_color(p_env).srgb_to_linear();
	float fog_energy = RendererSceneRenderRD::get_singleton()->environment_get_fog_light_energy(p_env);
	sky_scene_state.ubo.fog_light_color[0] = fog_color.r * fog_energy;
	sky_scene_state.ubo.fog_light_color[1] = fog_color.g * fog_energy;
	sky_scene_state.ubo.fog_light_color[2] = fog_color.b * fog_energy;
	sky_scene_state.ubo.fog_sun_scatter = RendererSceneRenderRD::get_singleton()->environment_get_fog_sun_scatter(p_env);

	sky_scene_state.ubo.fog_sky_affect = RendererSceneRenderRD::get_singleton()->environment_get_fog_sky_affect(p_env);
	sky_scene_state.ubo.volumetric_fog_sky_affect = RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_sky_affect(p_env);


Review comment (suggestion):
```suggestion
			// Reprojection is used when we need to have things in combined space.
```

Code after:
			}

			float fog_detail_spread = fog->spread; // Reverse lookup.
			if (fog_detail_spread > 0.0) {
				sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0 / fog_detail_spread;
			} else {
				sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0;
			}

			sky_scene_state.fog_uniform_set = fog->sky_uniform_set;
		}
	}

	Projection correction;
	correction.set_depth_correction(false, true);
	correction.add_jitter_offset(p_jitter);

	sky_scene_state.view_count = p_view_count;
	sky_scene_state.cam_transform = p_cam_transform;
	sky_scene_state.cam_projection = correction * p_cam_projection; // We only use this when rendering a single view.

	// Our info in our UBO is only used if we're rendering stereo.
	for (uint32_t i = 0; i < p_view_count; i++) {
		Projection view_inv_projection = (correction * p_view_projections[i]).inverse();
		if (p_view_count > 1) {
			// Reprojection is used when we need to have things in combined space.
			RendererRD::MaterialStorage::store_camera(p_cam_projection * view_inv_projection, sky_scene_state.ubo.combined_reprojection[i]);
		} else {
			// This is unused so just reset to identity.
			Projection ident;
			RendererRD::MaterialStorage::store_camera(ident, sky_scene_state.ubo.combined_reprojection[i]);
		}

		RendererRD::MaterialStorage::store_camera(view_inv_projection, sky_scene_state.ubo.view_inv_projections[i]);
		sky_scene_state.ubo.view_eye_offsets[i][0] = p_view_eye_offsets[i].x;
		sky_scene_state.ubo.view_eye_offsets[i][1] = p_view_eye_offsets[i].y;
		sky_scene_state.ubo.view_eye_offsets[i][2] = p_view_eye_offsets[i].z;
		sky_scene_state.ubo.view_eye_offsets[i][3] = 0.0;
	}

	sky_scene_state.ubo.z_far = p_view_projections[0].get_z_far(); // Should be the same for all projection.
	sky_scene_state.ubo.fog_enabled = RendererSceneRenderRD::get_singleton()->environment_get_fog_enabled(p_env);
	sky_scene_state.ubo.fog_density = RendererSceneRenderRD::get_singleton()->environment_get_fog_density(p_env);
	sky_scene_state.ubo.fog_aerial_perspective = RendererSceneRenderRD::get_singleton()->environment_get_fog_aerial_perspective(p_env);
	Color fog_color = RendererSceneRenderRD::get_singleton()->environment_get_fog_light_color(p_env).srgb_to_linear();
	float fog_energy = RendererSceneRenderRD::get_singleton()->environment_get_fog_light_energy(p_env);
	sky_scene_state.ubo.fog_light_color[0] = fog_color.r * fog_energy;
	sky_scene_state.ubo.fog_light_color[1] = fog_color.g * fog_energy;
	sky_scene_state.ubo.fog_light_color[2] = fog_color.b * fog_energy;
	sky_scene_state.ubo.fog_sun_scatter = RendererSceneRenderRD::get_singleton()->environment_get_fog_sun_scatter(p_env);