A tool script for 3D artists to generate vertex colors for vegetation sway used in the Trine games. Written in Python for Modo to replace an ancient piece of software whose only purpose was to make the gradients.
The main point of the script is to generate a gradient from root to tip by crawling along the vertices and calculating the distance traveled. A bunch of trees in the project were quite wide, so a simple vertical gradient wouldn't be sufficient.
Other features include an offset map and a leaf mask. The leaf mask samples a texture and generates the vertex colors based on that, so it requires the artist to paint a crude mask of where the origin points of leaves are. This was the most reliable way I could come up with to get the leaves behaving properly and luckily doesn't take much effort on my or the user's part.
The offset map is painted directly on the model by the artist and then processed by the script to work with the engine specs. The offset, as its name betrays, offsets the swaying on the painted parts to break up uniformity in the motion.
I made a test shader in UE4 for presentation purposes. Behaves similarly to how it works in the Trine games, but I took the opportunity to have some extra fun with it. Tree mesh borrowed from Trine 4.