Class

SKUniform

A container for uniform shader data.

Declaration

@interface SKUniform : NSObject

Overview

An SKUniform object is used to hold uniform data for a custom OpenGL or OpenGL ES shader. The uniform data is accessible from all shaders that include the uniform.To use a uniform variable in your shader, create the SKUniform object and set its initial value. Once its value is specified, the uniformType property changes to match the type of the initial value you provided and can never change afterward. To use the uniform object, add it to an SKShader object that needs to access the uniform variable. To update the uniform variable’s value, choose the appropriate property on the uniform object based on the data type it encapsulates.

Topics

Creating and Initializing Uniform Objects

+ uniformWithName:

Creates and initializes a new uniform object.

+ uniformWithName:float:

Creates and initializes a new uniform object that holds a floating-point number.

+ uniformWithName:floatVector2:

Creates and initializes a new uniform object that holds a vector of two floating-point numbers.

Deprecated
+ uniformWithName:floatVector3:

Creates and initializes a new uniform object that holds a vector of three floating-point numbers.

Deprecated
+ uniformWithName:floatVector4:

Creates and initializes a new uniform object that holds a vector of four floating-point numbers.

Deprecated
+ uniformWithName:floatMatrix2:

Creates and initializes a new uniform object that holds a 2 x 2 matrix of floating-point numbers.

Deprecated
+ uniformWithName:floatMatrix3:

Creates and initializes a new uniform object that holds a 3 x 3 matrix of floating-point numbers.

Deprecated
+ uniformWithName:floatMatrix4:

Creates and initializes a new uniform object that holds a 4 x 4 matrix of floating-point numbers.

Deprecated
+ uniformWithName:texture:

Creates and initializes a new uniform object that holds a reference to a texture.

- initWithName:

Initializes a new uniform object.

- initWithName:float:

Initializes a new uniform object that holds a floating-point number.

- initWithName:floatVector2:

Initializes a new uniform object that holds a vector of two floating-point numbers.

Deprecated
- initWithName:floatVector3:

Creates and initializes a new uniform object that holds a vector of three floating-point numbers.

Deprecated
- initWithName:floatVector4:

Initializes a new uniform object that holds a vector of four floating-point numbers.

Deprecated
- initWithName:floatMatrix2:

Initializes a new uniform object that holds a 2 x 2 matrix of floating-point numbers.

Deprecated
- initWithName:floatMatrix3:

Initializes a new uniform object that holds a 3 x 3 matrix of floating-point numbers.

Deprecated
- initWithName:floatMatrix4:

Initializes a new uniform object that holds a 4 x 4 matrix of floating-point numbers.

Deprecated
- initWithName:texture:

Initializes a new uniform object that holds a reference to a texture.

Reading Information About a Uniform

name

The uniform’s name.

uniformType

The uniform object’s data type.

Reading and Writing an Uniform Object’s Value

You should only read or write the property type that matches the type of the uniform object; it is a programming error to use any of the other properties.

floatValue

The receiver’s value as a floating-point value.

floatVector2Value

The receiver’s value as a vector of two floating-point values.

Deprecated
floatVector3Value

The receiver’s value as a vector of three floating-point values.

Deprecated
floatVector4Value

The receiver’s value as a vector of four floating-point values.

Deprecated
floatMatrix2Value

The receiver’s value as a 2 x 2 matrix of floating-point values.

Deprecated
floatMatrix3Value

The receiver’s value as a 3 x 3 matrix of floating-point values.

Deprecated
floatMatrix4Value

The receiver’s value as a 4 x 4 matrix of floating-point values.

Deprecated
textureValue

The receiver’s value as a SpriteKit texture.

Constants

SKUniformType

An enumerated type to identify the type of a uniform object.

Relationships

Inherits From

See Also

Shaders

SKShader

An object that allows you to apply a custom fragment shader.

SKAttribute

A specification for dynamic per-node data used with a custom shader.

SKAttributeValue

A container for dynamic shader data associated with a node.