TODO: Document GLSL Shaders

A ShaderParameter instance represents a single input parameter of a shader kernel. A kernel can be defined to accept zero, one, or more parameters that are used in the kernel execution. A ShaderParameter provides information about the parameter, such as the type of data it expects. It also provides a mechanism for setting the parameter value that is used when the shader executes. To specify a value or values for the shader parameter, create an Array containing the value or values and assign it to the value property.

A ShaderParameter instance representing a parameter for a Shader instance is accessed as a property of the Shader instance's data property. The ShaderParameter property has the same name as the parameter's name in the shader code. For example, if a shader defines a parameter named radius, the ShaderParameter instance representing the radius parameter is available as the radius property, as shown here:

var radiusParam:ShaderParameter =;

In addition to the defined properties of the ShaderParameter class, each ShaderParameter instance has additional properties corresponding to any metadata defined for the parameter. These properties are added to the ShaderParameter object when it is created. The properties' names match the metadata names specified in the shader's source code. The data type of each property varies according to the data type of the corresponding metadata. A text metadata value such as "description" is a String instance. A metadata property with a non-string value (such as minValue or defaultValue) is represented as an Array instance. The number of elements and element data types correspond to the metadata values.

For example, suppose a shader includes the following two parameter declarations:

parameter float2 size
	description: "The size of the image to which the kernel is applied";
	minValue: float2(0.0, 0.0);
	maxValue: float2(100.0, 100.0);
	defaultValue: float2(50.0, 50.0);

parameter float radius
	description: "The radius of the effect";
	minValue: 0.0;
	maxValue: 50.0;
	defaultValue: 25.0;

The ShaderParameter instance corresponding to the size parameter has the following metadata properties in addition to its built-in properties:

Property nameData typeValue
descriptionString"The size of the image to which the kernel is applied"
minValueArray[0, 0]
maxValueArray[100, 100]
defaultValueArray[50, 50]

The ShaderParameter corresponding to the radius parameter has the following additional properties:

Property nameData typeValue
descriptionString"The radius of the effect"

Generally, developer code does not create a ShaderParameter instance directly. A ShaderParameter instance is created for each of a shader's parameters when the Shader instance is created.




@SuppressWarnings("checkstyle:Dynamic")read onlyindex:Dynamic

The zero-based index of the parameter.

read onlytype:ShaderParameterType

The data type of the parameter as defined in the shader. The set of possible values for the type property is defined by the constants in the ShaderParameterType class.


The value or values that are passed in as the parameter value to the shader. The value property is an indexed Array. The number and type of the elements of the Array correspond to the data type of the parameter, which can be determined using the type property. The following table indicates the parameter type and corresponding number and data type of the value Array's elements:

Parameter type# ElementsElement data type
float (ShaderParameterType.FLOAT)1Number
float2 (ShaderParameterType.FLOAT2)2Number
float3 (ShaderParameterType.FLOAT3)3Number
float4 (ShaderParameterType.FLOAT4)4Number
int (ShaderParameterType.INT)1int or uint
int2 (ShaderParameterType.INT2)2int or uint
int3 (ShaderParameterType.INT3)3int or uint
int4 (ShaderParameterType.INT4)4int or uint
bool (ShaderParameterType.BOOL)1Boolean
bool2 (ShaderParameterType.BOOL2)2Boolean
bool3 (ShaderParameterType.BOOL3)3Boolean
bool4 (ShaderParameterType.BOOL4)4Boolean
float2x2 (ShaderParameterType.MATRIX2X2)4Number
float3x3 (ShaderParameterType.MATRIX3X3)9Number
float4x4 (ShaderParameterType.MATRIX4X4)16Number

For the matrix parameter types, the array elements fill the rows of the matrix, then the columns. For example, suppose the following line of ActionScript is used to fill a float2x2 parameter named myMatrix: = [.1, .2, .3, .4];

Within the shader, the matrix elements have the following values:

  • myMatrix[0][0]: .1
  • myMatrix[0][1]: .2
  • myMatrix[1][0]: .3
  • myMatrix[1][1]: .4