Search Unity

Questions On Implementing Grass

Discussion in 'General Graphics' started by Zhialus, Aug 14, 2019.

  1. Zhialus

    Zhialus

    Joined:
    Jan 3, 2019
    Posts:
    16
    I'm fairly new to the graphics side of unity and have spent the last week or so researching implementation of grass. Although I've learned alot, I'm still looking for some clarification of how its actually done as it seems to be quite vague and haphazard in most of the "tutorials" I've found.

    --------
    UPDATED:
    My new question that I think more accurately gets to the point I'm looking for is: based on this list of requirements below the photos, what would be the best way to achieve an effect similar to these examples? Whether through some kind of auto generating shader, gpu instancing gameobject prefabs of grass, or any other method I'm not aware of.
    --------

    This effect from a unfinished game called "Vind" is exactly what I'm looking for.
    Vind grass 01.png Vind grass 02.png Vind grass 03.png

    Based on these photos, here's the effects I want.

    - Different types of grass(see images for blue/white flowers, and different grass colors and shapes)
    - Varying height (Vind fades the height down when reaching the edge of islands or paths/dirt, aswell as having different height within the center of patches)
    - Reactive (Wind effect like the unity grass, and also bending when the player walks through, see images)
    - Ability to choose where the different grasses will be (Not sure if that means manually prefab painting, or if there's a way to do it with a colored texture map that a shader can use to decide what goes where.)
    - Ability to put grass on floating islands

    From what I understand there's 3 methods, please correct me on this.

    1. Manually placing grass prefabs (Prefabs being intersecting quads made in blender, with albedo alpha to make the quads into a grass shapes) This manual placing can go faster using polybrush, but the placement is sparse still and the hierarchy quickly fills if you want a reasonable amount of grass. Also because of the mass amounts of gameobjects this can cause slowdown.

    2. Using unity terrain and detail painting grass (Adding the alpha texture used in process 1 for the grass shape) More performant from what I can tell and bonus wind effect without custom shaders. However unity terrain has to be flat and planes square, so floating islands wouldn't work with this setup. Additionally, unity grass doesn't push out of the way when walking through it

    3. Making a grass shader (Using a base mesh OR point clouds to render triangle shapes at the points, and some kind of tessellation to buff out the density) benefits being the performance gained (not sure how) and also being able to simulate wind and pushing out of the way from player, but the drawback is I can't choose where to put each grass texture via painting(Or another method is there is one), or even choose a grass texture to use.

    Sorry for the long post, still trying to piece things together here.
     
    Last edited: Aug 16, 2019
  2. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    If you generate grass automatically based on a mesh, you could use vertex colors to give some control over the size, density, or type of grass that gets generated. Or you could use an extra UV channel and sample a texture to determine this more precisely?
     
    Zhialus likes this.
  3. Zhialus

    Zhialus

    Joined:
    Jan 3, 2019
    Posts:
    16
    I'm fairly new to shader's but from what I know, I'd have a standard grass shader that places quads across a mesh of which I'll map different textures to, which ones to use and their height will be determined by detecting the vertex colors of some kind of template, is that right?

    I wonder if polybrush's vertex painter would be compatible with this, additionally in Vind the ground texture is all one color where the grass is, so I wonder if I can make the "template mesh" invisible somehow, or perhaps just disable it in the hierarchy, not sure.

    I've never dabbled with the other UV channel, could you elaborate what you mean by that?