tylermorganwall / rayrender

A pathtracer for R. Build and render complex scenes and 3D data visualizations directly from R
http://www.rayrender.net
622 stars 43 forks source link

How to reduce dither? #27

Closed jbum closed 3 years ago

jbum commented 3 years ago

I'm new to R, and running this on a fresh install on a Mac in RStudio. When I render the first example under Usage in the README.

render_scene(scene, parallel = TRUE, width = 800, height = 800, samples = 1000)

I'm seeing heavy dithering, as compared to the illustration shown in the README. Increasing samples doesn't seem to improve it much (I went as high as 1m). Is there a way to reduce the dithering? My result shown below:

rplot_1000

If there's an easy fix, consider mentioning it in the README?

UPDATE: I can get a bit closer to the illustrations by tripling or quadrupling the resolution (e.g. width=3200 height=3200, samples=1000) and resizing back to 800 in photoshop. Are the images in the README using oversampling?

tylermorganwall commented 3 years ago

By default, the scene is rendered with adaptive sampling: try setting min_variance = 0 in render_scene(). That will turn off adaptive sampling and you should have much less noisy renders.

Additionally, if you use less than or equal to 256 samples, use sample_method = "sobol_blue"; if you use more than 256 samples, use sample_method = "sobol".

jbum commented 3 years ago

Much better thank you!

With min_variance = 0

> system.time(render_scene(scene, parallel = TRUE, width = 800, height = 800, samples = 1000, clamp_value=10, min_variance=0))
   user  system elapsed                                               
957.984  14.364 163.666 

rplot_1000_mv0

tylermorganwall commented 3 years ago

Great!

jbum commented 3 years ago

width=3200 height=3200 (without min_variance=0) looks even nicer, but if I combine it with min_variance=0 (and sobol), I ran out of memory. :-)

rplot_3200_1k_downsampled