Sword & Fortune – WIP – Waving foliage shader

Sword & Fortune

In new WIP video from Sword & Fortune we present shader for waving foliage in the wind.

Foliage on video above is bent by our custom shader. Most of the work is done in fragment shader, but wind calculation is done in vertex shader.

To achieve this effect we needed to know distance of each pixel from pivot point. We encoded it into secondary texture that looks for plant on left like this:

Red colors encode x distance from pivot and green colors encode y distance from pivot. Pixels with higher y distance rotate by higher angle. To optimize sin and cos calculations, we encoded their values into another texture, that is common for all sprites.

Leave a Reply

Your email address will not be published. Required fields are marked *