Set the material(s) of the mesh.
set_material(
mesh,
material = NULL,
id = NULL,
diffuse = c(0.5, 0.5, 0.5),
ambient = c(0, 0, 0),
specular = c(1, 1, 1),
transmittance = c(0, 0, 0),
emission = c(0, 0, 0),
shininess = 50,
ior = 1,
dissolve = 1,
illum = 1,
texture_location = "",
normal_texture_location = "",
bump_texture_location = "",
specular_texture_location = "",
ambient_texture_location = "",
emissive_texture_location = "",
diffuse_intensity = 1,
bump_intensity = 1,
specular_intensity = 1,
emission_intensity = 1,
ambient_intensity = 1,
culling = "back",
type = "diffuse",
translucent = TRUE,
toon_levels = 5,
toon_outline_width = 0.05,
toon_outline_color = "black",
reflection_intensity = 0,
reflection_sharpness = 0,
two_sided = FALSE,
sigma = 0
)The target mesh.
Default NULL. You can pass the output of material_list()
to specify the material, or use the following individual settings.
Default 1. Either a number specifying the material to change, or a character vector
matching the material name.
Default c(0.5,0.5,0.5). The diffuse color.
Default c(0,0,0). The ambient color.
Default c(1,1,1). The specular color.
Default c(0,0,0). The transmittance.
Default c(0,0,0). The emissive color.
Default 50.0. The shininess exponent.
Default 1.0. The index of refraction. If this is not equal to 1.0, the material will be refractive.
Default 1.0. The transparency.
Default 1.0. The illumination.
Default "". The diffuse texture location.
Default "". The normal texture location.
Default "". The bump texture location.
Default "". The specular texture location.
Default "". The ambient texture location.
Default "". The emissive texture location.
Default 1. The diffuse intensity.
Default 1. The bump intensity.
Default 1. The specular intensity.
Default 1. The emission intensity.
Default 1. The ambient intensity.
Default "back". The culling type. Options are back, front, and none.
Default "diffuse". The shader type. Options include diffuse,phong,vertex, and color.
Default TRUE. Whether light should transmit through a semi-transparent material.
Default 5. Number of color breaks in the toon shader.
Default 0.05. Expansion term for model to specify toon outline width. Note: setting this property via this function currently does not generate outlines. Specify it during object creation.
Default black. Toon outline color. Note: setting this property via this function currently does not color outlines. Specify it during object creation.
Default 0.0. Intensity of the reflection of the environment map, if present. This will be ignored if the material is refractive.
Default 1.0. Sharpness of the reflection, where lower values have blurrier reflections. Must be greater than zero and less than one.
Default NULL. Whether diffuse materials should be two sided (normal is taken as the absolute value of the dot product of the light direction and the normal).
Default 0. Oren-Nayar angle.
Shape with new material
if(run_documentation()) {
#Set the material of an object
generate_cornell_mesh() |>
add_shape(set_material(sphere_mesh(position=c(400,555/2,555/2),radius=40),
diffuse="purple", type="phong")) |>
add_shape(set_material(sphere_mesh(position=c(555/2,220,555/2),radius=40),
dissolve=0.2,culling="none",diffuse="red")) |>
add_shape(set_material(sphere_mesh(position=c(155,300,555/2),radius=60),
material = material_list(diffuse="gold", type="phong",
ambient="gold", ambient_intensity=0.4))) |>
rasterize_scene(light_info=directional_light(direction=c(0.1,0.6,-1)))
}
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .