Page MenuHome

Cycles: Scrambling distance for the PMJ sampler
ClosedPublic

Authored by William Leeson (leesonw) on Oct 13 2021, 2:44 PM.

Details

Diff Detail

Repository
rB Blender
Branch
arcpatch-D12854_1 (branched from master)
Build Status
Buildable 18260
Build 18260: arc lint + arc unit

Event Timeline

William Leeson (leesonw) requested review of this revision.Oct 13 2021, 2:44 PM
William Leeson (leesonw) created this revision.
Alaska (Alaska) added a comment.EditedOct 14 2021, 2:28 AM

One comment I would like to add:
In intern/cycles/blender/addon/ui.py there is a line col.active = not cscene.use_adaptive_sampling

What this leads to is that section of the UI being grayed out when adaptive sampling is enabled. However, Scrambling Distance appears to still be in use while adaptive sampling is enabled, which isn't expected.

One way I can think of fixing this is to add a check in intern/cycles/blender/blender_sync.cpp to see if adaptive sampling is being used.

Scrambling distance is now disabled when adaptive sampling is enabled.

Removes the printing of the PMJ sample set.

Something isn't right with this patch. The patch in it's current state appears to be the difference between your current work, and a previous version of this patch. Meaning this patch can NOT be applied on top of D12318: Distance Scrambling for for Cycles X - Sobol version without errors, and even if you fix them, none of the UI stuff is there.

Alaska (Alaska) added a comment.EditedOct 15 2021, 8:34 AM


I went through and manually made the changes at each revision of this patch and created a diff from it. I believe applying this diff on top of D12318: Distance Scrambling for for Cycles X - Sobol version will give you the code expected from this patch.

It should be noted that I did rebase my build of Blender on the latest master. So you should apply D12318: Distance Scrambling for for Cycles X - Sobol version on top of the latest master before applying this diff.

William Leeson (leesonw) updated this revision to Diff 43357.EditedOct 15 2021, 9:07 AM

Update with changes from @Alaska (Alaska)

intern/cycles/blender/addon/ui.py
292–293

This comment applies to D12318 and this patch.

I believe these two line should be removed.

This is because the (cscene.scrambling_distance < 1.0) or cscene.adaptive_scrambling_distance) part of this check results in the UI being grayed out for a reason that isn't particularly clear to the end user. So I would personally remove those. But with that removed you're left with

col = layout.column(align=True)
col.active = not cscene.use_adaptive_sampling

Which is the same variables as above at line 288 and 289

However, this is just my opinion.

Alaska (Alaska) added a comment.EditedOct 15 2021, 10:45 AM

