1 MINUTE VEX IX
Triplanar Mapping & Projection
In this example, we conclude the colormap trilogy by using VEX to create a triplanar projection at an attribute level.
For more information on OCIO and ACES, refer back to 1 Minute Vex VII, where these concepts are explored in further depth.
We begin once again by creating our image path variable from a string parameter, but this time accompanying it with the vector point position. In order to control the projection like you would in-shader, we add a vector to the initial position (as an offset) and then multiply (for frequency).
We then create a blank variable for our resulting colour, and an absolute normal. ‘N’ is written as absolute to keep the projection on 3 axes, but not ignoring the resulting 3 negative axes on the projection. It is also important to remember that all incoming vectors should be normalized!
Using a for loop, we can now iterate over these axes and set our vector ‘uv’ position as the current planar coordinates. Using modulo is a great way to loop through a set of numbers, allowing XYZ to be set as ZXY and YZX on the next two iterations.
Knowing our position in the loop, we use the third orthogonal vector (perpendicular to our first two axes) and point normal ‘N’ to calculate the dot product- finding our angle from current axis in radians and converting it to degrees.
We then fit this angle within a specified range for use as the projection mask, masking the filtered pixel found by colormap() into our colour variable.