tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.05k stars 211 forks source link

Line artefacts in rglwidget rendered models #147

Closed psychemedia closed 3 years ago

psychemedia commented 3 years ago

On occasion, I'm noticing line artefacts appearing in rglwidget() rendered models. My Rmd file blends simple widget rendering within Rmd documents with the use of rgl::rgl.open() andrgl::rgl.close() statements to support rendering videos.

(I'm on a Mac, using XQuartz at times eg via rgl::rgl.open().)

The line artefacts can appear from a high point to the base across a model, or as in the following case, within the base:

library(rgl)
library(rayshader)

simple_matrix = matrix(c(0, 0, 0, 0, 0,
                         0, 0, 0, 0, 0,
                         0, 0, 5, 0, 0,
                         0, 0, 0, 0, 0,
                         0, 0, 0, 0, 0), 5)

simple_map = simple_matrix %>%
  sphere_shade(texture = "desert")

options(rgl.useNULL = TRUE, rgl.printRglwidget = TRUE)

rgl::clear3d()

simple_map %>%
  plot_3d(simple_matrix,

          # Render base
          solid = TRUE,
          soliddepth = -0.50, #"auto" (= lowest_depth-1)
          solidcolor = "red",
          solidlinecolor = "blue",

        )

rgl::rglwidget()

image

Or here:

```{r}
library(rgl)
library(rayshader)

simple_matrix = matrix(c(0, 1, 0, 0),2)

simple_map = simple_matrix %>%
  sphere_shade(texture = "desert")

options(rgl.useNULL = TRUE,
        rgl.printRglwidget = TRUE)

rgl::clear3d()

simple_map %>%
  plot_3d(simple_matrix,

          # Render base
          solid = TRUE,
          soliddepth = -0.50, #"auto" (= lowest_depth-1)
          solidcolor = "red",
          solidlinecolor = "blue",

        )

rgl::rglwidget()

image

maybegeek commented 3 years ago

hi there,

same here:

grafik

bayr_matrix %>% 
  rayshader::sphere_shade(texture = "imhof2") %>%
  rayshader::plot_3d(
    bayr_matrix,
    zscale = 6,
    theta = 0,
    asp = 1/cospi(mean_latitude/180)
  )
> packageVersion("rgl")
[1] ‘0.105.13’
> packageVersion("rayshader")
[1] ‘0.24.2’
maybegeek commented 3 years ago

the lines are gone : )

> packageVersion("rgl")
[1] ‘0.105.22’
> packageVersion("rayshader")
[1] ‘0.24.2’
tylermorganwall commented 3 years ago

Yes, this was a bug in rgl. It appears to be fixed: see https://github.com/dmurdoch/rgl/issues/33.