L Smeets
L Smeets

Reputation: 942

how to prevent grey noise when using render_highquality() in rayshader

I need to output a high res image using render_highquality using plot_gg() of the rayshader/rayrender package. However, I always seem to get a strange grey noise filter over my image, how can I prevent this from happening? (this does not happen if I just use render_snapshot()

So this works (from the package examples):

library(rayshader)
library(rayrender)

volcano %>%
  sphere_shade() %>%
  plot_3d(volcano,zscale = 2)
render_snapshot(clear = TRUE,filename="p1_snap.png")

enter image description here

But this yields an unexpected result.

volcano %>%
  sphere_shade() %>%
  plot_3d(volcano,zscale = 2)
render_highquality(clear = TRUE, filename="p1_hq.png")

enter image description here

I just want the background to be white

Upvotes: 2

Views: 630

Answers (1)

Kunal Bhardwaj
Kunal Bhardwaj

Reputation: 11

The render_highquality() function has an argument called samples which defaults to 128. Increasing the samples to higher values like 512 will reduce noise and improve image quality - especially in the shadows - at the expense of computation time.

In order to get a white background, use two light sources instead of the default one.

   volcano %>%
   sphere_shade() %>%
   plot_3d(volcano,
   zscale = 2)
   render_highquality(clear = TRUE,
   filename="p1_hq.png",
   samples = 512,
   lightdirection = c(60,150))

The default direction is 315. Passing a vector like c(60,150) chooses two light sources with bearings 60 and 150. Changing the direction of light sources can change how the final image looks. Here is the image for the code above:512 Samples and direction c(60,150)

If you change direction to c(60,240) instead, you'll get an image that looks something like this: 512 Samples and direction c(60,240)

Upvotes: 1

Related Questions