specular
The specular highlight applied to the entity.
Declaration
var specular: PhysicallyBasedMaterial.Specular { get set }Mentioned in
Discussion
In Physically Based Rendering (PBR), specular highlights primarily come from the object’s roughness value. RealityKit automatically renders materials that have a low roughness value with specular highlights based on the environment lighting and the shape of the entity. As a result, for most materials, you won’t need to specify a specular value when using PhysicallyBasedMaterial.
For some types of dielectric (nonmetallic) materials, like facet-cut glass or gems, PBR algorithms don’t create bright enough specular highlights using just roughness. To accurately simulate those types of materials, use the specular property to specify additional specular for the entity.
The following example demonstrates how to specify specular using a single value for the entire material:
material.specular = .init(floatLiteral: 0.8)This example shows how to specify specular using a UV-mapped image texture:
if let specularResource = try? TextureResource.load(named:"entity_specular") {
let specularMap = MaterialParameters.Texture(specularResource)
material.specular = .init(texture: specularMap)
}