Node materials described as data.
{:shader my-shader ; (fn [uniforms] node-or-output-map)
:type :standard ; see material-types, default :basic
:uniforms {:time 0 :tint [1 0 0]}
:transparent true ; any other key is a material property
:blending :additive}
The shader fn receives a map of uniform nodes keyed like :uniforms and
returns a node (the material's colorNode) or a map of outputs:
{:color .. :opacity .. :position .. :normal .. :emissive .. :fragment ..},
each key k setting the material's <k>Node property.
Materials without :uniforms are shared between every owner using the same
spec. Materials with :uniforms are per owner. Changing only uniform values
writes uniform.value and never rebuilds the shader. Changing the shader
fn, the type, a property, or the set/kind of uniforms builds a new material.
So a hot reload that redefines the shader fn swaps materials in place the
next time the scene renders.
Node materials described as data.
{:shader my-shader ; (fn [uniforms] node-or-output-map)
:type :standard ; see `material-types`, default :basic
:uniforms {:time 0 :tint [1 0 0]}
:transparent true ; any other key is a material property
:blending :additive}
The shader fn receives a map of uniform nodes keyed like `:uniforms` and
returns a node (the material's colorNode) or a map of outputs:
`{:color .. :opacity .. :position .. :normal .. :emissive .. :fragment ..}`,
each key `k` setting the material's `<k>Node` property.
Materials without `:uniforms` are shared between every owner using the same
spec. Materials with `:uniforms` are per owner. Changing only uniform values
writes `uniform.value` and never rebuilds the shader. Changing the shader
fn, the type, a property, or the set/kind of uniforms builds a new material.
So a hot reload that redefines the shader fn swaps materials in place the
next time the scene renders.(acquire! owner spec)Material for owner (any object, typically the Mesh) described by spec.
Material for `owner` (any object, typically the Mesh) described by `spec`.
(dispose-unused!)Dispose shared materials no owner holds anymore. threeagent calls this when a scene is reset (hot reload).
Dispose shared materials no owner holds anymore. threeagent calls this when a scene is reset (hot reload).
(material-of owner)The material currently held by owner, if any.
The material currently held by `owner`, if any.
(release! owner)Drop owner's claim on its material. Per-owner materials are disposed;
shared ones stay cached until dispose-unused!.
Drop `owner`'s claim on its material. Per-owner materials are disposed; shared ones stay cached until `dispose-unused!`.
(spec? x)True when x describes a node material.
True when `x` describes a node material.
(uniforms-of owner)The uniform nodes of owner's material, keyed like its spec's :uniforms.
Handy for driving values imperatively (e.g. every frame from a system).
The uniform nodes of `owner`'s material, keyed like its spec's `:uniforms`. Handy for driving values imperatively (e.g. every frame from a system).
(update! owner spec)Bring owner's material in line with spec: writes uniform values when only
they changed, otherwise builds (or finds) a new material.
Bring `owner`'s material in line with `spec`: writes uniform values when only they changed, otherwise builds (or finds) a new material.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |