This object takes an object constructed using the `csg_*` functions. The object is drawn using ray marching/sphere tracing.
Object created with CSG interface.
Default `0`. x-offset of the center of the object.
Default `0`. y-offset of the center of the object.
Default `0`. z-offset of the center of the object.
Default diffuse
. The material, called from one of the material
functions diffuse
, metal
, or dielectric
.
Default `c(0, 0, 0)`. Angle of rotation around the x, y, and z axes, applied in the order specified in `order_rotation`.
Default `c(1, 2, 3)`. The order to apply the rotations, referring to "x", "y", and "z".
Default `FALSE`. Whether to flip the normals.
Default `c(1, 1, 1)`. Scale transformation in the x, y, and z directions. If this is a single value, number, the object will be scaled uniformly. Note: emissive objects may not currently function correctly when scaled.
Single row of a tibble describing the sphere in the scene.
Note: For dielectric objects, any other objects not included in the CSG object and nested inside will be ignored.
if(run_documentation()) {
#We will combine these three objects:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
add_object(csg_object(csg_box(), material=glossy(color="red"))) %>%
add_object(csg_object(csg_sphere(radius=0.707), material=glossy(color="green"))) %>%
add_object(csg_object(csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
material=glossy(color="blue"))) %>%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) %>%
render_scene(clamp_value=10, fov=15,lookfrom=c(5,5,10),
samples=128, sample_method="sobol_blue")
}
if(run_documentation()) {
#Standard CSG sphere + box - crossed cylinder combination:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
add_object(csg_object(csg_combine(
csg_combine(
csg_box(),
csg_sphere(radius=0.707),
operation="intersection"),
csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
operation="subtract"),
material=glossy(color="red"))) %>%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) %>%
render_scene(clamp_value=10, fov=10,lookfrom=c(5,5,10),
samples=128, sample_method="sobol_blue")
}
if(run_documentation()) {
#Blend them all instead:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
add_object(csg_object(csg_combine(
csg_combine(
csg_box(),
csg_sphere(radius=0.707),
operation="blend"),
csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
operation="blend"),
material=glossy(color="purple"))) %>%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) %>%
render_scene(clamp_value=10, fov=15,lookfrom=c(5,5,10),
samples=128, sample_method="sobol_blue")
}