Cycles: Ray Visibility > Diffuse is different than using Is Diffuse Ray in shader #118484

Open
opened 2024-02-20 09:11:29 +01:00 by Scurest · 2 comments
Contributor

System Information
Operating system: Linux-6.6.3-arch1-1-x86_64-with-glibc2.38 64 Bits, X11 UI
Graphics card: Mesa Intel(R) HD Graphics 520 (SKL GT2) Intel 4.6 (Core Profile) Mesa 23.2.1-arch1.2

Blender Version
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2024-01-25 14:57, hash: ca767644ebe3

Short description of error
In Cycles, using the Ray Visibility > Diffuse object property to make an object invisible to diffuse rays produces different results than using a Light Path node to do the same thing.

DiffuseRayVs.png

I expected these to be the same, but this could be a problem with my expectation too. It does work for Camera rays and the manual suggests the same effect can be achieved with nodes ("In terms of performance, using these options is more efficient than using a shader node setup that achieves the same effect.").

Exact steps for others to reproduce the error
Open this .blend and go into Rendered View: DiffuseRayTest.blend

DiffuseRayEx.png

The lower left plane is with Ray Visibility > Diffuse off. The lower right plane has a shader that uses Is Diffuse Ray to simulate it. The two upper planes show the same thing works for Camera rays (at least in this test).

**System Information** Operating system: Linux-6.6.3-arch1-1-x86_64-with-glibc2.38 64 Bits, X11 UI Graphics card: Mesa Intel(R) HD Graphics 520 (SKL GT2) Intel 4.6 (Core Profile) Mesa 23.2.1-arch1.2 **Blender Version** Broken: version: 4.1.0 Alpha, branch: main, commit date: 2024-01-25 14:57, hash: `ca767644ebe3` **Short description of error** In Cycles, using the Ray Visibility > Diffuse object property to make an object invisible to diffuse rays produces different results than using a Light Path node to do the same thing. ![DiffuseRayVs.png](/attachments/70eb866f-7ef1-4c95-a553-91a51705439d) I expected these to be the same, but this could be a problem with my expectation too. It does work for Camera rays and the [manual](https://docs.blender.org/manual/en/4.0/render/cycles/object_settings/object_data.html#cycles-ray-visibility) suggests the same effect can be achieved with nodes ("In terms of performance, using these options is more efficient than using a shader node setup that achieves the same effect."). **Exact steps for others to reproduce the error** Open this .blend and go into Rendered View: [DiffuseRayTest.blend](/attachments/e6f42677-5156-456c-b45d-ca2a833ab662) ![DiffuseRayEx.png](/attachments/a7042000-6981-4293-a2be-94186d17c2a9) The lower left plane is with Ray Visibility > Diffuse off. The lower right plane has a shader that uses Is Diffuse Ray to simulate it. The two upper planes show the same thing works for Camera rays (at least in this test).
Scurest added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-02-20 09:11:30 +01:00

Apparently emission rays are considered Diffuse by the Ray Visibility filter of an Object in Cycles, but is not considered diffuse by the Light Path Node.

Maybe it should be Diffuse in both cases?

Needs information from developers... Cc. @brecht.

Apparently emission rays are considered Diffuse by the [Ray Visibility](https://docs.blender.org/manual/en/4.2/render/cycles/object_settings/object_data.html?utm_source=blender-4.2.0-alpha#bpy-types-object-visible-diffuse) filter of an Object in Cycles, but is not considered diffuse by the [Light Path Node](https://docs.blender.org/manual/en/4.2/render/shader_nodes/input/light_path.html?utm_source=blender-4.2.0-alpha#bpy-types-shadernodelightpath). Maybe it should be Diffuse in both cases? Needs information from developers... Cc. @brecht.
Member

For reference, this issue only occurs in the Next Event Estimation (NEE) part of the light sampling.

Looking at the code, this appears to be a known limitation, presumably from performance enhancing code.

/* No proper path flag, we're evaluating this for all closures. that's weak but we'd have to do multiple evaluations otherwise. */
surface_shader_eval<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT>(kg, state, emission_sd, NULL, PATH_RAY_EMISSION);

Source: af4b09a61c/intern/cycles/kernel/light/sample.h (L67)

So what's happening in Cycles is:

  1. A light gets pick for NEE (This is done early in integrate_surface_direct_light()).
  2. Cycles calculates how much light the light is actually emitting (done in the middle of integrate_surface_direct_light() with the function light_sample_shader_eval())
  3. Inside light_sample_shader_eval() we encounter the code from above, that passes NULL rather than path_flags to surface_shader_eval(). surface_shader_eval() being the function that figures out how the node setup of the light influences it's output.
  4. Since NULL is passed rather than path_flags, many features inside the light path node don't work since they rely on this information.
  5. Then the rest of the rendering code runs as expected.

I'll leave the final decision on how to handle this report up to other people.


In the meantime I have a recommendation for @scurest. You can remove mesh lights from NEE to get the desired results. This does come at the cost of increased noise in various situations, but this might be a trade off you're willing to take. To do this, follow these steps:

  1. Go to the Materials Properties tab in the Properties editor.
  2. Locate and expand the section titled Settings
  3. In the subsection titled Surface, set Emission Sampling to None. The light will no longer be sampled by NEE, but can still be sampled by forward path tracing (which does work with your node setup)
For reference, this issue only occurs in the Next Event Estimation (NEE) part of the light sampling. Looking at the code, this appears to be a known limitation, presumably from performance enhancing code. > /* No proper path flag, we're evaluating this for all closures. that's weak but we'd have to do multiple evaluations otherwise. */ > surface_shader_eval<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT>(kg, state, emission_sd, NULL, PATH_RAY_EMISSION); Source: https://projects.blender.org/blender/blender/src/commit/af4b09a61cb7f6abe435c31aa844c228e3130910/intern/cycles/kernel/light/sample.h#L67 So what's happening in Cycles is: 1. A light gets pick for NEE (This is done early in `integrate_surface_direct_light()`). 2. Cycles calculates how much light the light is actually emitting (done in the middle of `integrate_surface_direct_light()` with the function `light_sample_shader_eval()`) 3. Inside `light_sample_shader_eval()` we encounter the code from above, that passes NULL rather than path_flags to `surface_shader_eval()`. `surface_shader_eval()` being the function that figures out how the node setup of the light influences it's output. 4. Since NULL is passed rather than path_flags, many features inside the light path node don't work since they rely on this information. 5. Then the rest of the rendering code runs as expected. I'll leave the final decision on how to handle this report up to other people. --- In the meantime I have a recommendation for @scurest. You can remove mesh lights from NEE to get the desired results. This does come at the cost of increased noise in various situations, but this might be a trade off you're willing to take. To do this, follow these steps: 1. Go to the `Materials Properties` tab in the Properties editor. 2. Locate and expand the section titled `Settings` 3. In the subsection titled `Surface`, set `Emission Sampling` to `None`. The light will no longer be sampled by NEE, but can still be sampled by forward path tracing (which does work with your node setup)
Sign in to join this conversation.
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 project
No Assignees
3 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#118484
No description provided.