1. Unity 5.6 is now released.
    Dismiss Notice
  2. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  3. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  4. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  5. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice

Shader for grass

Discussion in 'Shaders' started by ElGreco, Jun 2, 2013.

  1. ElGreco

    ElGreco

    Joined:
    Mar 18, 2013
    Posts:
    6
    Hey dear community,

    is there any way to improve the look of grass assets, like adding a bit of gloss or normal map?
    Because in the grass paint options you can only add the texture and some settings.

    I dont know why, but it looks pretty crappy $Test.png
    Maybe because there is no variation in it, but can you add gloss or normal maps on it or any other
    suggestions?

    Sincerly,
    ElGreco
     
    Last edited: Jun 2, 2013
  2. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    610
    What shader are you using?
    Normal mapping might help to simulate the curvature the of leaves. Right now they look like they're part of a flat plane (because they are).
     
  3. mmwizard

    mmwizard

    Joined:
    Mar 27, 2009
    Posts:
    65
    TRy creating a shader with two grass textures and use 1 alpha channel 2 blend them together. Then use a normal map and a rim light . And youre done.
     
  4. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    567
    If you want to improve your grass, you can use other shader like you said, but I suggest you to look at some modeling tutorial.
    It's not hard and you could improve your rendering.

    As you can see in this tutorial. The grass is not in one flat plane, you need to create multiple rounded planes (not so much, I think you care about performances).
    You can follow this tutorial on Unity until step 7), next is for creating grassmaps.

    PolyCount Grass
    Crydev
     
  5. mmwizard

    mmwizard

    Joined:
    Mar 27, 2009
    Posts:
    65
    this is a example of how i use grass
    $Screen Shot 2013-06-05 at 13.24.51.png
    these are the settings
    $Screen Shot 2013-06-05 at 13.25.19.png
    and this is the code
    Code (csharp):
    1. Shader "MMWizard/Rim/Terrain" {
    2.     Properties {
    3.       _MainColor ("Main Color", Color) = (0.5,0.5,0.5,0.0)
    4.       _MainTex ("Main(RGB)", 2D) = "white" {}
    5.       _SeconTex ("Second(RGB)", 2D) = "white" {}
    6.       _MaskTex ("Mask(A)", 2D) = "white" {}
    7.       _BumpMap ("Bumpmap(RGB)", 2D) = "bump" {}
    8.       _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
    9.       _RimPower ("Rim Power", Range(0.5,20.0)) = 5.0
    10.     }
    11.     SubShader {
    12.       Tags { "RenderType" = "Opaque" }
    13.       CGPROGRAM
    14.       #pragma surface surf Lambert
    15.       struct Input {
    16.           float2 uv_MainTex;
    17.           float2 uv_SeconTex;
    18.           float2 uv_MaskTex;
    19.           float2 uv_BumpMap;
    20.           float3 viewDir;
    21.       };
    22.       float4 _MainColor;
    23.       sampler2D _MainTex;
    24.       sampler2D _SeconTex;
    25.       sampler2D _MaskTex;
    26.       sampler2D _BumpMap;
    27.       float4 _RimColor;
    28.       float _RimPower;
    29.      
    30.       void surf (Input IN, inout SurfaceOutput o) {
    31.           half4 main = tex2D (_MainTex, IN.uv_MainTex);
    32.           half4 sec = tex2D (_SeconTex, IN.uv_SeconTex);
    33.           half4 mask = tex2D (_MaskTex, IN.uv_MaskTex);
    34.          
    35.           o.Albedo = lerp(main.rgb, sec.rgb, mask.a);
    36.           o.Albedo *= _MainColor;
    37.           o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
    38.           half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
    39.           o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    40.       }
    41.       ENDCG
    42.     }
    43.     Fallback "Diffuse"
    44.   }
     
  6. Ben Massey

    Ben Massey

    Joined:
    Jun 13, 2011
    Posts:
    581
    The color of your grass is way to dark compared to the terrain, either darken your terrain texture or lighten your grass detail to match either one, this will make a much more realistic blend. Think of it as not trying to make your grass look like a separate asset, your trying to give you terrain more depth.

    [​IMG]

    What you can also do is use crossover planes for a detail mesh instead of bill boarding a single plane, this will add a lot more depth.
    [​IMG]
     
    Last edited: Jul 17, 2013
  7. CoalCzar

    CoalCzar

    Joined:
    Nov 25, 2012
    Posts:
    22
    Sorry to bring this post back up, but, Ben, what is a "crossover plane"? I've tried to find this phrase elsewhere and haven't gotten any good leads.
     
  8. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
  9. Ben Massey

    Ben Massey

    Joined:
    Jun 13, 2011
    Posts:
    581
    Sure do, I've updated my post I case anybody els is having trouble. Most design elements in unity are quite universal in the software world so it's good to do some research on other engines as well.
     
  10. rea

    rea

    Joined:
    Oct 10, 2009
    Posts:
    1,759
    Disabling billboard option should do the joba isn't?
    billboard grass is evil btw.....if you looking for realistic grass style