WIP: Cycles: Importance Resampling #121023

Draft
Weizhen Huang wants to merge 55 commits from weizhen/blender:restir into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Implement Reservoir-based Spatial and Temporal Importance Resampling, aka ReSTIR.
This is heavily WIP and inefficient, currently only implemented initial and spatial resampling for direct illumination, works on CPU with surface lit by area light, sphere light and mesh light.

Direct Light Only Before (5 or 4 spp) After (1 spp)
7.4 s, with light tree before_7.41s_5spp.png after_7.49s_1spp.png
~4.5s, no light tree before_4.84s_4spp_no_tree.png after_4.35s_1spp_no_tree.png

TODO:

  • Multiple spatial sampling iterations
  • Improve spatial sampling MIS weight to remove fireflies
  • Temporal resampling (ReSTIR)
  • Global Illumination (ReSTIR PT)
  • Shift mapping (different sampling method based on roughness and light types)
  • Respect MIS setting of light
  • Reduce reservoir pass storage
    • Random replay from camera
    • Compress data
  • Increase speed
    • Move BSDF sampling outside of NEE
    • Check visibility only when necessary
    • Use light tiles to reduce cache thrash
  • Init from bake (?)
  • Properly handle tiled rendering
  • Volume
  • Transparent surfaces (properly check visibility)
  • Subsurface
  • Curve and point cloud
  • Improve sphere light with soft falloff
  • Spot light
  • Background light
  • Distant light
  • Support GPU
  • Add back MNEE (or can we replace MNEE?)
  • Check compatibility with path guiding

FIX:

  • Bias in spatial resampling
    • due to wrong formulation of the visibility term
  • Denoiser not working with spatial resampling
  • Random crashes with NaN (?)

Debug options:

Screenshot 2024-04-24 at 15.10.56.png

Implement Reservoir-based Spatial and Temporal Importance Resampling, aka **ReSTIR**. This is heavily WIP and inefficient, currently only implemented initial and spatial resampling for direct illumination, works on CPU with surface lit by area light, sphere light and mesh light. | Direct Light Only | Before (5 or 4 spp) | After (1 spp) | | -------- | -------- | -------- | | 7.4 s, with light tree | ![before_7.41s_5spp.png](/attachments/66f1562d-01f2-4bec-afbe-8f9a361f29e1) | ![after_7.49s_1spp.png](/attachments/5c14bd79-c589-4939-ac6f-4038d6de7e93) | |~4.5s, no light tree|![before_4.84s_4spp_no_tree.png](/attachments/482ddbed-6d2a-412b-8d3f-84cc9a690ea3)|![after_4.35s_1spp_no_tree.png](/attachments/b866029f-b39e-472a-abd3-1bb3bd1a773f)| **TODO:** - [ ] Multiple spatial sampling iterations - [x] Improve spatial sampling MIS weight to remove fireflies - [ ] Temporal resampling ([ReSTIR](https://research.nvidia.com/sites/default/files/pubs/2020-07_Spatiotemporal-reservoir-resampling/ReSTIR.pdf)) - [ ] Global Illumination ([ReSTIR PT](https://research.nvidia.com/publication/2022-07_generalized-resampled-importance-sampling-foundations-restir)) - [ ] Shift mapping (different sampling method based on roughness and light types) - [ ] Respect MIS setting of light - [ ] Reduce reservoir pass storage - [x] Random replay from camera - [ ] Compress data - [ ] Increase speed - [ ] Move BSDF sampling outside of NEE - [ ] Check visibility only when necessary - [ ] Use light tiles to reduce cache thrash - [ ] Init from bake (?) - [ ] Properly handle tiled rendering - [ ] Volume - [ ] Transparent surfaces (properly check visibility) - [ ] Subsurface - [ ] Curve and point cloud - [ ] Improve sphere light with soft falloff - [ ] Spot light - [ ] Background light - [ ] Distant light - [ ] Support GPU - [ ] Add back MNEE (or can we replace MNEE?) - [ ] Check compatibility with path guiding **FIX:** - [ ] Bias in spatial resampling - [ ] due to wrong formulation of the visibility term - [x] Denoiser not working with spatial resampling - [ ] Random crashes with NaN (?) **Debug options:** ![Screenshot 2024-04-24 at 15.10.56.png](/attachments/53d175e8-54a7-4e4f-a990-f8f2ea07afd4)
Weizhen Huang added 36 commits 2024-04-24 15:19:21 +02:00
c52d1d1cbc Simple RIS for direct illumination
Take several light and BSDF sample candidates, pick one of them based on
the (unoccluded) contribution.
Quite messy. No MNEE, no support for distant/background light in BSDF
sampling, has bias when lamps overlap.
Less noise in direct illumination, but seems more noisy in indirect illumination.
8c27266b0b Write ShaderData to render buffer and render later
Is redundant but makes spatial resampling easier
Currently require many storage, but can be improved later.
Only support area light for now.
4aeebe5655 Add spatial resampling
Always check 8 neighbors.
Currently doesn't work well with point light with soft falloff, because
uv can only recover `ls->D`, and the visibility between neighboring
pixels vary too much.
110b247b0a Fix crash without light tree
does not support emissive triangles
412f7c1215 Add more ReSTIR options
the ones not implemented yet are grayed out
4392ddb30f Refactor: use int to represent initial and spatial resampling
because we are hitting the socket number limit.
Weizhen Huang added this to the Render & Cycles project 2024-04-24 15:19:26 +02:00
Weizhen Huang added 2 commits 2024-04-25 18:41:53 +02:00
Weizhen Huang force-pushed restir from 0b83af2c4d to 0023d17cb7 2024-04-26 16:10:14 +02:00 Compare
Weizhen Huang added 5 commits 2024-04-29 14:33:25 +02:00
Weizhen Huang added 3 commits 2024-04-30 15:53:42 +02:00
Weizhen Huang force-pushed restir from ec6bd6ca21 to cb15fa32dc 2024-04-30 18:31:41 +02:00 Compare
Weizhen Huang added 5 commits 2024-05-02 13:12:34 +02:00
Weizhen Huang force-pushed restir from 3968b522ac to c3bc745a6b 2024-05-02 15:17:03 +02:00 Compare
Weizhen Huang added 3 commits 2024-05-06 12:04:51 +02:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u restir:weizhen-restir
git checkout weizhen-restir
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
1 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#121023
No description provided.