"lang" { "Tokens" { "DynamicExpressions" "Dynamic Expressions" "DynamicExpressions:help" "Material expressions look very similar to HLSL code. Expressions can have one of two basic structures: A simple inline expression that's just one math expression.

sin(SomeAttribute)
10 + sqrt( 2 ) * frac( time() )


Expressions can also be composed of multiple intermediate expressions -- each of which computes a temporary value -- followed by a return expression that uses the intermediate values.

tempVar1 = sin(SomeAttribute);
tempVar2 = exists(SomeOtherAttribute) ? float4( 1, 2, 3, 4 ) : float4( 5, 6, 7, 8 );
tempVar3 = cos(tempVar1)
return tempVar1 + dot4( tempVar2, SomeThirdAttribute.xyzz ) * tempVar3;


Identifiers

Identifiers in expressions can refer either to intermediate values stored in local variables (e.g. tempVar1 in the example above) or to attributes supplied by game code (e.g. SomeAttribute in the example above). If an identifier isn't a local variable it is assumed to be supplied by game code.
If an expression relies on a value supplied by game code but the code doesn't provide it, expression evaluation will silently fail and the value of the parameter with the expression will fall back to the value set for the parameter in the material.

Data Types

The internal type for computations is float4, everything gets converted to a four-component float internally by smearing the last specified component into the remaining ones. Any scalar function is applied to all four components of the input vectors. Any function that returns a scalar result will output the same result to all four components.

Operators

Supported operators in order of precedence:
Click Here For Built-in Functions " "Functions" "Built-in Functions" "Functions:help" "All functions take float4() as parameters. All scalar operations will be applied to all four components of the input.
For example:
sin(vSomeVector) will compute the output vector (sin(vSomeVector.x),sin(vSomeVector.y),sin(vSomeVector.z),sin(vSomeVector.w)) " } }