R语言rayrender包,metal,添加铝、铜、铅反光金属块

2021-08-22  本文已影响0人  youmigo

R语言rayrender包,metal,添加铝、铜、铅反光金属块

# Tue Jul 13 02:30:03 2021 -

# 字符编码:UTF-8
# R 版本:R 4.1 x64 for window 11
# cgh163email@163.com
# 个人笔记不负责任,拎了个梨🍐🍈
#.rs.restartR()
require(rayrender)
rm(list = ls());gc()

?   metal   #   金属材料。
scene = generate_cornell() %>%
  add_object(sphere(x=555/2,y=555/2,z=555/2,radius=555/8,
                    material=metal(eta=c(3.2176,3.1029,2.1839), k = c(3.3018,3.33,3.0339))))

render_scene(scene, lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=50,
             aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)

#添加铝制旋转闪亮金属块
scene = scene %>%
  add_object(cube(x=380,y=150/2,z=200,xwidth=150,ywidth=150,zwidth=150,
                  material = metal(eta = c(1.07,0.8946,0.523), k = c(6.7144,6.188,4.95)),angle=c(0,45,0)))

render_scene(scene, lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
             aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)

#添加铜金属立方体
scene = scene %>%
  add_object(cube(x=150,y=150/2,z=300,xwidth=150,ywidth=150,zwidth=150,
                  material = metal(eta = c(0.497,0.8231,1.338),
                                   k = c(2.898,2.476,2.298)),
                  angle=c(0,-30,0)))

render_scene(scene, lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
             aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)


#最后,让我们添加一个铅管
scene2 = scene %>%
  add_object(cylinder(x=450,y=200,z=400,length=400,radius=30,
                      material = metal(eta = c(1.44,1.78,1.9),
                                       k = c(3.18,3.36,3.43)),
                      angle=c(0,-30,0)))

render_scene(scene2, lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
             aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)

dev.copy(png, "3.png");dev.off()

1.png 2.png 3.png
上一篇下一篇

猜你喜欢

热点阅读