Eevee-next: Reflective Light Baking #109909

Merged
Jeroen Bakker merged 29 commits from Jeroen-Bakker/blender:eevee-next/reflection-probe-baking-pipeline into main 2023-07-14 11:22:26 +02:00
Member

This PR introduces baking reflective light from light probes. Light probes
are baked on the fly when the light probe data has changed. It doesn't update
directly when other scene data is changed in the viewport.

When doing image rendering the light probes are updated on each frame.

Currently the world probe and closest reflection probe are composited
together in shader. This allows different resolutions. We expect that we
eventually composite it before usage. This would improve the performance.
Unclear if we would support both compositing options eventually.

This PR introduces baking reflective light from light probes. Light probes are baked on the fly when the light probe data has changed. It doesn't update directly when other scene data is changed in the viewport. When doing image rendering the light probes are updated on each frame. Currently the world probe and closest reflection probe are composited together in shader. This allows different resolutions. We expect that we eventually composite it before usage. This would improve the performance. Unclear if we would support both compositing options eventually.
Jeroen Bakker added this to the 4.0 milestone 2023-07-10 14:45:22 +02:00
Jeroen Bakker added the
Module
EEVEE & Viewport
label 2023-07-10 14:45:22 +02:00
Jeroen Bakker self-assigned this 2023-07-10 14:45:22 +02:00
Jeroen Bakker added 1 commit 2023-07-10 14:45:33 +02:00
fabc17246e Eevee-next: Reflective Light Baking
This PR will work towards baking reflective light from light probes.

Noteworthy changes:

- Input cubemap now has a resolution that would not require mipmapping
  anymore. As the cubemap is smaller than the octahedral map the
  filtering would already remove any artifacts using less GPU memory.
Jeroen Bakker added this to the EEVEE & Viewport project 2023-07-10 14:46:37 +02:00
Jeroen Bakker requested review from Clément Foucault 2023-07-10 14:46:43 +02:00
Jeroen Bakker added 1 commit 2023-07-10 15:49:10 +02:00
Jeroen Bakker added 1 commit 2023-07-10 15:58:58 +02:00
Jeroen Bakker added 2 commits 2023-07-11 14:08:54 +02:00
Jeroen Bakker added 1 commit 2023-07-11 15:03:02 +02:00
Jeroen Bakker added 1 commit 2023-07-11 15:16:46 +02:00
Jeroen Bakker added 1 commit 2023-07-11 15:38:48 +02:00
Jeroen Bakker added 1 commit 2023-07-11 15:41:29 +02:00
Jeroen Bakker changed title from WIP: Eevee-next: Reflective Light Baking to Eevee-next: Reflective Light Baking 2023-07-11 15:41:40 +02:00
Clément Foucault requested changes 2023-07-13 00:28:31 +02:00
Clément Foucault left a comment
Member

Did not yet review the update tagging / request system. But this is a first pass.

Did not yet review the update tagging / request system. But this is a first pass.
@ -300,2 +300,3 @@
capture_view.render();
capture_view.render_world();
main_view.render();
/* Rendering of probes depends on main view resources. The rendered probes will be applied to the

Could you elaborate on this? This seems quite a poor technical limitation. If the capture pipeline / view shares resources with the main one it should acquire them.

Could you elaborate on this? This seems quite a poor technical limitation. If the capture pipeline / view shares resources with the main one it should acquire them.
Author
Member

This is mentioned in the description of the PR that this should be investigated as I haven't looked into it yet

This is mentioned in the description of the PR that this should be investigated as I haven't looked into it yet
Jeroen-Bakker marked this conversation as resolved
@ -301,1 +301,4 @@
main_view.render();
/* Rendering of probes depends on main view resources. The rendered probes will be applied to the
* next sample. */
// TODO: Not sure how to incorporate this during image rendering.

