The question is answered, right answer was accepted
Inside of a shader how can I convert a world direction relevant to a vertex's local position
I'm trying to make a shader for my grass that will allow me to have all the grass blowing in the same direction regardless of its rotation.
This is what I have at the moment (http://puu.sh/nl9l0/ff81760b81.png)
My problem is that I want my grass to blow in the world direction (0, 0, 1), but the vertex offset input is for the vertex's local position. I need a way to make my world direction relevant to the vertex's local position.
Any input/help is appreciated.
Hi, I'm actually starting to learn shader coding myself and I really need grass that colellectively "bows" in wave patterns, like a world space wind blows over it, not that weird stuttering the unity tree creator shaders have.
Would you $$anonymous$$d sharing your work in progress or if not, point me to some tutorials that explain this well? Browsing through the "writing shaders" sections of the unity documentation gives me a headache since the pages link to each other in a weird cancerlike circle and don't actually explain basic commands needed.
Answer by GarrettShields · Feb 25, 2016 at 11:58 PM
I ended up solving my problem with help from someone in the IRC channel.
If anyone stumbles upon this in the future with a similar problem you need to multiply your world direction by _Object2World.