Also, something is wrong. Either when I updated the patch I did it incorrectly or this is some other issue. But with this patch applied PMJ produces more noise than master at the same sample count. Even when the Scambling Distance Strength is set to 1 (With a value of 1 a significant change in noise shouldn't be noticeable)

Master (PMJ)This patch with Scambling Distance Strength = 1 (PMJ)

Note: Both tests are at 4092 samples with no adaptive sampling enabled.

intern/cycles/blender/blender_sync.cpp
373 ↗(On Diff #43357)

Just wanted to point out I made a mistake in my diff. The if (preview) should be deleted.

lines 292-292: No problem I'll fix it up soon.
lines 370: I can believe I missed that :-).

I think the more noise is caused by the adaptive scrambling distance but I need to investigate.

This comment was removed by William Leeson (leesonw).

Fix broken distance scrambled PMJ sampler.

William Leeson (leesonw) marked an inline comment as done.Oct 15 2021, 1:24 PM

Submitted an update to remove the floating if statement and also fix the broken sampler. I am not sure what to do with the UI but it greys out the distance scrambling if adaptive sampling is on, I don't think adaptive sampling works correctly with distance scrambling so that probably make sense.

This comment was removed by Alaska (Alaska).

Rebased against master and updated the diff

Alaska (Alaska) updated this revision to Diff 43816.EditedOct 23 2021, 3:20 AM

Just wanted to make sure everything was up to date so it's easy to commit D12318: Distance Scrambling for for Cycles X - Sobol version and this patch before BCON 3 if that is the goal.

Updated to use master and for the moved and renamed files.

William Leeson (leesonw) retitled this revision from Scrambling distance for the PMJ sampler to Cycles:Scrambling distance for the PMJ sampler.Oct 27 2021, 9:39 AM
William Leeson (leesonw) edited the summary of this revision. (Show Details)
Alaska (Alaska) added a comment.EditedOct 27 2021, 9:57 AM

I am posting my results here as per request of @William Leeson (leesonw)

In D12318: Distance Scrambling for for Cycles X - Sobol version some changes were made in intern/cycles/integrator/tile.cpp to change how the tile size was calculated in hopes to improve performance. I decided to run performance tests with various techniques to figure out how each system performs and these are the results.

Let's start with some intial information:

  • For my testing I took the Barbershop and Classroom demo scenes from the Blender demos website and changed the resolution to 1920x1080 and increased the sample counts (8192 for Barbershop and 16384 for Classroom). I then incremented through Scramble Distance Strengh values in 0.1 increments and recorded the rendertime of each render.
  • I ran testing on the Barbershop and Classroom scenes both with command line rendering and with rendering through the GUI. This is important for a aspect of the test.
  • I did not use my computer for any other task than render while running these tests to avoid adding extra load to my system.
  • All builds of Blender builds are based on top of rBddf97d6270d0a0da36257bb676d9d05513064de5
  • In all the renders I used GPU compute with OptiX. You can find information about my GPU below.
    • Operating system: Linux-5.14.0-3-amd64-x86_64-with-glibc2.32 64 Bits
    • Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.29.05

Here are the results:

Barbershop - Command LineBarbershop - GUIClassroom - Command LineClassroom - GUI

Now to talk about some notes:
What does Original, New Master and Brecht Proposal mean in terms of code?

  • Original means the code used in tile.cpp is the code found in D12318 revision 43748
if (scrambling_distance < 0.9f) {
    return ((max_num_path_states > 4000000) ? TileSize(1024, 1024, 1) : TileSize(512, 512, 1));
  }
  • New Master means the code used in tile.cpp is the code found in the latest revision of D12318 and was the code commited to Master
  • Brecht Proposal means the code used in tile.cpp is the code found here as proposed by Brecht P2520

As you can see from the tests, Original and Brecht Proposal are close in performance in these specific tests with this specific GPU. As such Brecht Proposal (P2520) should probably be commited to master or iterated on.


Extra notes:

  • You may notice that with New Master the results vary between the command line rendering and GUI rendering. As far as I can tell this is because the code path taken in tile.cpp was impacted by the different update times while rendering as defined in /intern/cycles/integrator/render_scheduler.cpp at around line 700 - 730 as different numbers of samples are scheduled.
  • You may notice that Brecht Proposal is slower than Original in GUI rendering. This is most likely down to the fact that Original in GUI rendering is actually the performance numbers of Original from command line rendering as I didn't have time to redo the GUI results for Original.
  • You will notice a large change in performance at around a Scramble Distance Strength of 0.9. This is caused by the code in tile.cpp being based around a check if (scrambling_distance < 0.9f)

Use @brechts tile size proposal.

  • Fix code removed in a older revision on accident

Some results comparing this updated PMJ sampler vs the version in master by rendering 1024 sample using the junk shop scene

variantPMJ (original)PMJSD PMJ
SDPMJ CUDA134.17134.21130.64
SD PMJ Optix74.9574.4361.19
SD PMJ CPU516.78519.51445.31

and some images for comparison

Variantmaster PMJPMJSD PMJ
CUDA
Optix
CPU
This revision is now accepted and ready to land.Oct 27 2021, 1:27 PM
Brecht Van Lommel (brecht) retitled this revision from Cycles:Scrambling distance for the PMJ sampler to Cycles: Scrambling distance for the PMJ sampler.Oct 27 2021, 1:30 PM
intern/cycles/integrator/tile.cpp
76–79

I would personally add the code comment from P2520 here in the final commit.

Add in code comment and adjust formatting.