If a vertex transformation is included in the material, then the attributes passed in to the shaders for each vertex are often less useful. Use these values to refer to the position and normal after vertex transformations. Usually you always want to use these to calculate the amount of light reflected from a surface.
import { transformed } from "@hology/core/shader-nodes"
const position: Vec4Node = transformed.position // After applying vertex transform
const mvPosition: Vec4Node = transformed.mvPosition // After applying vertex transform and the model view matrix
const normal: Vec3Node = transformed.normal // Recalculated normal after applying the vertex transform
Custom attributes
You can also define your own attributes with attribute node classes.
import { AttributeVec3Node, Vec3Node } from "@hology/core/shader-nodes"
import { BoxGeometry } from 'three'
const customAttribute: Vec3Node = new AttributeVec3Node('myCustomAttribute')
const customAttributeValues = new Float32Array([
1, 1, 1,
1, 1, 1,
...
])
const geometry = new BoxGeometry(1,1,1)
geometry.setAttribute('myCustomAttribute', new THREE.BufferAttribute(customAttributeValues, 3));
The following classes exist to define your own attributes and the only constructor argument is the name of the attribute as it is defined when calling setAttribute on a .