R语言rayrender包,csg_onion立体放置操作

2021-07-30  本文已影响0人  youmigo

R语言rayrender包,csg_onion立体放置操作

# Wed Jun 16 00:56:14 2021 -

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

# csg_onion立体放置操作
#切一个球体:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
  add_object(csg_object(csg_combine(
    csg_onion(csg_sphere(z=2,x=2,radius=1), thickness = 0.2),
    csg_box(y=1,width=c(10,2,10)), operation = "subtract"),
    material=glossy(color="red"))) %>%
  add_object(csg_object(csg_combine(
    csg_onion(csg_sphere(radius=1), thickness = 0.4),
    csg_box(y=1,width=c(10,2,10)), operation = "subtract"),
    material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_combine(
    csg_onion(csg_sphere(z=-2.5,x=-2.5,radius=1), thickness = 0.6),
    csg_box(y=1,width=c(10,2,10)), operation = "subtract"),
    material=glossy(color="green"))) %>%
  add_object(sphere(y=5,x=5,radius=2,material=light())) %>%
  render_scene(clamp_value=10,lookat=c(0,-0.5,0),
               lookfrom=c(3,5,10),fov=35)

#多层洋葱:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
  add_object(csg_object(csg_combine(
    csg_onion(csg_onion(csg_onion(csg_sphere(radius=1), 0.4), 0.2),0.1),
    csg_box(y=1,width=c(10,2,10)), operation = "subtract"),
    material=glossy(color="purple"))) %>%
  add_object(sphere(y=5,x=5,radius=2,material=light())) %>%
  render_scene(clamp_value=10,lookat=c(0,-0.5,0),
               lookfrom=c(3,5,10),fov=20)

#洋葱与介电球体形成气泡:
generate_cornell() %>%
  add_object(csg_object(
    csg_onion(csg_sphere(x=555/2,y=555/2,z=555/2, radius=150), 5),
    material=dielectric(attenuation=c(1,1,0.3)/100))) %>%
  render_scene(clamp_value=10)

#在气泡中生成气泡的多个操作:
generate_cornell() %>%
  add_object(csg_object(
    csg_onion(csg_onion(csg_sphere(x=555/2,y=555/2,z=555/2, radius=150), 10),5),
    material=dielectric(attenuation=c(1,1,0.3)/100))) %>%
  render_scene(clamp_value=10)
# Wed Jun 16 00:58:04 2021 --
dev.copy(png, "3.png");dev.off()

上一篇下一篇

猜你喜欢

热点阅读