Search Unity

unity_ObjectToWorld is not correct if I use Terrain to setup my grass

Discussion in 'Shaders' started by zhutianlun810, Dec 20, 2019.

  1. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    171
    Hello,

    I find that if I use Terrain tool to create my grass, the unity_ObjectToWorld in my grass shader is incorrect. It seems all grass have the same unity_ObjectToWorld. How can I fix it?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You can’t. Terrain grass is always batched into a single mesh, thus there’s no way to get the individual grass meshes’ original pivot.
     
  3. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    171
    I need the grass's height info to do some vertex anim. What is the common way to do it in the industry? Is it a good idea to let our artists to paint height on the vertex color?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Yep, use the vertex color. Unity already bakes a top and bottom into the default “sprite” based grass to do wind.
     
  5. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    171
    But The terrain bush can set the max height and min height for my plants. How can I get the scaled size for an individual plant?
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You can't. If you want that level of control and information, you can't use the built in terrain grass. This is why there are so many grass related assets on the store.