tylermorganwall / rayshader

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

plot_3d: Subscript out of bound #222

Closed simoncarrignon closed 2 years ago

simoncarrignon commented 2 years ago

Using the actual github version of rayshader_(0.27.4, plot_3d return the error below:

Error in `[<-`(`*tmp*`, i, j, value = (dnorm(power * x[i], mean = 0, sd = sd) *  : 
  subscript out of bounds

A simple way to test:

plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))

With the version of rayshader on cran (0.24.10) it works and return a warning:

> library(rayshader)
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Warning message:
In make_shadow(heightmap, shadowdepth, shadowwidth, background,  :
  `magick` package required for smooth shadow--using basic shadow instead.

image

installing magick (install.package("magick")) solves the issue for rayshader_0.27.4.

I struggled a lot to understand what was happening so I open the issue here it may help someone facing the same problem.

tylermorganwall commented 2 years ago

I am not able to reproduce this bug on my system (I do not get the error). Be sure to update the rayimage package and all other packages.

When you say installing magick solved this issue, do you mean the original error message above with version 0.27.4 or the warning message?

simoncarrignon commented 2 years ago

Without magick I get a warning with 0.24.10 (which is good) and an error with 0.27.4 . With magick installed both disappear.

I reproduced it on one Ubuntu 21.04 machine and on debian stable buster (debian 10) and one Debian stable (Debian 11 bullseye). Here the output with my debian 10. Note that before the sessionInfo() I ran a devtools::install_github("tylermorganwall/rayshader")

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] ps_1.6.0          prettyunits_1.1.1 rprojroot_2.0.2   crayon_1.4.2     
 [5] withr_2.4.3       R6_2.5.1          lifecycle_1.0.1   magrittr_2.0.2   
 [9] rlang_1.0.1       cachem_1.0.6      cli_3.1.1         curl_4.3.2       
[13] remotes_2.4.2     fs_1.5.2          testthat_3.1.1    callr_3.7.0      
[17] ellipsis_0.3.2    desc_1.4.0        devtools_2.4.3    tools_4.1.2      
[21] glue_1.6.1        purrr_0.3.4       pkgload_1.2.4     fastmap_1.1.0    
[25] compiler_4.1.2    processx_3.5.2    pkgbuild_1.3.1    sessioninfo_1.2.2
[29] memoise_2.0.1     usethis_2.1.5    
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Error in plot_3d(matrix(1:200, ncol = 10, nrow = 10), hillshade = matrix(rep(0.5,  : 
  could not find function "plot_3d"
> library(rayshader)
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Error in `[<-`(`*tmp*`, i, j, value = (dnorm(power * x[i], mean = 0, sd = sd) *  : 
  subscript out of bounds
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Error in `[<-`(`*tmp*`, i, j, value = (dnorm(power * x[i], mean = 0, sd = sd) *  : 
  subscript out of bounds
> install.packages("magick")
Installing package into ‘/home/simon/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/magick_2.7.3.tar.gz'
Content type 'application/x-gzip' length 4813163 bytes (4.6 MB)
==================================================
downloaded 4.6 MB

* installing *source* package ‘magick’ ...
** package ‘magick’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6
Using PKG_LIBS=-lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c animation.cpp -o animation.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c attributes.cpp -o attributes.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c base.cpp -o base.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c color.cpp -o color.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c composite.cpp -o composite.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c config.cc -o config.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c convolve.cpp -o convolve.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c device.cpp -o device.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c edges.cpp -o edges.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c edit.cpp -o edit.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c fonts.cpp -o fonts.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c options.cpp -o options.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c properties.cpp -o properties.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c resize.cpp -o resize.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c segment.cpp -o segment.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include'   -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c transformations.cpp -o transformations.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-z,relro -o magick.so RcppExports.o animation.o attributes.o base.o color.o composite.o config.o convolve.o device.o edges.o edit.o fonts.o options.o properties.o resize.o segment.o transformations.o -lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16 -L/usr/lib/R/lib -lR
installing to /home/simon/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-magick/00new/magick/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (magick)

The downloaded source packages are in
        ‘/tmp/RtmpuGkfVH/downloaded_packages’
> 
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
> 
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rayshader_0.27.4

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8        compiler_4.1.2    prettyunits_1.1.1 remotes_2.4.2    
 [5] iterators_1.0.13  tools_4.1.2       progress_1.2.2    testthat_3.1.1   
 [9] digest_0.6.29     pkgbuild_1.3.1    pkgload_1.2.4     jsonlite_1.7.3   
[13] memoise_2.0.1     lifecycle_1.0.1   png_0.1-7         pkgconfig_2.0.3  
[17] rlang_1.0.1       foreach_1.5.2     cli_3.1.1         magick_2.7.3     
[21] curl_4.3.2        parallel_4.1.2    xfun_0.29         fastmap_1.1.0    
[25] knitr_1.37        withr_2.4.3       desc_1.4.0        fs_1.5.2         
[29] vctrs_0.3.8       htmlwidgets_1.5.4 devtools_2.4.3    hms_1.1.1        
[33] rprojroot_2.0.2   glue_1.6.1        R6_2.5.1          processx_3.5.2   
[37] rgl_0.108.3       sessioninfo_1.2.2 callr_3.7.0       purrr_0.3.4      
[41] magrittr_2.0.2    ps_1.6.0          codetools_0.2-18  ellipsis_0.3.2   
[45] htmltools_0.5.2   usethis_2.1.5     rayimage_0.6.2    doParallel_1.0.16
[49] cachem_1.0.6      crayon_1.4.2     
> remove.packages(c("rayshader","magick"))
Removing packages from ‘/home/simon/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
> unloadNamespace
unloadNamespace
> unloadNamespace(c("rayshader","magick"))
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))                        
Error in plot_3d(matrix(1:200, ncol = 10, nrow = 10), hillshade = matrix(rep(0.5,  : 
  could not find function "plot_3d"
> install.packages("rayshader")
Installing package into ‘/home/simon/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rayshader_0.24.10.tar.gz'
Content type 'application/x-gzip' length 2763596 bytes (2.6 MB)
==================================================
downloaded 2.6 MB

* installing *source* package ‘rayshader’ ...
** package ‘rayshader’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c bilineargrid.cpp -o bilineargrid.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c calculate_normal.cpp -o calculate_normal.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c construct_matrix.cpp -o construct_matrix.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c find_groups.cpp -o find_groups.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c interpolate_color.cpp -o interpolate_color.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c lambshade.cpp -o lambshade.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c make_base_cpp.cpp -o make_base_cpp.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c pointspread.cpp -o pointspread.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rayshade.cpp -o rayshade.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/progress/include' -I'/home/simon/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'    -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/buster/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rayshade_multicore.cpp -o rayshade_multicore.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-z,relro -o rayshader.so RcppExports.o bilineargrid.o calculate_normal.o construct_matrix.o find_groups.o interpolate_color.o lambshade.o make_base_cpp.o pointspread.o rayshade.o rayshade_multicore.o -L/usr/lib/R/lib -lR
installing to /home/simon/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-rayshader/00new/rayshader/libs
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
Warning: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Warning: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
Warning: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
** testing if installed package keeps a record of temporary installation path
* DONE (rayshader)

The downloaded source packages are in
        ‘/tmp/RtmpuGkfVH/downloaded_packages’
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Error in plot_3d(matrix(1:200, ncol = 10, nrow = 10), hillshade = matrix(rep(0.5,  : 
  could not find function "plot_3d"
> library(rayshader)
> plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10))
Warning message:
In make_shadow(heightmap, shadowdepth, shadowwidth, background,  :
  `magick` package required for smooth shadow--using basic shadow instead.

Something like this may allow to reproduce all, thought I am not sure about the unloadNamespace, maybe safer to close the session and restart it.

remove.packages(c("magick","rayshader")) #remove previous version of the packages
unloadNamespace(c("magick","rayshader")) #maybe close and restart R here
devtools::install_github("tylermorganwall/rayshader") #install actual github version
library(rayshader) 
plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10)) #this should return the error
install.packages("magick") #install magick
plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10)) #this should work
remove.packages(c("magick","rayshader")) #remove the newly installed packages
unloadNamespace(c("magick","rayshader")) #maybe close and restart R here
install.packages("rayshader") #install Rcran rayshader (2.4.10)
library(rayshader) 
plot_3d(matrix(1:200,ncol=10,nrow=10),hillshade=matrix(rep(.5,100),ncol=10,nrow=10)) #this should return the warning
tylermorganwall commented 2 years ago

So I've figured this out—the small dimensions of the height matrix ran into a bug in the automatic shadow generation. Update to the latest GH version of rayimage (which should properly handle the kernel) and the latest version of rayshader (which ensures a minimum shadow width size) to fix it.