Have a loop in Instance::render_frame that update all probes before the sampling loop (while (!sampling.finished()) {).

Have a loop in `Instance::render_frame` that update all probes before the sampling loop (`while (!sampling.finished()) {`).
Jeroen-Bakker marked this conversation as resolved
@ -254,3 +259,4 @@
mat.prepass = material_pass_get(ob, blender_mat, prepass_pipe, geometry_type);
mat.shading = material_pass_get(ob, blender_mat, surface_pipe, geometry_type);
mat.capture = MaterialPass();
mat.probe_prepass = material_pass_get(

This should only be created if needed. So if object is visible in reflections and capture is enabled.

This should only be created if needed. So if object is visible in reflections and capture is enabled.
Author
Member

Need to look into this. I assumed (due to unexperience of the material pipeline) that this was persistent. If not this could be made more flexible. Ah I see shader_map_ is cleared at the beginning when syncing.

Need to look into this. I assumed (due to unexperience of the material pipeline) that this was persistent. If not this could be made more flexible. Ah I see shader_map_ is cleared at the beginning when syncing.
Jeroen-Bakker marked this conversation as resolved
@ -558,0 +569,4 @@
/* Textures. */
prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
/* Uniform Buffer. */
// TODO: should not be camera...

? visible confusion

? **visible confusion**
Jeroen-Bakker marked this conversation as resolved
@ -558,0 +646,4 @@
eval_light_ps_.bind_texture("gbuffer_closure_tx", &inst_.gbuffer.closure_tx);
eval_light_ps_.bind_texture("gbuffer_color_tx", &inst_.gbuffer.color_tx);
eval_light_ps_.push_constant("is_last_eval_pass", is_last_eval_pass);
// TODO bind dummy texture so they don't influence any render pass accumulation.

To be verified, but they won't because none of these results are then accumulated into the film buffers.

To be verified, but they won't because none of these results are then accumulated into the film buffers.
Author
Member

Yes was also my understanding and yes it should be tested.

Yes was also my understanding and yes it should be tested.
Jeroen-Bakker marked this conversation as resolved
@ -558,0 +659,4 @@
inst_.sampling.bind_resources(&eval_light_ps_);
inst_.hiz_buffer.bind_resources(&eval_light_ps_);
inst_.ambient_occlusion.bind_resources(&eval_light_ps_);
// TODO: only allow the world light to be evaluated

Don't understand how this comment is related to its surrounding.

Don't understand how this comment is related to its surrounding.
Author
Member

During probe rendering I would only use the world reflection probe during shading and ignore all reflection probes that are created by light probes. as the data might not be up to date and therefore can lead to artifacts because the render order cannot be controlled by the artist.

My idea would be to assign an ubo only containing the world inside the inst_.reflection_probes.bind_resources(..., REFLECTION_PROBE_WORLD_ONLY) or something similar. Could be an ubo or push constant.

During probe rendering I would only use the world reflection probe during shading and ignore all reflection probes that are created by light probes. as the data might not be up to date and therefore can lead to artifacts because the render order cannot be controlled by the artist. My idea would be to assign an ubo only containing the world inside the `inst_.reflection_probes.bind_resources(..., REFLECTION_PROBE_WORLD_ONLY)` or something similar. Could be an ubo or push constant.

Do not use any reflection in the baking process. Using only the world probe will only create light leaks. Only evaluate diffuse surfaces for now.

Do not use any reflection in the baking process. Using only the world probe will only create light leaks. Only evaluate diffuse surfaces for now.
Jeroen-Bakker marked this conversation as resolved
@ -558,0 +723,4 @@
void DeferredProbePipeline::begin_sync()
{
opaque_layer_.begin_sync();
refraction_layer_.begin_sync();

No refraction layer needed during probe capture. You can remove the option. All specular energy should be converted to diffuse, or use irradiance grid as indirect lighting. But you should really only have one deferred layer since no screen space effect is supported in capture mode.

No refraction layer needed during probe capture. You can remove the option. All specular energy should be converted to diffuse, or use irradiance grid as indirect lighting. But you should really only have one deferred layer since no screen space effect is supported in capture mode.
Jeroen-Bakker marked this conversation as resolved
@ -213,0 +219,4 @@
PassMain prepass_ps_ = {"Prepass"};
PassMain::Sub *prepass_single_sided_static_ps_ = nullptr;
// PassMain::Sub *prepass_single_sided_moving_ps_ = nullptr;

Remove and remove static from name.

Remove and remove `static` from name.
Jeroen-Bakker marked this conversation as resolved
@ -213,0 +252,4 @@
* a hardcoded number of them. */
DeferredProbeLayer opaque_layer_;
DeferredProbeLayer refraction_layer_;
DeferredProbeLayer volumetric_layer_;

Remove that too. No need to make the pipeline complex for this implementation.

Remove that too. No need to make the pipeline complex for this implementation.
Jeroen-Bakker marked this conversation as resolved
@ -96,0 +106,4 @@
* Is set and reset during `remap_to_octahedral_projection`. All other occasions should contain
* nullptr.
*/
GPUTexture *cubemap_tx_ = nullptr;

I think you can promote it to Texture and acquire it on the fly. This removes a bit of ugly code where you have to setup the reference.

Also don't forget to add comment saying that this should be a TextureFromPool and explaining why it isn't.

I think you can promote it to `Texture` and acquire it on the fly. This removes a bit of ugly code where you have to setup the reference. Also don't forget to add comment saying that this should be a `TextureFromPool` and explaining why it isn't.
Jeroen-Bakker marked this conversation as resolved
@ -162,6 +162,19 @@ void Sampling::step()
reset_ = false;
}
bool Sampling::do_probe_sync() const

Move to Instance

Move to `Instance`
Jeroen-Bakker marked this conversation as resolved
@ -223,0 +230,4 @@
{
GPU_debug_capture_begin();
Texture cubemap_tx;
TextureFromPool depth_tx;

Never used!

Never used!
Jeroen-Bakker marked this conversation as resolved
@ -223,0 +244,4 @@
int2 extent = int2(update_info->resolution);
if (cubemap_tx.ensure_cube(GPU_RGBA16F, update_info->resolution, GPU_TEXTURE_USAGE_ATTACHMENT))

I assume that if you enter render_probes, either there is a early out at the top of the functino when no probes are to be rendered, or there is a check in the caller code.

So put all the setup code for the frambuffer outside the loop.

I assume that if you enter `render_probes`, either there is a early out at the top of the functino when no probes are to be rendered, or there is a check in the caller code. So put all the setup code for the frambuffer outside the loop.
Author
Member

Every reflection probe could be rendered in a different resolution, extent can then be different, framebuffer can use different textures etc. The early exit is the while loop. If nothing needs to be rerendered it returns a nullopt and won't enter the while loop.

Perhaps check IRL how to make this better.

Every reflection probe could be rendered in a different resolution, extent can then be different, framebuffer can use different textures etc. The early exit is the while loop. If nothing needs to be rerendered it returns a nullopt and won't enter the while loop. Perhaps check IRL how to make this better.

I missed this changing resolution for each probe. Then it is fine.

I missed this changing resolution for each probe. Then it is fine.
fclem marked this conversation as resolved
Jeroen Bakker added 6 commits 2023-07-13 09:09:42 +02:00
Jeroen Bakker added 2 commits 2023-07-13 10:30:44 +02:00
Jeroen Bakker added 2 commits 2023-07-13 11:14:20 +02:00
Jeroen Bakker added 1 commit 2023-07-13 11:43:21 +02:00
Jeroen Bakker added 2 commits 2023-07-13 14:22:45 +02:00
Jeroen Bakker added 1 commit 2023-07-13 15:40:19 +02:00
Jeroen Bakker added 1 commit 2023-07-13 16:10:45 +02:00
Jeroen Bakker added 3 commits 2023-07-14 09:57:48 +02:00
Jeroen Bakker added 1 commit 2023-07-14 10:38:39 +02:00
Jeroen Bakker added 1 commit 2023-07-14 11:04:45 +02:00
Clément Foucault approved these changes 2023-07-14 11:06:02 +02:00
Clément Foucault left a comment
Member

Tested on Mac M1 and it now works great with the latest fixes. Good to go.

Tested on Mac M1 and it now works great with the latest fixes. Good to go.
Jeroen Bakker merged commit 03ead30027 into main 2023-07-14 11:22:26 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#109909
No description provided.