-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path2019-04-02-mesh3d-rayshader-and-rayrender.R
70 lines (35 loc) · 1.53 KB
/
2019-04-02-mesh3d-rayshader-and-rayrender.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## ---- message=FALSE, warning=FALSE---------------------------------------
# Packages
library(raster)
library(dplyr)
library(Rvcg)
library(rgl)
library(rayshader)
library(rayrender)
# remotes::install_github("statnmap/mesh2ray")
library(mesh2ray)
library(magick)
# Directories
# extraWD <- tmpImgWD <- ""
## ---- echo=FALSE, eval=load----------------------------------------------
human_materials <- readr::read_rds(file.path(extraWD, "human_materials.rds"))
## ------------------------------------------------------------------------
human_materials
## ------------------------------------------------------------------------
# 3. Draw with rayrender
if (!file.exists(file.path(extraWD, "rayrender-human-scene.png"))) {
# _scene
scene <- generate_cornell(lightintensity = 20)
# _add cubes on scene with material data.frame /!\ A little long /!\
scene <- mesh2ray::add_cubes_to_scene(scene, cubes = human_cubes,
material = human_materials)
# _draw scene /!\ long calculation /!\
options(cores = 4)
render_scene(scene, width = 600, height = 600,
lookfrom = c(278, 278, -800) ,
lookat = c(278, 278, 0), fov = 40, ambient_light = FALSE,
samples = 500, parallel = TRUE, clamp_value = 5,
filename = file.path(tmpImgWD, "figure-html/rayrender-human-scene.png"))
}
## ---- warning=FALSE, message=FALSE---------------------------------------
attachment::att_from_rmd("2019-04-02-mesh3d-rayshader-and-rayrender.Rmd")