EEVEE-Next: Extract Spherical Harmonics from World #110110

Merged
Member

This PR adds diffuse light from environment to the scene without having an
irradiance volume in the scene.

It does this by extracting the sperical harmonics from the world probe and
store it in the irradiance brick that is reserved for world diffuse light
in the irradiance cache.

This also fixes that selecting an LookDev HDRI didn't update the diffuse
light.

image

Known Issues

  • When sampling probes with lower resolution strokes are visible, leading
    to flickering and instability in the spherical harmonics. This is an
    issue that should be solved in a separate patch as it is already visible
    in main
  • When selecting a lookdev HDRI all irradiance volumes needs to be disabled
    manually for the expected results (but this also disabled GI). In the future
    this will be done automatically or we will add a solution to separate the
    world diffuse light from the irradiance cache so we can update it on the fly.
This PR adds diffuse light from environment to the scene without having an irradiance volume in the scene. It does this by extracting the sperical harmonics from the world probe and store it in the irradiance brick that is reserved for world diffuse light in the irradiance cache. This also fixes that selecting an LookDev HDRI didn't update the diffuse light. ![image](/attachments/48adc150-0b46-4073-af4a-b2f3ffe847c7) **Known Issues** - When sampling probes with lower resolution strokes are visible, leading to flickering and instability in the spherical harmonics. This is an issue that should be solved in a separate patch as it is already visible in main - When selecting a lookdev HDRI all irradiance volumes needs to be disabled manually for the expected results (but this also disabled GI). In the future this will be done automatically or we will add a solution to separate the world diffuse light from the irradiance cache so we can update it on the fly.
683 KiB
Jeroen Bakker added this to the 4.0 milestone 2023-07-14 16:38:28 +02:00
Jeroen Bakker added the
Module
EEVEE & Viewport
label 2023-07-14 16:38:28 +02:00
Jeroen Bakker self-assigned this 2023-07-14 16:38:28 +02:00
Jeroen Bakker added 1 commit 2023-07-14 16:38:36 +02:00
Jeroen Bakker added a new dependency 2023-07-17 10:57:34 +02:00
Jeroen Bakker added 6 commits 2023-07-17 13:49:46 +02:00
Jeroen Bakker added 1 commit 2023-07-17 13:53:57 +02:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-07-17 14:00:13 +02:00
Jeroen Bakker requested review from Clément Foucault 2023-07-17 14:00:19 +02:00
Jeroen Bakker added 2 commits 2023-07-17 15:12:25 +02:00
Jeroen Bakker removed a dependency 2023-07-17 15:13:04 +02:00
Jeroen Bakker added 1 commit 2023-07-17 15:16:42 +02:00
Jeroen Bakker added 1 commit 2023-07-17 15:19:13 +02:00
Jeroen Bakker added 1 commit 2023-07-17 15:29:42 +02:00
Jeroen Bakker changed title from WIP: Eevee-next: Extract Spherical Harmonics Cooefs from World Probe to Eevee-next: Extract Spherical Harmonics Cooefs from World 2023-07-17 15:39:52 +02:00
Jeroen Bakker added 1 commit 2023-07-18 09:06:35 +02:00
Jeroen Bakker added 2 commits 2023-07-18 09:48:34 +02:00
Jeroen Bakker added 1 commit 2023-07-18 09:56:58 +02:00
Jeroen Bakker added 1 commit 2023-07-18 10:12:47 +02:00
Jeroen Bakker added 1 commit 2023-07-18 10:53:52 +02:00
Jeroen Bakker added 3 commits 2023-07-18 14:32:39 +02:00
Jeroen Bakker added 1 commit 2023-07-18 14:56:20 +02:00
Jeroen Bakker added 1 commit 2023-07-18 14:57:39 +02:00
Jeroen Bakker added 1 commit 2023-07-18 15:46:58 +02:00
Jeroen Bakker added 1 commit 2023-07-18 15:49:23 +02:00
Jeroen Bakker added 2 commits 2023-07-19 09:03:05 +02:00
Jeroen Bakker added 1 commit 2023-07-19 09:13:13 +02:00
Clément Foucault requested changes 2023-07-19 09:17:33 +02:00
@ -38,6 +38,7 @@ struct ReflectionProbe {
bool do_update_data = false;
/* Should the area in the probes_tx_ be updated? */
bool do_render = false;
bool do_update_irradiance = false;

Would call it do_world_irradiance_update.

Would call it `do_world_irradiance_update`.
Jeroen-Bakker marked this conversation as resolved
@ -167,6 +170,7 @@ class ReflectionProbeModule {
std::optional<ReflectionProbeUpdateInfo> update_info_pop(ReflectionProbe::Type probe_type);
void remap_to_octahedral_projection(uint64_t object_key);
void update_probes_texture_mipmaps();
void update_irradiance(uint64_t object_key);

This is confusing. Why would it take an object_key if that is only for updating the world?

This is confusing. Why would it take an object_key if that is only for updating the world?
Jeroen-Bakker marked this conversation as resolved
@ -0,0 +1,84 @@
/* Shader to extract spherical harmonics cooefs from octahedral mapped reflection probe. */
/* TODO(jbakker): Use larger dispatch size and atomic add. */

Remove TODO

Remove TODO
Jeroen-Bakker marked this conversation as resolved
@ -0,0 +37,4 @@
barrier();
/* Determine the LOD to sample. We locate mipmap level that contains the 64x64 subdivision what

I don't think this comment brings any clarification to what's happening. Either make it more descriptive or remove it.

I don't think this comment brings any clarification to what's happening. Either make it more descriptive or remove it.
Jeroen-Bakker marked this conversation as resolved
@ -0,0 +54,4 @@
vec2 rand = fract(hammersley_2d(sample_index + sample_offset, total_samples));
vec3 direction = sample_sphere(rand);
vec4 light = reflection_probes_sample(direction, layer_mipmap, probe_data);
spherical_harmonics_encode_signal_sample(

I wouldn't put a early return even if that's after the barrier.

I wouldn't put a early return even if that's after the barrier.
Jeroen-Bakker marked this conversation as resolved
@ -105,0 +107,4 @@
float omega = rand.y * 2.0 * M_PI;
float cos_theta = rand.x * 2.0 - 1.0;
float sin_theta = safe_sqrt(1.0 - cos_theta * cos_theta);
return vec3(sin_theta * vec2(cosf(omega), sinf(omega)), cos_theta);

cos & sin. cosf is for C++ and it is a define in our GLSL .

`cos` & `sin`. `cosf` is for C++ and it is a define in our GLSL .
Jeroen-Bakker marked this conversation as resolved
Clément Foucault changed title from Eevee-next: Extract Spherical Harmonics Cooefs from World to Eevee-next: Extract Spherical Harmonics from World 2023-07-19 09:18:34 +02:00
Jeroen Bakker added 2 commits 2023-07-19 09:28:28 +02:00
Clément Foucault approved these changes 2023-07-19 12:17:25 +02:00
Clément Foucault changed title from Eevee-next: Extract Spherical Harmonics from World to EEVEE-Next: Extract Spherical Harmonics from World 2023-07-19 12:17:35 +02:00
Author
Member

@blender-bot build

@blender-bot build
Jeroen Bakker added 1 commit 2023-07-19 13:45:36 +02:00
Jeroen Bakker merged commit 9cacdf6c42 into main 2023-07-19 13:48:38 +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#110110
No description provided.