Fix #120119: Area lamp artifacts in Cycles with light trees #120216
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 & 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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120216
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Sergey/blender:fix_120119"
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 regression in 4.1, caused by
36e603c430
.For unbiased MIS weight in light tree, we should use sd->N for
mis_origin_n, since sc->N is not available in NEE.
The change also makes it so we do not sample lights below sd->N even
when bump map correction is disabled. This diverges from the original
idea of giving full control to artists, but ensures the internal math
is happy.
A set of test files which I aim to add after landing this patch, to help catching similar issues in the future.
The
light_tree_bump_map.blend
is a smaller version of the file provided in the initial report #120119. its reference image is generated with the change in the codeINTEGRATOR_STATE_WRITE(state, path, mis_origin_n) = sd->N;
(which matches the state prior to the breaking change). This test file behaves exactly as it is expected with this PR applied.The
light_tree_bump_map_no_correction.blend
is a smaller file derived fromreef_shot3.blend
which was used during the "Bump Map Correction" option project. The reference image for it is generated with the state of code prior to this PR. There are some changes in shading, especially when zoomed in so closely. Technically this test will fail with this PR applied, but I'd consider this acceptable trade-off (at least for now, without going too much deep into the normals story).P.S. Surely when the tests will be added a new reference image will be generated. It is mainly to prepare files, and share them for the reviewers.
And one more thing I wanted to share is the demonstration of this change on the bigger picture of the original file
reef_shot3.blend
.I forgot to mention. In terms of performance impact, there is no change on M2, both CPU and GPU.
It is what one would intuitively expect, since it's just moving some lines around, but is always good to verify such things, especially on GPU.
I believe changing
sc->N
tosd->N
is the correct fix, as this normal must be consistent for both forward tracing and NEE, and in NEEsc->N
is not available.As for the
bump_shadowing_term()
fix, I’m not very sure. Even without light tree, the probability of picking a light with NEE is zero when the normal is below the surface due to the shadow ray intersection check; allowing the light to be picked in forward path tracing only adds to bias, it’s just more obvious with the MIS weight of light tree, therefore the firefly. This is also the case for specular surfaces, therefore, while this patch fixes the firefly for diffuse surfaces with bump mapping, I wonder would it be better to checkif (dot(sd->N, *wo) < 0)
in more general cases. Attached is a scene that also needsif (dot(sd->N, *wo) < 0)
check, otherwise there are fireflies.But probably it is better to add incremental changes like this. We should gather a bunch of test files like these to test the shadow terminator and revisit the topic at some point. For example is this
shift_cos_in()
function still needed, why we useensure_valid_specular_reflection()
for glossy surfaces andbump_shadowing_term()
for diffuse surfaces, etc.I expect the final commit message to be shorter than the current description for clarity. Mainly two points need to be stated:
sd->N
need to be consistently used in forward path tracing and NEE, sincesc->N
is not available in NEE.sd->N
, therefore we also need to prevent such lights from being sampled in forward path tracing.The current description can stay in the PR.
@ -81,0 +84,4 @@
/* When bump map correction is not used do not do smoothing, let the normal to be the one which
* artists desires it to be via shader configuration.
* Effectively, when bump map correction is not used only scale shading to 0 when the normal
* points inside of the mesh, which is not well supported by functionality like light trees. */
First, the
g < 0
condition is not checking whether a shading normal points inside the mesh, but whether the incoming light is below the geometry normal.Second, to say it is not well supported by light tree is vague and inaccurate, better to say it is not supported by NEE.
Yes, I also agree that going with
sd->N
is correct here. It's unfortunate, but well, non-physical tricks only get you so far. Arguably we have this issue with some other features as well (such as the classic "object is visible to diffuse/glossy rays, but not shadow rays" topic), but normal maps in particular feel like something so basic that they need to just work without any MIS-relayed traps.As for the
dot(sd->N, *wo)
topic: Yes, thanks for bringing that up. This is something I keep noticing when working on closures - it doesn't really seem consistent whether we check againstsc->N
,sd->N
and/orsd->Ng
, sometimes even between sample and eval functions in the same closure if I remember correctly. We should probably document this somewhere and/or enforce it centrally outside of the closure-specific functions. Personally, I'd prefer to be conservative and only accept rays that are in the correct hemisphere w.r.t. all normals, but that might cause visible artifacts.For now, I think this fix should be okay, the finer details can be discussed later.