#Load the included example R object file, by calling the r_obj() function. This
#returns the local file path to the `r.txt` obj file. The file extension is "txt"
#due to package constraints, but the file contents are identical and it does not
#affect the function.
if(rayrender:::run_documentation()) {
generate_ground(material = diffuse(checkercolor = "grey50")) %>%
add_object(obj_model(y = -0.8, filename = r_obj(),
material = microfacet(color = "gold", roughness = 0.05))) %>%
add_object(obj_model(x = 1.8, y = -0.8, filename = r_obj(),
material = diffuse(color = "dodgerblue"))) %>%
add_object(obj_model(x = -1.8, y = -0.8, filename = r_obj() ,
material = dielectric(attenuation = c(1,0.3,1)*2))) %>%
add_object(sphere(z = 20, x = 20, y = 20, radius = 10,
material = light(intensity = 10))) %>%
render_scene(parallel = TRUE, samples = 128, aperture = 0.05,
fov = 32, lookfrom = c(0, 2, 10))
}
#Use scale_obj to make objects bigger--this is more robust than the generic scale argument.
if(rayrender:::run_documentation()) {
generate_ground(material = diffuse(checkercolor = "grey50")) %>%
add_object(obj_model(y = -0.8, filename = r_obj(), scale_obj = 2,
material = diffuse(noise = TRUE, noiseintensity = 10,noisephase=45))) %>%
add_object(sphere(z = 20, x = 20, y = 20, radius = 10,
material = light(intensity = 10))) %>%
render_scene(parallel = TRUE, samples = 128, ambient = TRUE,
backgroundhigh="blue", backgroundlow="red",
aperture = 0.05, fov = 32, lookfrom = c(0, 2, 10),
lookat = c(0,1,0))
}
Run the code above in your browser using DataLab