# aego/material

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

Use `material.Builtin("Flash")`, `Dissolve`, `Outline`, `Additive`, `PixelSnap`, `Unlit`, `Lit` or `LitMesh2D` (`Default` is an alias for Unlit). Unknown names fault. Lit and LitMesh2D evaluate each selected light against the receiver's own surface normal. `material.Assign` writes the current world's SpriteRenderer or Mesh2D reference. For custom assets, assign an exported `AssetRef<Material>` or set the component's Material property.

```aes run
package demo

import (
    "aego/material"
    "aego/log"
)

script SharedMaterial {
    func Ready() {
        ref := material.Builtin("Flash")
        sprite := node.Get<SpriteRenderer>()
        if sprite != nil {
            material.Assign(node, ref)
        }
        weights := material.Vec4{0.1, 0.2, 0.3, 0.4}
        log.Info("Flash reference available; numeric lane X=" + string(weights.X))
    }
}
```

For a node with MaterialOverride, use `SetFloat`, `SetInt`, `SetBool`, `SetVec2`, `SetVec3`, `SetVec4`, `SetColor`, their matching getters, and `Reset`. An ordinary vec4 uses `material.Vec4`; a color parameter uses linear `Color`. Type mismatches fail before changing the node.

## Assign

```
func Assign(node NodeRef, material AssetRef<material>)
```

Changes the SpriteRenderer or Mesh2D material reference in this world.

## Builtin

```
func Builtin(name string) AssetRef<material>
```

Returns Unlit (Default), Additive, Flash, Dissolve, Outline or PixelSnap. Lit belongs to the lighting module.

## Shader

```
func Shader(name string) AssetRef<shader>
```

Returns the prepared shader reference for a named built-in material.
