Change Material

Change individual material properties, leaving others alone.

change_material(
  mesh,
  id = NULL,
  diffuse = NULL,
  ambient = NULL,
  specular = NULL,
  transmittance = NULL,
  emission = NULL,
  shininess = NULL,
  ior = NULL,
  dissolve = NULL,
  illum = NULL,
  texture_location = NULL,
  normal_texture_location = NULL,
  specular_texture_location = NULL,
  ambient_texture_location = NULL,
  emissive_texture_location = NULL,
  diffuse_intensity = NULL,
  specular_intensity = NULL,
  emission_intensity = NULL,
  ambient_intensity = NULL,
  culling = NULL,
  type = NULL,
  translucent = NULL,
  toon_levels = NULL,
  toon_outline_width = NULL,
  toon_outline_color = NULL,
  reflection_intensity = NULL,
  reflection_sharpness = NULL
)

Arguments

mesh

Mesh to change.

id

Default `NULL`. Either a number specifying the material to change, or a character vector matching the material name.

diffuse

Default `NULL`. The diffuse color.

ambient

Default `NULL`. The ambient color.

specular

Default `NULL`. The specular color.

transmittance

Default `NULL`. The transmittance

emission

Default `NULL`. The emissive color.

shininess

Default `NULL`. The shininess exponent.

ior

Default `NULL`. The index of refraction. If this is not equal to `1.0`, the material will be refractive.

dissolve

Default `NULL`. The transparency.

illum

Default `NULL`. The illumination.

texture_location

Default `NULL`. The diffuse texture location.

normal_texture_location

Default `NULL`. The normal texture location.

specular_texture_location

Default `NULL`. The specular texture location.

ambient_texture_location

Default `NULL`. The ambient texture location.

emissive_texture_location

Default `NULL`. The emissive texture location.

diffuse_intensity

Default `NULL`. The diffuse intensity.

specular_intensity

Default `NULL`. The specular intensity.

emission_intensity

Default `NULL`. The emission intensity.

ambient_intensity

Default `NULL`. The ambient intensity.

culling

Default `NULL`. The culling type. Options are `back`, `front`, and `none`.

type

Default `NULL`. The shader type. Options include `diffuse`,`phong`,`vertex`, and `color`.

translucent

Default `NULL`. Whether light should transmit through a semi-transparent material.

toon_levels

Default `NULL`. Number of color breaks in the toon shader.

toon_outline_width

Default `NULL`. 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.

toon_outline_color

Default `NULL`. Toon outline color.Note: setting this property via this function currently does not color outlines. Specify it during object creation.

reflection_intensity

Default `NULL`. Intensity of the reflection of the environment map, if present. This will be ignored if the material is refractive.

reflection_sharpness

Default `NULL`. Sharpness of the reflection, where lower values have blurrier reflections. Must be greater than zero and less than one.

Value

Shape with new material settings

Examples

# \dontshow{
options("cores"=1)
# }
p_sphere = sphere_mesh(position=c(555/2,555/2,555/2), 
                      radius=40,material=material_list(diffuse="purple"))
# \donttest{            
generate_cornell_mesh() %>% 
 add_shape(p_sphere) %>% 
 add_shape(change_material(translate_mesh(p_sphere,c(200,0,0)),diffuse="red")) %>% 
 add_shape(change_material(translate_mesh(p_sphere,c(100,0,0)),dissolve=0.5)) %>% 
 add_shape(change_material(translate_mesh(p_sphere,c(-100,0,0)),type="phong")) %>% 
 add_shape(change_material(translate_mesh(p_sphere,c(-200,0,0)),type="phong",shininess=30)) %>% 
 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` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }