Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Grass

Discussion in 'General Graphics' started by ExtremePowers, Feb 19, 2015.

  1. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    What is the best way to make grass? Like what are the best settings to use, how to make a great looking texture for grass, billboard or non-billboard?

    I have been able to create some "okay" grass textures with photoshop, paint etc. But I never seem to get something that is useable. I have noticed that the built-in terrain grass shader makes a fade from a black color to the actual texture color, I would like to remove this to make the grass better fitting for the terrain. I also tend to make the texture black and white, and then use the grass tint for better control of the grass color, without having to edit the whole texture.

    I have been trying to achieve something like this kind of grass, where the color on the grass doesn't have a gradient over it:

    But it always has weird color even if I set both the dry and health color to the same. Is this something I would have to change in the grass shader?

    Tips and tricks on achieving good looking grass, would be much appreciated.
     
  2. KingMatthew

    KingMatthew

    Joined:
    Jul 7, 2013
    Posts:
    166
    One way to make grass is to 3d model the blades of grass, then make a texture of that. Use a 3dmodeling program such as blender and make a 3dmodel of a blade of grass. then copy that and past it in random locations on one plane. maybe change the size of one blade to add some diversity. Once you have a nice little group of grass, render a picture of it, then turn that into a texture for your game.
     
  3. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    How would I be able to get the grass to be the same color over the whole texture, like in the picture above?
     
  4. KingMatthew

    KingMatthew

    Joined:
    Jul 7, 2013
    Posts:
    166
    All I can think of would be to make the grass in your texture all one color.
     
  5. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    I have tried that but the grass seems to have some kind of gradient on it, and how can I prevent the grass from changing color, because it seems to be reacting to the wind..

    EDIT:
    In the picture below the grass texture is completly white and I have used the tint to make it that color. The weird thing is that the terrain and the grass has the same RGB value, but the grass shader seems to modify that.
     
  6. varfare

    varfare

    Joined:
    Feb 12, 2013
    Posts:
    227
    I might be wrong on this one but grass shader is probably changing the color depending on the camera angle. Check if your light source- it might be affecting the color.
     
  7. Kali2048

    Kali2048

    Joined:
    Oct 16, 2013
    Posts:
    67
    Change the color of your grass texture to be the same green as your ground texture.
    Edit the normals on your grass models to make them point directly up.
     
  8. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    I have done that, still with no luck. The grass still seems to have some gradient on them:

    NOTE: The grass and terrain has same rgb value.
     
  9. Kali2048

    Kali2048

    Joined:
    Oct 16, 2013
    Posts:
    67
    Are you sure you've updated all the grass normals to point up ?
    Also you need to have the model importer with the "normals" setting set to "import" and not "calculate".
    if that doesn't work could you please upload or send your test files ?
     
  10. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    I have set the DetailRenderMode to Grass, instead of grass billboard with no effect. I am not sure what else I could do without having the performance going too much down.
     
  11. Kali2048

    Kali2048

    Joined:
    Oct 16, 2013
    Posts:
    67
    send over your grass fbx / obj, no need texture
     
  12. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    I am using the builtin grass system (Unity terrain)
     
  13. Kali2048

    Kali2048

    Joined:
    Oct 16, 2013
    Posts:
    67
    you need to be using a custom mesh for the grass, not sure how to do that I've never used their grass system :(
     
  14. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    Last edited: Feb 23, 2015
  15. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
  16. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    Can I use your tool at runtime, and say generate a detail map with it and then place the grass?
     
  17. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    Yes, but you have to use a texture to describe the masked area.
     
  18. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    What system are you using?
    I couldn't get it to work at runtime
     
  19. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    The system distributes gameobjects. So everything you can make into a gameobject, like prefabs can be distributed by the system. There is an option for combining meshes to reduce draw calls. This will not affect other scripts on the distributed gameobjects. In the examples I use a custom mesh to display the grass.


    Have you tested the example scenes? Do they work?
    I think you must have a distribution map selected (texture), or else it will not work. You can make a small 32x32 white texture. I know this is not ideal but I will make changes to it when I start using the system myself.


    EDIT: After taking a closer look I see that I am using blender files in the package. You need a copy of blender to read them so that maybe why it is not working. I will update the package with .obj files instead.

    EDIT 2: @ExtremePowers It is now using .obj instead of .blend files. You have to re-download the package. :)
     
    Last edited: Feb 24, 2015
  20. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    Okay, I have a problem where the ScreenCapture game object doesn't have a script attached.

    EDIT: How to place the grass on a procedurally generated unity terrain?
     
  21. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    It was just a tool I used to create the some screenshots. I did not include the script in the package but I forgot to remove the object using it from the demo scene. I fixed this in the new version.

    Surface projection is done on colliders. Does your terrain have a collider?
     
  22. ExtremePowers

    ExtremePowers

    Joined:
    Sep 27, 2013
    Posts:
    28
    My terrain has the terrain collider attached to it. Does the system by any chance have frustum culling built-in for better performance, like the GrassViewdistance, if not I will just implement it myself :)

    EDIT: None of the grass seems to have color too. I have no idea if this is by accident or not, just mentioning it. You might be able to tell me.
     
    Last edited: Feb 25, 2015
  23. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    I tested the system on some terrains and I had problems getting it to work. I have no idea why. I am sorry.
    It seems like sometimes the terrain got a collider and sometimes it don't.

    No it does not have frustum culling.

    I like to control the grass color from within the game. By making the texture gray-scale, I can tint it when I render.
    Adjusting the material color for every cluster of grass is not very effective. Instead we can apply it to the vertex color. This require a custom shader. I included one in the package.