R语言rayrender包,microfacet微面材料

R语言rayrender包,microfacet微面材料

# Tue Jul 13 03:14:53 2021 -

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

?   microfacet  #   微面材料。
generate_cornell() %>%
  add_object(ellipsoid(x=555/2,555/2,y=150, a=100,b=150,c=100,
                       material=microfacet(roughness=0.1,
                                           eta=c(0.216,0.42833,1.3184), kappa=c(3.239,2.4599,1.8661)))) %>%
  render_scene(lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
               aperture=0, fov=40, parallel=TRUE,clamp_value=10)

#使粗糙度各向异性(水平或垂直),在前面添加额外的灯光
#展示不同的微平面方向
generate_cornell() %>%
  add_object(sphere(x=555/2,z=50,y=75,radius=20,material=light())) %>%
  add_object(ellipsoid(x=555-150,555/2,y=150, a=100,b=150,c=100,
                       material=microfacet(roughness=c(0.3,0.1),
                                           eta=c(0.216,0.42833,1.3184), kappa=c(3.239,2.4599,1.8661)))) %>%
  add_object(ellipsoid(x=150,555/2,y=150, a=100,b=150,c=100,
                       material=microfacet(roughness=c(0.1,0.3),
                                           eta=c(0.216,0.42833,1.3184), kappa=c(3.239,2.4599,1.8661)))) %>%
  render_scene(lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
               aperture=0, fov=40,  parallel=TRUE,clamp_value=10)

#用一个较小的金蛋在前面渲染一个粗糙的银色R
generate_cornell() %>%
  add_object(obj_model(r_obj(),x=555/2,z=350,y=0, scale_obj = 200, angle=c(0,200,0),
                       material=microfacet(roughness=0.2,
                                           eta=c(1.1583,0.9302,0.5996), kappa=c(6.9650,6.396,5.332)))) %>%
  add_object(ellipsoid(x=200,z=200,y=80, a=50,b=80,c=50,
                       material=microfacet(roughness=0.1,
                                           eta=c(0.216,0.42833,1.3184), kappa=c(3.239,2.4599,1.8661)))) %>%
  render_scene(lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
               aperture=0, fov=40, parallel=TRUE,clamp_value=10)

#增加粗糙度
generate_cornell() %>%
  add_object(obj_model(r_obj(),x=555/2,z=350,y=0, scale_obj = 200, angle=c(0,200,0),
                       material=microfacet(roughness=0.5,
                                           eta=c(1.1583,0.9302,0.5996), kappa=c(6.9650,6.396,5.332)))) %>%
  add_object(ellipsoid(x=200,z=200,y=80, a=50,b=80,c=50,
                       material=microfacet(roughness=0.3,
                                           eta=c(0.216,0.42833,1.3184), kappa=c(3.239,2.4599,1.8661)))) %>%
  render_scene(lookfrom=c(278,278,-800),lookat = c(278,278,0), samples=500,
               aperture=0, fov=40, parallel=TRUE,clamp_value=10)
# Tue Jul 13 03:22:23 2021 --
dev.copy(png, "1.png");dev.off()

image.png

你可能感兴趣的:(R语言rayrender包,microfacet微面材料)