I want to have a world vector map that represents wind direction and strength in that particular area. I also want to be able to use colliders to influence the wind effect (faking collisions and additional winds).
In theory a monobehavior script provides the material shader with a localized world direction and wind strength values by changing the material block properties per object instance. The shader is initialized at the start of the game with a weight value per vertex (how much a vertex should be displaced). The Shader performs vertex displacement per vertex based on: wind direction, wind strength, and vertex weight value. The shader also has a maximum displacement value. The max displacement value makes sure that strong winds don’t over stretch vertices with high weight values (leaves) while increasing the influence on low weighted vertices (branches, trunks). Displacement should start from the mesh’s origin point so that the max displacement per vertex is relative to its neighbors. Vertices have a counter ‘force’ vector that tries to reposition them back to their resting position. Additional shader properties dictate how quickly this spring-like force builds and dampens.
I have little experience with shaders, so here are my questions:
-
Is this possible? If so…
-
Any concerns for efficiency such as large frame-rate loss over many objects?
-
Any ideas on how to go about this?
-
Would it be best to have two versions of this shader: one for quads / planes (grass, leaves) and one for more complexed meshes (trunk / branches)?
-
I plan to have branches as separate objects from the trunk (for customization / interaction reasons). As a tree trunk sways in the wind is it be possible to recalculate where the origin of each branch should be?