EEVEE-Next: Irradiance Cache: Initial Implementation #108639
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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 project
No Assignees
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#108639
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fclem/blender:eevee-next-irradiance-cache"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a full rewrite of the irradiance volume baking.
The baking is much faster and doesn't scale linearly with the number
of irradiance samples in the volumes.
Ref #105643
transform_point
andinvert
14973fabe6WIP: EEVEE-Next: Irradiance Cache: Initial Implementationto EEVEE-Next: Irradiance Cache: Initial ImplementationI tried a test run on Mac Studio M1. Currently Eevee-next only renders black. When looking at individual buffers the light buffer is black. Also with default blender cube or an emissive material. Lights are on in the viewport. I will do a code review and check other systems.
@blender-bot package
Package build started. Download here when ready.
@ -595,6 +617,27 @@ class RENDER_PT_eevee_indirect_lighting_display(RenderButtonsPanel, Panel):
row.prop(props, "gi_irradiance_display_size", text="Irradiance Size")
row.prop(props, "gi_show_irradiance", text="", toggle=True)
class RENDER_PT_eevee_next_indirect_lighting_display(RenderButtonsPanel, Panel):
Code format: Add empty line
@ -219,3 +219,3 @@
if (region->regiontype == RGN_TYPE_TOOL_HEADER) {
if (((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) ||
sl->spacetype == SPACE_SEQ) {
sl->spacetype == SPACE_SEQ)
Unneeded change Make sure your clang-format points to the one in blender-git/lib
I went over the code I think it would require some technical documentation to understand. Although it is a complex feature it seems that the architecture of eevee-next works quite good here.
What is important to fix before landing:
@ -0,0 +27,4 @@
* Create the job description.
* This is called for async (modal) bake operator.
* The actual work will be done by `EEVEE_NEXT_lightbake_job()`.
* IMPORTANT: Must run on the main thread because of potential GPUContext creation.
Guard with an assert?
It is already guarded in LightBake class.
@ -0,0 +42,4 @@
* Allocate dependency graph and job description (EEVEE_NEXT_LightBake).
* Dependency graph evaluation does *not* happen here. It is delayed until
* `EEVEE_NEXT_lightbake_job` runs.
* IMPORTANT: Must run on the main thread because of potential GPUContext creation.
guard with an assert
It is already guarded in
LightBake
class.@ -0,0 +42,4 @@
int grid_index;
};
struct ReflectionCube : public LightProbe {};
Code style (clang-format)
@ -0,0 +62,4 @@
radiance_transfer(receiver, radiance, L);
}
void radiance_transfer_sky(inout Surfel receiver, vec3 sky_L)
Personally I would use the term background. sky is a specific background.
I will use world as it fits better the terminology used in the rest of EEVEE-Next.
@ -1037,3 +1053,2 @@
*/
class Image {
};
class Image {};
clang format
@ -1172,3 +1172,3 @@
case OB_SOLID:
if (U.experimental.enable_workbench_next &&
STREQ(engine_type->idname, "BLENDER_WORKBENCH_NEXT")) {
STREQ(engine_type->idname, "BLENDER_WORKBENCH_NEXT"))
clang format
I experience the same issue with the M1 Pro. All objects are black with the exception of during and after the baking process where incorrect indirect lighting is applied to the area contained within the Irradiance Volume.
System Information
Operating system: macOS-13.4-arm64-arm-64bit 64 Bits
Graphics card: M1 Pro (Using the Metal Backend)
Unable to bake in windows due to the error i post a fix in blender.chat :
" @fclem For the fix when blender crash when you try to bake the irradiance in windows with the error message i'll give you UP the fixe are this : in file
blender\source\blender\draw\engines\eevee_next\shaders\eevee_surfel_ray_comp.glsl
Line46
i put theinout
beforeSurfel sender
and he give this code line :New :
void radiance_transfer_surfel(inout Surfel receiver, inout Surfel sender)
Past (Crash on windows) are
void radiance_transfer_surfel(inout Surfel receiver, Surfel sender)
Same in
C:\blender-git\blender\source\blender\draw\engines\eevee_next\shaders\eevee_lightprobe_irradiance_ray_comp.glsl
line27
i put theinout
beforeSurfel surfel
and he give this code line :New :
void irradiance_capture(inout Surfel surfel, vec3 P, inout SphericalHarmonicL1 sh)
Past (Crash on windows) are :
void irradiance_capture(Surfel surfel, vec3 P, inout SphericalHarmonicL1 sh)
Now when you try to bake irradiance cache in EEVEE NEXT, blender not crash anymore in Windows. Works perfect and density of surfels working too.
"
After the fixe the bake works correctly but give wrong results (all stay black, or with normals color or sometime white color randomly)
Default scene with no baking irradiance
Default scene with irradiance baking (In irradiance option and Render > Indirect lightning) Both give a black scene
Default scene with baking irradiance (Debug mode 3 - Surfels Normals / Density of Surfels : 1.0)
Default scene with baking irradiance (Debug mode 3 - Surfels Normals / Density of Surfels : 0.5)
Sometimes surfels ovelap, and are not correctly placed when you have 2 plan one over the other.
Compiled from machine :
Windows 11 x64 - Home édition 22H2 / Build 22621.1702
GPU : RTX 2060 6 GO (Lenovo)
CPU : INTEL I5 9300H
PC MODEL : LENOVO LEGION RTX 15INCH Y540
And taked from this branch : https://projects.blender.org/fclem/blender/src/branch/eevee-next-irradiance-cache At 6PM (18H french hours / 06/06/2023)
Confirming the same issue as Jeroen and Alaska. All objects render pure black regardless of light type, material changes, etc.
Mac Studio
M1 Ultra
macOS 13.3.1
@dodo-2
This is expected. The surfel representation is not precise enough to detect these cases. The only workaround for now is to increase surfel density. But the indirect lighting usually doesn't require that much precision.
I saw on the EA videos and the PDF, that the surfels spread randomly and their density increased or decreased depending on the distance from the camera and not aligned in a "Grid" form like a Matrix.
Are you going to reproduce these 2 functions (Random placement and density by distance)?
PS : this error come sometimes idk why
Pseudo Random placement can be added and help some cases of aliasing. But the EA video you are surely referencing is not what we implemented at all.
Yes, the baking seems currently broken on some platform. We are investigating.
The main issue seems to be solved for NVidia and MacOS.
However, on Metal backend, there are remaining warnings that I think should be tackled as separate issue.
@ -201,3 +202,3 @@
}
void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
void blo_do_versions_400(FileData * fd, Library * /*lib*/, Main *bmain)
run
make format
@fclem
can you add
118e637e0f
to this branch to fix Linux linking issues. And runmake format
:-) that would solve most of my issues. The other code-style was adding asserts to guard bad usage and a rename of a function (nitpicks).One thing I noticed is that you need to add a irradiance grid to the scene in order to render anything. Is that expected? If so I would add it to the commit description.
Also I found that the next configuration didn't work:
For the rest seems fine for initial land in main.
@blender-bot build
@ -0,0 +301,4 @@
WM_JOB_TYPE_LIGHT_BAKE);
LightBake *bake = new LightBake(
bmain, view_layer, scene, original_probes, true, frame, delay_ms);
std::move(original_probes)
@ -0,0 +316,4 @@
return wm_job;
}
void *EEVEE_NEXT_lightbake_job_data_alloc(struct Main *bmain,
These
struct
keywords are unnecessary in C++@ -0,0 +322,4 @@
blender::Vector<struct Object *> original_probes,
int frame)
{
LightBake *bake = new LightBake(bmain, view_layer, scene, original_probes, false, frame);
std::move(original_probes)
@ -0,0 +17,4 @@
struct wmJob;
/** Opaque type hiding eevee::LightBake. */
typedef struct EEVEE_NEXT_LightBake EEVEE_NEXT_LightBake;
typedef
->using
I'm not sure about what you are suggesting.
EEVEE_NEXT_LightBake
is never defined and is just here to hideeevee::LightBake
. Are you suggestingusing EEVEE_NEXT_LightBake = struct EEVEE_NEXT_LightBake;
?Yeah,
using EEVEE_NEXT_LightBake = EEVEE_NEXT_LightBake
That's making less sense right now, not sure why this using/typdef is necessary in C++
@blender-bot build linux
Was just reading through this out of curiosity, but left some comments as I went.
@ -451,1 +485,4 @@
void Instance::light_bake_irradiance(
Object &probe,
std::function<void()> context_enable,
Looks like these could use
FunctionRef
instead ofstd::function
? That's a bit clearer since these aren't stored more permanently.@ -34,1 +90,4 @@
return {};
}
Vector<IrradianceBrickPacked> allocated;
allocated.resize(brick_len);
These can be combined into one line:
Vector<IrradianceBrickPacked> allocated(brick_len);
@ -64,0 +389,4 @@
display_grids_ps_.bind_texture("irradiance_c_tx", &irradiance_c_tx);
display_grids_ps_.bind_texture("irradiance_d_tx", &irradiance_d_tx);
int sample_count = static_cast<int>(BKE_lightprobe_grid_cache_frame_sample_count(cache));
Functional cast for arithmetic types:
const int sample_count = int(BKE_lightprobe_grid_cache_frame_sample_count(cache));
@ -0,0 +68,4 @@
std::mutex result_mutex_;
public:
LightBake(struct Main *bmain,
struct Main
->Main
, etc.Same below, and in other files.
@ -0,0 +330,4 @@
void EEVEE_NEXT_lightbake_job_data_free(void *job_data)
{
delete reinterpret_cast<LightBake *>(job_data);
reinterpret_cast
->static_cast
when casting fromvoid *
@ -0,0 +52,4 @@
void LightProbeModule::sync_probe(const Object *ob, ObjectHandle &handle)
{
const ::LightProbe *light_probe = (const ::LightProbe *)ob->data;
static_cast
@ -0,0 +109,4 @@
}
}
#if 0 /* TODO make this work with new per object light cache. */
Is the comment meant to be on a separate line from
#if 0
?@ -0,0 +3,4 @@
* Virtual shadowmapping: Usage tagging
*
* Shadow pages are only allocated if they are visible.
* This pass iterates the surfels buffer and tag all tiles that are needed for light shadowing as
tag
->tags
@ -213,0 +291,4 @@
/* -------------------------------------------------------------------- */
/** \name Load/Store
*
* This section define the compression scheme of spherical harmonic data.
define
->defines
@ -21,0 +140,4 @@
.uniform_buf(IRRADIANCE_GRID_BUF_SLOT,
"IrradianceGridData",
"grids_infos_buf[IRRADIANCE_GRID_MAX]")
/* NOTE: Use uint instead of IrradianceBrickPacked because Metal need to know the exact type.*/
need
->needs
@ -1760,0 +1790,4 @@
"ALL",
0,
"All Light Probes",
"Delete all light probes baked lighting data"},
probes
->probes'
(possessive and plural (ends with an s)). Same for selected@ -1760,0 +1800,4 @@
"ACTIVE",
0,
"Active Only",
"Only delete the active light probe baked lighting data"},
probe
->probe's
@ -158,1 +158,4 @@
prop = RNA_def_property(srna, "grid_bake_samples", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(
prop, "Bake Samples", "Number of rays direction to evaluate when baking");
rays direction
->ray directions
I think?@blender-bot build linux
Only blender organization members with write access can start builds. See documentation for details.