Refactor: Cycles: adjust microfacet lobe selection pdf by tint #112158
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
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 project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#112158
Loading…
Reference in New Issue
No description provided.
Delete Branch "weizhen/blender:refactor_microfacet_fresnel"
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?
Now that there are different Fresnel types and the reflectance can be tinted,
it is better to sample based on the actually used Fresnel type, instead of
the original Fresnel. This also avoids computing Fresnel multiple times.
Refactor: Cycles: weight reflection/refraction lobe selection pdf by tintto Refactor: Cycles: adjust microfacet lobe selection pdf by tintLooks great! The new approach is much cleaner.
Just a few code-level comments.
@ -511,3 +517,2 @@
(is_transmission && m_reflection) || (!is_transmission && m_refraction))
(is_transmission && !has_transmission) || (!is_transmission && !has_reflection))
{
*pdf = 0.0f;
Is this intentional?
In
bsdf_eval()
the*pdf
is initialized with zero, so it's not necessary to assign zero to*pdf
again.I was thinking whether we should remove such assignment in all the
bsdf_xxx_eval()
. On one hand these functions should be responsible themselves to ensure the return values are valid, on the other hand we have many early returns here and it looks ugly to have*eval = zero_spectrum()
and*pdf = 0.0f
everywhere.Doesn't really matter either way I think, here it just looks a bit cleaner to me. Or we can initialze the values to 0.0f at the beginning of this function.
Ah yeah, good point. All of these only get called from one location anyways, so it's much nicer to do a clean initialization there than to do it 100x in each individual BSDF.
@ -219,1 +210,3 @@
{
* If generalized Schlick is used, the reflectance is an interpolation of the F0 color and the F90
* color.
* For dielectric and conductor, use Fresnel equations.
This comment was already outdated before this PR, I guess now would be a good time to update it 😄
Maybe something like
@ -220,0 +213,4 @@
* Otherwise returns white. */
ccl_device_forceinline void microfacet_fresnel(ccl_private const MicrofacetBsdf *bsdf,
const float cos_theta_i,
ccl_private float *r_cos_theta_r,
Shouldn't this be
r_cos_theta_t
?Would be better yes! This comes from an early iteration where I was thinking
r
can mean both reflection and refraction, but the reflection angle is not really needed here, it always equals tocos_theta_i
@ -254,3 +254,1 @@
return refraction ? zero_spectrum() : fresnel->reflection_tint;
}
cosI = safe_sqrtf(1.0f - sinT2);
const float cosT_sq = 1.0f - (1.0f - sqr(cos_theta_i)) / sqr(bsdf->ior);
Nitpick: I think we generally use
2
as a suffix to indicate squared values, likecosT2
?Sergey said the convention in Blender is
_sq
, I have that inray_sphere_intersect()
, and am trying to name all the newly added variables with that suffix. But we have a lot mixed convention here, for exampleH
andwi
,cosT
andcos_theta_t
,2
and_sq
. Maybe we should do a cleanup at some pointAh okay, maybe Blender and Cycles drifted apart a bit here? Anyways, you're right that this is not really consistent, so I think we can just leave this.
@ -257,0 +258,4 @@
*r_transmission = zero_spectrum();
return;
}
const float cosT = safe_sqrtf(cosT_sq);
Nitpick: The
if
above explicitly checks for non-positivecosT_sq
, so this can be a regularsqrt
.@ -258,2 +266,3 @@
/* TODO(lukas): Is a special case for exponent==5 worth it? */
s = powf(1.0f - cosI, fresnel->exponent);
/* When going from a higher to a lower IOR, we must use the transmitted angle. */
s = powf(1.0f - ((bsdf->ior < 1.0f) ? *r_cos_theta_r : cos_theta_i), fresnel->exponent);
This might cause issues if
r_cos_theta_r
is NULL, just usecosT
I guess.LGTM - looks like tests need to be updated, but it's only a few fireflies that are different.