A specification for dynamic per-node data used with a custom shader.
- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+
- watchOS 2.0+
To define an attribute for your shader, you create an
SKAttribute object with a unique name and data type, which is a
SKAttribute enum. After creating an
SKShader object, custom attributes are added to its
attributes array. Attribute values are set on the parent node with
set and can change for each execution of a shader without the need for recompilation.
The following listing shows how you can use an attribute to pass the size of a sprite into a shader using an attribute. In this example,
a is available as a global
vec2 within the GLSL code.