WIP: eevee-next-world-irradiance #108304
|
@ -494,6 +494,8 @@ void Instance::light_bake_irradiance(
|
|||
for (int bounce = 0; bounce <= bounce_len; bounce++) {
|
||||
/* Last iteration only captures lighting. */
|
||||
const bool is_last_bounce = (bounce == bounce_len);
|
||||
/* First bounce includes world lighting. */
|
||||
const bool is_first_bounce = bounce == 0;
|
||||
|
||||
sampling.init(scene);
|
||||
while (!sampling.finished()) {
|
||||
|
@ -505,7 +507,7 @@ void Instance::light_bake_irradiance(
|
|||
|
||||
irradiance_cache.bake.raylists_build();
|
||||
if (!is_last_bounce) {
|
||||
irradiance_cache.bake.propagate_light();
|
||||
irradiance_cache.bake.propagate_light(is_first_bounce);
|
||||
}
|
||||
if (is_last_bounce) {
|
||||
irradiance_cache.bake.irradiance_capture();
|
||||
|
|
|
@ -443,15 +443,20 @@ void IrradianceBake::sync()
|
|||
sub.dispatch(&dispatch_per_list_);
|
||||
}
|
||||
}
|
||||
{
|
||||
PassSimple &pass = surfel_light_propagate_ps_;
|
||||
for (int pass_index : IndexRange(2)) {
|
||||
PassSimple &pass = surfel_light_propagate_ps_[pass_index];
|
||||
pass.init();
|
||||
{
|
||||
PassSimple::Sub &sub = pass.sub("RayEval");
|
||||
sub.shader_set(inst_.shaders.static_shader_get(SURFEL_RAY));
|
||||
sub.bind_ssbo(SURFEL_BUF_SLOT, &surfels_buf_);
|
||||
sub.bind_ssbo(CAPTURE_BUF_SLOT, &capture_info_buf_);
|
||||
inst_.reflection_probes.bind_resources(&sub);
|
||||
if (pass_index == 0) {
|
||||
inst_.reflection_probes.bind_resources(&sub);
|
||||
}
|
||||
else {
|
||||
inst_.reflection_probes.bind_dummy_resources(&sub);
|
||||
}
|
||||
sub.barrier(GPU_BARRIER_SHADER_STORAGE);
|
||||
sub.dispatch(&dispatch_per_surfel_);
|
||||
}
|
||||
|
@ -722,9 +727,10 @@ void IrradianceBake::raylists_build()
|
|||
inst_.manager->submit(surfel_ray_build_ps_, ray_view_);
|
||||
}
|
||||
|
||||
void IrradianceBake::propagate_light()
|
||||
void IrradianceBake::propagate_light(bool first_bounce)
|
||||
{
|
||||
inst_.manager->submit(surfel_light_propagate_ps_, ray_view_);
|
||||
PassSimple &pass = surfel_light_propagate_ps_[first_bounce ? 0 : 1];
|
||||
inst_.manager->submit(pass, ray_view_);
|
||||
}
|
||||
|
||||
void IrradianceBake::irradiance_capture()
|
||||
|
|
|
@ -44,7 +44,7 @@ class IrradianceBake {
|
|||
/** Create linked list of surfel to emulated raycast. */
|
||||
PassSimple surfel_ray_build_ps_ = {"RayBuild"};
|
||||
/** Propagate light from surfel to surfel. */
|
||||
PassSimple surfel_light_propagate_ps_ = {"LightPropagate"};
|
||||
PassSimple surfel_light_propagate_ps_[2] = {{"LightPropagateFirstBounce"}, {"LightPropagate"}};
|
||||
/** Start of a light bounce. Accumulate light from previous propagation. */
|
||||
PassSimple surfel_light_bounce_ps_ = {"LightBounce"};
|
||||
/** Capture surfel lighting to irradiance samples. */
|
||||
|
@ -108,7 +108,7 @@ class IrradianceBake {
|
|||
/** Create a surfel lists to emulate ray-casts for the current sample random direction. */
|
||||
void raylists_build();
|
||||
/** Propagate light from surfel to surfel in a random direction over the sphere. */
|
||||
void propagate_light();
|
||||
void propagate_light(bool first_bounce);
|
||||
/** Store surfel irradiance inside the irradiance grid samples. */
|
||||
void irradiance_capture();
|
||||
/** Accumulate light inside `surfel.radiance_bounce` to `surfel.radiance`. */
|
||||
|
|
|
@ -24,6 +24,11 @@ void ReflectionProbeModule::init()
|
|||
NULL,
|
||||
12);
|
||||
GPU_texture_mipmap_mode(cubemaps_tx_, true, true);
|
||||
|
||||
dummy_tx_.ensure_cube_array(
|
||||
GPU_RGBA16F, 1, 1, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT, NULL, 1);
|
||||
dummy_tx_.clear(float4(0.0f));
|
||||
GPU_texture_mipmap_mode(dummy_tx_, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class ReflectionProbeModule {
|
|||
|
||||
Vector<ReflectionProbe> cubemaps_;
|
||||
Texture cubemaps_tx_ = {"Probes"};
|
||||
Texture dummy_tx_ = {"DummyProbes"};
|
||||
|
||||
public:
|
||||
ReflectionProbeModule(Instance &instance) : instance_(instance) {}
|
||||
|
@ -80,6 +81,11 @@ class ReflectionProbeModule {
|
|||
pass->bind_texture(REFLECTION_PROBE_TEX_SLOT, cubemaps_tx_);
|
||||
}
|
||||
|
||||
template<typename T> void bind_dummy_resources(draw::detail::PassBase<T> *pass)
|
||||
{
|
||||
pass->bind_texture(REFLECTION_PROBE_TEX_SLOT, dummy_tx_);
|
||||
}
|
||||
|
||||
private:
|
||||
void sync(const ReflectionProbe &cubemap);
|
||||
|
||||
|
|
Loading…
Reference in New Issue