Type Casting

There are three kinds of channels and variables available: color, float and vector. Most of the VSL objects repeat the same calculation to all sub channels independently. The user does not have to worry about the data type differences when building VSL code. VSL automatically changes data types to a similar form so that the computation can be performed.

For example, in a VSL expression 'color = wave(coordinates)' both input and output channel are 3 dimensional. Therefore, the computation goes as:

color.red = sin(coordinates.x)

color.green = sin(coordinates.y)

color.blue = sin(coordinates.z)

The expression 'color = wave(distance)' (distance is one dimensional value) is computed as:

color.red = sin(distance)

color.green = sin(distance)

color.blue = sin(distance)

The expression 'alpha = wave(distance)' (both alpha and distance are one dimensional) is simply:

alpha = sin(distance)

and 'alpha = wave(coordinates)' goes as:

alpha = sin(coordinates.x)

Similarly, if the object, by its nature, always outputs a single floating point value, the result is copied to all output sub channels. So, 'ray = length(normal)' computes:

ray.x = length(normal)

ray.y = length(normal)

ray.z = length(normal)