Search Unity

How to make swaying trees with DrawMeshInstanced?

Discussion in 'General Graphics' started by JoeStrout, Mar 23, 2019.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm need to make a forest scene (on Oculus Go). DrawMeshInstanced looks like a promising way to draw a lot of trees, grass, and bushes in just a few draw calls.

    But real plants sway in the breeze; they are not solid and static like statues.

    How would I go about making my meshes sway while using DrawMeshInstanced? Is this a job for vertex displacement? Perhaps I could use vertex color or a second UV set to control how much each vertex sways (for solid trunk but swaying branches, etc.), and use some sort of noise function combined with time to make the ripples propagate across the scene?

    Please let me know if I'm on the right track. And if there is an off-the-shelf shader already available that does this, please point it out (I'm not proud!).

    Thanks,
    - Joe
     
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    JoeStrout likes this.