From 0dfcde3fde6d35593fd8a13ac00a233fd8c2058c Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Mon, 25 Sep 2023 19:54:51 +0200 Subject: [PATCH] Fix: EEVEE-Next: Ensure volume property textures are cleared Clear volume property textures when there's no valid world volume shader. Pull Request: https://projects.blender.org/blender/blender/pulls/112871 --- .../draw/engines/eevee_next/eevee_pipeline.cc | 16 +++++++++++----- .../draw/engines/eevee_next/eevee_pipeline.hh | 6 ++++++ .../draw/engines/eevee_next/eevee_volume.cc | 7 +++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 42e71dcd04f..e340842f4a6 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -114,17 +114,18 @@ void WorldPipeline::render(View &view) void WorldVolumePipeline::sync(GPUMaterial *gpumat) { + is_valid_ = GPU_material_status(gpumat) == GPU_MAT_SUCCESS; + if (!is_valid_) { + /* Skip if the material has not compiled yet. */ + return; + } + world_ps_.init(); world_ps_.state_set(DRW_STATE_WRITE_COLOR); inst_.bind_uniform_data(&world_ps_); inst_.volume.bind_properties_buffers(world_ps_); inst_.sampling.bind_resources(&world_ps_); - if (GPU_material_status(gpumat) != GPU_MAT_SUCCESS) { - /* Skip if the material has not compiled yet. */ - return; - } - world_ps_.material_set(*inst_.manager, gpumat); volume_sub_pass(world_ps_, nullptr, nullptr, gpumat); @@ -135,6 +136,11 @@ void WorldVolumePipeline::sync(GPUMaterial *gpumat) void WorldVolumePipeline::render(View &view) { + if (!is_valid_) { + /* Skip if the material has not compiled yet. */ + return; + } + inst_.manager->submit(world_ps_, view); } diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh index e51b48743b3..99ed35a637e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh @@ -80,6 +80,7 @@ class WorldPipeline { class WorldVolumePipeline { private: Instance &inst_; + bool is_valid_; PassSimple world_ps_ = {"World.Volume"}; @@ -88,6 +89,11 @@ class WorldVolumePipeline { void sync(GPUMaterial *gpumat); void render(View &view); + + bool is_valid() + { + return is_valid_; + } }; /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.cc b/source/blender/draw/engines/eevee_next/eevee_volume.cc index 2fb1c22e9de..f0bc38ba7ab 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_volume.cc @@ -241,6 +241,13 @@ void VolumeModule::end_sync() prop_emission_tx_.ensure_3d(GPU_R11F_G11F_B10F, data_.tex_size, usage); prop_phase_tx_.ensure_3d(GPU_RG16F, data_.tex_size, usage); + if (!inst_.pipelines.world_volume.is_valid()) { + prop_scattering_tx_.clear(float4(0.0f)); + prop_extinction_tx_.clear(float4(0.0f)); + prop_emission_tx_.clear(float4(0.0f)); + prop_phase_tx_.clear(float4(0.0f)); + } + scatter_tx_.ensure_3d(GPU_R11F_G11F_B10F, data_.tex_size, usage); extinction_tx_.ensure_3d(GPU_R11F_G11F_B10F, data_.tex_size, usage);