Convergence based adaptive sampling

Discussion related to the LuxCore functionality, implementations and API.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Convergence based adaptive sampling

Post by Dade »

Introduction

I have added the support for convergence based adaptive sampling to RANDOM and SOBOL sampler.

The problem

image.jpg

While SOBOL sampler has a good stratification, it uses the same number of samples for each pixel. This is the new SAMPLECOUNT AOV showing the number for samples for each pixel, darker means less sample, brighter means more:

sobol-samplecount.jpg

Not very interesting :lol: All pixels have the same amount of samples so the image is just flat gray. Let's see how METROPOLIS sampler works. Metropolis "seeks" light and it uses a number of samples for each pixel proportional to the pixel luminance:

mtl-samplecount.jpg

It works exactly as expected. However it isn't so smart, for instance, it samples the sky a lot because it is bright but it has zero noise and could be rendered with just one samples per pixel.

TILEPATH already has the support for adaptive sampling:

tile-samplecount.jpg

however, its work is based on tiles so it can not refine very much its work aside from sampling less the sky and some other zone.

The solution

Convergence based adaptive sampling for SOBOL (and RANDOM) samplers, uses a number of samples directly proportional to how far is the pixel from the convergence threshold:

sobol-adapt-samplecount.jpg

As you can see, it works very well here. It uses a vary small amount of samples for the sky, the mirror, etc. (darker means less samples, min. samples count 193) and a lot of samples for the caustics (max. samples counts 2106).

The race

But in practice how much rendering time can it save ?

This is normal SOBOL:

race-sobol.jpg
Rendering time => 261 secs
Samples per pixel => 9136

This is METROPOLIS:

race-mtl2.jpg
Rendering time => 600 secs
Samples per pixel => 16963

Why is it so bad ?!? Because it is trapped in its obsession for light and brighter zones. A zone like the one circled in red will receive less samples because it is darker but is also the part of the image with more noise.

This is new SOBOL with convergence based adaptive sampling:

race-sobol-adapt.jpg
Rendering time => 145 secs
Samples per pixel => 4843

Yes, it can be that good, it achieves the same level of convergence while being 1.8 times faster and using 47% less samples.

Conclussion

The adaptive mode is now enabled by default both for RANDOM and SOBOL sampler. There is only one additional parameter:

Code: Select all

sampler.random.adaptive.strength = 0.7
# and
sampler.sobol.adaptive.strength = 0.7
The "strength" is a value between [0.0, 0.95] and It controls how "adaptive" is the sampler: at 0.0 works like the old sampler, at 0.95 samples the zones far from convergence as much as possible ... at 1.0 is biased so it is forbidden by law ;)

The adaptive mode is based on convergence test, if you don't directly enable the convergence halt condition, the sampler will use a test with a threshold of 0.02 as default (but will not stop the rendering).

P.S. a note about convergence threshold: it is written as 0.02 but should be read as 5.12 level difference in an 8bit RGB color. It is a lot easier to understand if it is seen as a value between 0 and 255 divided by 256.
Support LuxCoreRender project with salts and bounties
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Convergence based adaptive sampling

Post by B.Y.O.B. »

Very cool.
Can we get the percentage of converged pixels and the error with session.GetStats()?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Convergence based adaptive sampling

Post by Dade »

This feature will be available in the next v2.0 alpha3, it should be released during the weekend.

LuxCore has many settings but there currently 2 rendering modes that really stand out:

- PATHOCL/CPU+Adaptive SOBOL+Variance clamping (CPU and/or GPU): capable to very fast render reasonably complex scenes.

- BIDIRCPU+METROPOLIS (CPU only): capable to render most complex light paths. It will render nearly evrything but it is going to take some time.
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Convergence based adaptive sampling

Post by Dade »

B.Y.O.B. wrote: Fri Feb 02, 2018 11:59 am Very cool.
Can we get the percentage of converged pixels and the error with session.GetStats()?
It is already returned in the "stats.renderengine.convergence" property as a value between [0, 1]. It is the percentage of pixel under the threshold (I assume you don't care of the exact number but the % is fine).
Support LuxCoreRender project with salts and bounties
User avatar
Sharlybg
Donor
Donor
Posts: 3101
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: Convergence based adaptive sampling

Post by Sharlybg »

Dade wrote: Fri Feb 02, 2018 12:04 pm This feature will be available in the next v2.0 alpha3, it should be released during the weekend.
LuxCore has many settings but there currently 2 rendering modes that really stand out:
happy weekend for everyone ! :D . GOOD JOB
- PATHOCL/CPU+Adaptive SOBOL+Variance clamping (CPU and/or GPU): capable to very fast render reasonably complex scenes.
Like a serious performance increase !
exterior render/ studio lighting/ product viz gonna be faster. can't wait for this week end.
- BIDIRCPU+METROPOLIS (CPU only): capable to render most complex light paths. It will render nearly evrything but it is going to take some time.
Indoor and caustics will rely on Bidir. will try to see this week end how luxcore handle 2K pro indoor render.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Convergence based adaptive sampling

Post by B.Y.O.B. »

Dade wrote: Fri Feb 02, 2018 12:08 pm It is already returned in the "stats.renderengine.convergence" property as a value between [0, 1].
The console prints the following but the "stats.renderengine.convergence" always stays at 0.0

Code: Select all

[LuxCore][76.472] Convergence test: ToDo Pixels = 5, Max. Error = 0.0460828 [11.7972/256]
I try to get it like this:

Code: Select all

convergence = stats.Get("stats.renderengine.convergence").GetFloat()
Do I have to enable it somehow?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Convergence based adaptive sampling

Post by Dade »

B.Y.O.B. wrote: Fri Feb 02, 2018 1:04 pm
Dade wrote: Fri Feb 02, 2018 12:08 pm It is already returned in the "stats.renderengine.convergence" property as a value between [0, 1].
The console prints the following but the "stats.renderengine.convergence" always stays at 0.0

Code: Select all

[LuxCore][76.472] Convergence test: ToDo Pixels = 5, Max. Error = 0.0460828 [11.7972/256]
I try to get it like this:

Code: Select all

convergence = stats.Get("stats.renderengine.convergence").GetFloat()
Do I have to enable it somehow?
Yes, by setting batch.haltthreshold otherwise it only runs internally (to not stop the rendering if you don't set batch.haltthreshold).
Support LuxCoreRender project with salts and bounties
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Convergence based adaptive sampling

Post by B.Y.O.B. »

I noticed that the convergence test seems to focus noise free areas too much when they are very bright.
For example in this scene, the reflections on the bottom are clearly more noisy than the bright areas in the glass, yet the latter ones is sampled far more than the noisy reflections.

This is with 0.95 adaptive amount.
Attachments
whiskey_glass_01_rend01.png
sample count AOV
sample count AOV
whiskey_glass_01.blend
(133.23 KiB) Downloaded 434 times
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Convergence based adaptive sampling

Post by Dade »

I don't have your HDR so it may be related to that but I seem to get a different distribution:
adapt.jpg
Support LuxCoreRender project with salts and bounties
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Convergence based adaptive sampling

Post by B.Y.O.B. »

This is the HDR: http://www.hdrlabs.com/sibl/archive/dow ... Shrine.zip
How long did you render?
The images I posted are taken after about 30min on a HD 7970, so around 2000 samples.
In that stage of the rendering most pixels are noise-free apart from the area on the bottom, and the sampler focuses too much on the bright areas.

I will re-upload the .blend with the bump texture for the ground plane packed because I think it is important. I forgot it.
Post Reply