Shader class

A shader Resource that represents a compiled shader program and the uniform data that will be bound to it.

Uniform values are set by string key ('VertexInfo.model', 'Lights.positions[0]', 'someColor') and are automatically packed into GPU buffers using shader reflection for layout.

Samplers are auto-detected at compile time via gpu.UniformSlot.sizeInBytes returning null — no need to declare them separately.

Inheritance
Implementers

Constructors

Shader.fromAsset(String assetName, {required String entryPoint, List<String> slots = const []})
Load a Shader from asset.

Properties

entryPoint String
The shader entry point name within the bundle.
final
hashCode int
The hash code for this object.
no setterinherited
recreateResource bool
getter/setter pairinherited
resource Shader
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
slots List<String>
Names of all uniform slots — both struct blocks and samplers.
final

Methods

bind(GraphicsDevice device) → void
Bind all uniform data and textures to the device.
createResource() Shader
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setColor(String key, Color color) → void
Set a Color at the given key.
setFloat(String key, double value) → void
Set a double at the given key.
setMatrix2(String key, Matrix2 matrix) → void
Set a Matrix2 at the given key.
setMatrix3(String key, Matrix3 matrix) → void
Set a Matrix3 at the given key.
setMatrix4(String key, Matrix4 matrix) → void
Set a Matrix4 at the given key.
setTexture(String key, Texture texture) → void
Set a Texture at the given key.
setUint(String key, int value) → void
Set an int (encoded as uint) at the given key.
setVector2(String key, Vector2 vector) → void
Set a Vector2 at the given key.
setVector3(String key, Vector3 vector) → void
Set a Vector3 at the given key.
setVector4(String key, Vector4 vector) → void
Set a Vector4 at the given key.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

parseKey(String key) → (String, String?, int?)
Parse a uniform key into (structName, memberName, arrayIndex).