Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

material.pbrMat (procNode)

A physically-based metallic-roughness material made from its maps, each with the factor the shader multiplies it by: base colour (baseColor, baseColorMap), metallic and roughness (metallic, roughness, metallicRoughnessMap in the glTF packing, green roughness and blue metallic), normal (normalMap, normalScale), occlusion (occlusionMap, occlusionStrength) and emissive (emissive, emissiveMap, emissiveIntensity). A map left out reads as its factor alone. The material draws with the standard metallic-roughness shader; material.shader makes a material of any other.

It answers one element whose Material attribute holds the material record, with the material kind stated on the detail attribute records. Any input that takes a material takes it (geometry.set_material, instances.set_material, elements.entity, instances.pack, instances.to_points), io.output shows it and io.export saves it as a .material, writing a Texture a map holds as a texture beside it.

local look = g.material.pbrMat({
    baseColorMap = asset.resolve("@builtin::models.Sample.AnisotropyBarnLamp.bundle.texture.Lamp_Metal_albedo", "texture"),
    normalMap = asset.resolve("@builtin::models.Sample.AnisotropyBarnLamp.bundle.texture.Lamp_Metal_normal", "texture"),
    occlusionMap = g.texture.noise({ width = 256, height = 256 }),
    roughness = 0.8,
})
local ball = g.geometry.set_material({ geometry = g.mesh.sphere({}), material = look })

Inputs

  • baseColor (Vec4, default { 1, 1, 1, 1 }). The base colour as {r, g, b, a} in 0-1, multiplied into baseColorMap.
  • baseColorMap (Texture or AssetRef<texture>, optional). The base-colour map: a texture.* node's output, or a reference to a .texture asset, read in sRGB.
  • metallic (Float, default 0, 0 to 1). How metallic the surface is, from 0 (a dielectric: plastic, stone, paint) to 1 (bare metal). Multiplied by the blue channel of metallicRoughnessMap.
  • roughness (Float, default 0.5, 0 to 1). How widely the surface scatters what it reflects, from 0 (mirror-sharp) to 1 (fully diffuse). Multiplied by the green channel of metallicRoughnessMap.
  • metallicRoughnessMap (Texture or AssetRef<texture>, optional). The metallic-roughness map in the glTF packing: green holds roughness, blue holds metallic.
  • normalMap (Texture or AssetRef<texture>, optional). A tangent-space normal map. Left out, the surface keeps the geometry's own normals.
  • normalScale (Float, default 1, 0 to 4). How strongly normalMap tilts the surface: 0 flat, 1 as the map states it.
  • occlusionMap (Texture or AssetRef<texture>, optional). An ambient-occlusion map, read from its red channel.
  • occlusionStrength (Float, default 1, 0 to 1). How much of occlusionMap darkens the surface.
  • emissive (Vec3, default { 0, 0, 0 }). Light the surface gives off itself, as {r, g, b}, multiplied into emissiveMap. Black gives off none, so an emissive map glows only where this is above 0.
  • emissiveMap (Texture or AssetRef<texture>, optional). Where and in what colour the surface glows, read in sRGB.
  • emissiveIntensity (Float, default 1, 0 to 64). A multiplier on the emitted light: values above 1 push it brighter than white.

Outputs

  • material (Geometry). One element whose Material attribute holds the material record.