Search Unity

Script for change Grass color

Discussion in 'Scripting' started by cybervalie, Jan 18, 2010.

  1. cybervalie

    cybervalie

    Joined:
    Sep 27, 2009
    Posts:
    94
    Hello :)

    I did a script that create a day/night cycle for my world. for that, my script change the values of colors of the light, the fog color, the fog density, the ambient light, the color of skysphere, the clouds... looks very good in game, but a litle detail need some attention :D

    The grass stay at the same luminosity... for the day time, is ok, but when is night time, is like illuminate grass ^^

    So i tried to find a command that permit me to have access to this grass color, and i find nothing...

    does somebody know what sort of script command could touch the grass color?
     

    Attached Files:

  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Are you saying that the grass stays the same bright colour even when the scene lights are at a low level? If so, you probably just need to use a different shader on the grass material (say, one of the Diffuse ones). If this isn't what you want, you can access the material's colour using renderer.material.color and set it to anything you like.
     
  3. cybervalie

    cybervalie

    Joined:
    Sep 27, 2009
    Posts:
    94
    uh, i look for change the shader :)
     
  4. cybervalie

    cybervalie

    Joined:
    Sep 27, 2009
    Posts:
    94
    well, i tried to change the intensity of light form the only light in the level, nothing change in grass. I look in the shader of the grass, in project pane, and is the texture importet that appear, with no place for the shader, and in the hierarchy, i can't change that because is in the terrain script, and is no place for shader in terrain script. So for the script line you give me, is the same, i don't know how to target the grass with a script if this grass is in the terrain sctipt...
     
  5. radiolobito

    radiolobito

    Joined:
    Jun 12, 2009
    Posts:
    117
    my suggest:

    use
    renderer.material.color
     
  6. cybervalie

    cybervalie

    Joined:
    Sep 27, 2009
    Posts:
    94
    As i know, it is not possible to access to the grass color with: renderer.material.color only... if she is in the terrain script. For change manualy this color, i need to select it > edit grass texture, and appear a window. So in the command more up, i need to precise in the script how to access to the renderer.material.color of the grass that is in the terrain script. :eek:
     
  7. cybervalie

    cybervalie

    Joined:
    Sep 27, 2009
    Posts:
    94
    Somebody know how to fix that? Please it's important
     
  8. radiolobito

    radiolobito

    Joined:
    Jun 12, 2009
    Posts:
    117
    have you tried to make the surface of terrain not in Unity? try with Vue or Terragen.

    then you can paint it
     
  9. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    Yes, the grass tint property doesn't seem to be accessible, or at least nobody seems to know the variable name (though breaking the API might not be such a good idea).

    As far as I know, only trees and detail meshes can have light sources affect them. All grass is permanently stuck on the same tint color.

    Night day cycle with terrain grass = impossible as far as I know. Well, at least if you want it to look good anyway
     
  10. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I would guess gras uses the lightmap color for performance reasons, so you could experiment with tinting that.
     
  11. DaReign

    DaReign

    Joined:
    Apr 12, 2013
    Posts:
    79
    So still changing grass tint via script isn't possible ?