Eevee-Next: World Reflective Light #108149

Merged
Jeroen Bakker merged 33 commits from Jeroen-Bakker/blender:eevee-next-world-shader into main 2023-06-29 15:25:04 +02:00
5 changed files with 28 additions and 19 deletions
Showing only changes of commit 8835017422 - Show all commits

View File

@ -8,13 +8,16 @@ namespace blender::eevee {
void ReflectionProbeModule::init()
{
cubemaps_tx_.ensure_cube_array(GPU_RGBA16F,
max_resolution_,
max_probes_,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT,
NULL,
max_mipmap_levels_);
GPU_texture_mipmap_mode(cubemaps_tx_, true, true);
if (!initialized_) {
cubemaps_tx_.ensure_cube_array(GPU_RGBA16F,
max_resolution_,
max_probes_,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT,
NULL,
max_mipmap_levels_);
GPU_texture_mipmap_mode(cubemaps_tx_, true, true);
initialized_ = true;
}
}
} // namespace blender::eevee

View File

@ -41,6 +41,10 @@ class ReflectionProbeModule {
Texture cubemaps_tx_ = {"Probes"};
bool initialized_ = false;
bool do_world_update_ = false;
public:
ReflectionProbeModule(Instance &instance) : instance_(instance) {}
@ -51,7 +55,17 @@ class ReflectionProbeModule {
pass->bind_texture(REFLECTION_PROBE_TEX_SLOT, cubemaps_tx_);
}
void do_world_update_set(bool value)
{
do_world_update_ = value;
}
private:
bool do_world_update_get() const
{
return do_world_update_;
}
/* Capture View requires access to the cubemaps texture for framebuffer configuration. */
friend class CaptureView;
};

View File

@ -195,9 +195,10 @@ void ShadingView::update_view()
void CaptureView::render()
{
if (!world_capture_enable_) {
if (!inst_.reflection_probes.do_world_update_get()) {
return;
}
inst_.reflection_probes.do_world_update_set(false);
GPU_debug_group_begin("World.Capture");
View view = {"World.Capture.View"};
@ -209,14 +210,12 @@ void CaptureView::render()
GPU_framebuffer_bind(capture_fb_);
float4x4 view_m4 = cubeface_mat(face);
float4x4 win_m4;
cubeface_winmat_get(win_m4, 1.0f, 10.0f);
float4x4 win_m4 = math::projection::perspective(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f);
view.sync(view_m4, win_m4);
inst_.pipelines.world.render(view);
}
GPU_texture_update_mipmap_chain(inst_.reflection_probes.cubemaps_tx_);
GPU_debug_group_end();
world_capture_enable_ = false;
}
/** \} */

View File

@ -153,16 +153,9 @@ class CaptureView {
Instance &inst_;
Framebuffer capture_fb_ = {"World.Capture"};
bool world_capture_enable_ = false;
public:
CaptureView(Instance &inst) : inst_(inst) {}
void render();
void world_capture_enable(bool enable)
{
world_capture_enable_ = enable;
}
};
/** \} */

View File

@ -90,7 +90,7 @@ void World::sync()
WorldHandle &wo_handle = inst_.sync.sync_world(bl_world);
if (wo_handle.recalc != 0) {
inst_.capture_view.world_capture_enable(true);
inst_.reflection_probes.do_world_update_set(true);
}
wo_handle.reset_recalc_flag();