tylermorganwall / rayshader

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

Water lines do not render correctly with plot_3d() #127

Closed KHwong12 closed 3 years ago

KHwong12 commented 4 years ago

Not sure if this is the problem of rgl/my computer environment/other issues.

When plot_3d() is used to render the water layer, the water lines do not render correctly (not following zscale?). The water body is rendered correctly though. This does not happen when using render_water() to add water layer after rendering the elevation model with render_snapshot().

Any help would be greatly appreciated.

Render water layer with plot_3d

library(rayshader)

ZSCALE <- 50

montereybay %>%
  sphere_shade(texture = "imhof1") %>%
  plot_3d(montereybay, zscale = ZSCALE, fov = 0, theta = -45, phi = 45,
          water = TRUE, waterdepth = 500, wateralpha = 0.5, watercolor = "lightblue",
          waterlinecolor = "turquoise4", waterlinealpha = 0.5)

render_snapshot(clear = TRUE)

image


Render the base first, then render water layer

library(rayshader)

ZSCALE <- 50

montereybay %>%
  sphere_shade(texture = "imhof1") %>%
  plot_3d(montereybay, zscale = ZSCALE, fov = 0, theta = -45, phi = 45)

render_snapshot()

image

render_water(montereybay, zscale = ZSCALE,
             waterdepth = 500, wateralpha = 0.5, watercolor = "lightblue",
             waterlinecolor = "turquoise4", waterlinealpha = 0.5)

render_snapshot(clear = TRUE)

image

Created on 2020-09-22 by the reprex package (v0.3.0)

sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Catalina 10.15.4
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rayshader_0.19.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.5              compiler_4.0.2          later_1.1.0.1          
#>  [4] highr_0.8               prettyunits_1.1.1       iterators_1.0.12       
#>  [7] tools_4.0.2             progress_1.2.2          digest_0.6.25          
#> [10] lattice_0.20-41         jsonlite_1.7.0          evaluate_0.14          
#> [13] pkgconfig_2.0.3         png_0.1-7               rlang_0.4.7            
#> [16] foreach_1.5.0           shiny_1.5.0             magick_2.4.0           
#> [19] crosstalk_1.1.0.1       curl_4.3                yaml_2.2.1             
#> [22] parallel_4.0.2          xfun_0.16               fastmap_1.0.1          
#> [25] xml2_1.3.2              httr_1.4.2              raster_3.3-13          
#> [28] stringr_1.4.0           knitr_1.29              vctrs_0.3.3            
#> [31] htmlwidgets_1.5.1       hms_0.5.3               grid_4.0.2             
#> [34] manipulateWidget_0.10.1 webshot_0.5.2           R6_2.4.1               
#> [37] rgl_0.100.54            rmarkdown_2.3           sp_1.4-2               
#> [40] magrittr_1.5            codetools_0.2-16        promises_1.1.1         
#> [43] htmltools_0.5.0         mime_0.9                xtable_1.8-4           
#> [46] httpuv_1.5.4            stringi_1.4.6           miniUI_0.1.1.1         
#> [49] doParallel_1.0.15       crayon_1.3.4
tylermorganwall commented 3 years ago

Thanks for the bug report! This will be fixed in the next update.