threejs-worldgen
    Preparing search index...

    Function applyMaterialStatesTo

    • Applies the material states to a node material in place, starting from whatever it already outputs (its colorNode/roughnessNode/… if set, else its colour, maps and scalars). Sets alphaTest = 0.5 when foliage or cut-outs need it. Call once per material. Vertex colours are folded into the base colour (and vertexColors turned off); InstancedMesh.instanceColor still multiplies the result, so tint instances through colorNode instead if their snow and ash should stay white and grey.

      Type Parameters

      • T extends MeshStandardNodeMaterial

      Parameters

      Returns T

      const material = new MeshStandardNodeMaterial({ color: '#8a7f70', roughness: 0.8 })
      applyMaterialStatesTo(material, field.node()) // wet / snowy / burnt / damaged from a StateField
      applyMaterialStatesTo(leaves, instances.node(), { foliage: true })