EEVEE Next: Volumes: Lighting integration improvements #110809

Merged
Clément Foucault merged 10 commits from pragma37/blender:pull-eevee-next-volumes-2-cleanup into main 2023-09-06 14:36:06 +02:00
6 changed files with 15 additions and 8 deletions
Showing only changes of commit b4d4c0a905 - Show all commits

View File

@ -109,6 +109,7 @@ void Instance::init_light_bake(Depsgraph *depsgraph, draw::Manager *manager)
/* Irradiance Cache needs reflection probes to be initialized. */
reflection_probes.init();
irradiance_cache.init();
volume.init();
}
void Instance::set_time(float time)

View File

@ -252,6 +252,7 @@ void VolumeModule::end_sync()
scatter_ps_.shader_set(inst_.shaders.static_shader_get(
data_.use_lights ? VOLUME_SCATTER_WITH_LIGHTS : VOLUME_SCATTER));
inst_.lights.bind_resources(&scatter_ps_);
inst_.irradiance_cache.bind_resources(&scatter_ps_);
inst_.shadows.bind_resources(&scatter_ps_);
inst_.sampling.bind_resources(&scatter_ps_);
scatter_ps_.bind_image("in_scattering_img", &prop_scattering_tx_);

View File

@ -6,6 +6,7 @@
* - irradiance_atlas_tx
*/
#pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl)
fclem marked this conversation as resolved Outdated

Not sure what this has to do with the patch.

Not sure what this has to do with the patch.

It's simply that gpu_shader_codegen_lib is required by eevee_lightprobe_eval_lib, since it needs the Closure structs declared.
I think it's best if files handle their own dependencies, unless there's a good reason not to do so.
If that's the case the import could be moved to eevee_volume_scatter_comp.

It's simply that `gpu_shader_codegen_lib` is required by `eevee_lightprobe_eval_lib`, since it needs the Closure structs declared. I think it's best if files handle their own dependencies, unless there's a good reason not to do so. If that's the case the import could be moved to `eevee_volume_scatter_comp`.

Ok fine then.

Ok fine then.
#pragma BLENDER_REQUIRE(eevee_lightprobe_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_spherical_harmonics_lib.glsl)

View File

@ -169,15 +169,14 @@ vec3 volume_shadow(LightData ld, vec3 ray_wpos, vec3 L, float l_dist)
#endif /* VOLUME_SHADOW */
}
vec3 volume_irradiance(vec3 wpos)
vec3 volume_irradiance(vec3 P)
{
#ifdef IRRADIANCE_HL2
IrradianceData ir_data = load_irradiance_cell(0, vec3(1.0));
vec3 irradiance = ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
ir_data = load_irradiance_cell(0, vec3(-1.0));
irradiance += ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
irradiance *= 0.16666666; /* 1/6 */
return irradiance;
#ifdef VOLUME_IRRADIANCE
/* Skip normal and view bias. */
SphericalHarmonicL1 irradiance = lightprobe_irradiance_sample(
irradiance_atlas_tx, P, vec3(0.0), vec3(0.0));
return irradiance.L0.M0.rgb * M_PI;
#else
return vec3(0.0);
#endif

View File

@ -1,4 +1,8 @@
#pragma BLENDER_REQUIRE(gpu_shader_math_vector_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
/* Included here to avoid requiring lightprobe resources for all volume lib users. */
#pragma BLENDER_REQUIRE(eevee_lightprobe_eval_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_volume_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_sampling_lib.glsl)

View File

@ -39,6 +39,7 @@ GPU_SHADER_CREATE_INFO(eevee_volume_scatter)
.additional_info("draw_resource_id_varying")
.additional_info("draw_view")
.additional_info("eevee_light_data")
.additional_info("eevee_lightprobe_data")
.additional_info("eevee_shadow_data")
.additional_info("eevee_sampling_data")
.compute_source("eevee_volume_scatter_comp.glsl")