I've gotten the wind to look nice with grass, which all faces front, but it doesn't work right with other meshes, since they can be rotated arbitrarily. I realized that since I'm basing the wind movement on vertex position in object space, if my objects are rotated, the wind movement is rotated too (since rotation is not taken into account). I'm wondering if there is a way to adjust the vertex position based on the object's rotation, so that the wind movement always goes the same way no matter the object's rotation?
Something like, multiple the wind vector by the object's rotation? Or rotate the input vertex position by the object's rotation so that the output is adjusted? (not sure how to do either).
I am using
- Code: Select all
Graphics.DrawMeshInstanced
This is my "wind vertex position" function which outputs wind-adjusted vertex offset:
https://www.dropbox.com/s/qgubhmpe7isoilp/Screenshot%202018-08-24%2000.39.46.png?dl=0
This is an example of a simple shader using said function:
https://www.dropbox.com/s/s46trlthq1i472o/Screenshot%202018-08-24%2000.39.40.png?dl=0
Thank you for your help!