- Home /
Why does the grass change color by default?
Why does the grass change color by default whithout script attaching? How can I change it?
Answer by WillNelson · Mar 14, 2015 at 01:51 AM
This was a big problem for me for a long time. This behavior is years old and undocumented. (Very frustrating.) After quite a bit of experimentation and guessing at what Unity does internally, I discovered something that works well for me: under the main terrain settings, set "Grass Tint" to a 50% gray value (r=g=b=128).
A little more information: The grass color seems to slowly oscillate between (a) the dry/healthy colors you explicitly set in the grass texture and (b) another color controlled by the Grass Tint color that's derived from the dry/healthy colors. I'll call the first color the "Base Color" and the second the "Derived Color". The Grass Tint color seems to affect the Derived Color independently on the three color channels (red, green, blue). If Grass Tint Red=255, then the Derived Color red is a brighter red than in the Base Color you set in the dry/healthy colors. If Grass Tint Red = 0, the Derived Color red is 0 (black). At Grass Tint Red = 128, the Derived Color red seems to be very close to the Base Color Red. Same with the other channels.
If this was helpful to you, please up vote. I hate having to wait for a moderator to approve my questions!
I want to add that i had to restart Unity for this to take effect, Otherwise this worked.
This was on 5.3
I found that no matter what I did, setting my tint at 50% just made my grass too dark. See giucapan's answer below.
This doesn't fix anything. The issue is that wins causes the grass to change colors. Setting 50% grey on all 3 tint parameters does NOT fix this. The only way to fix it is to completely turn grass wind off
Answer by giucapan · Jan 11, 2017 at 01:31 PM
I solved the problem:
Go to ../Unity/Editor/Data/CGIncludes and copy TerrainEngine.cginc into your Unity Project.
Open it with Mono or Visual and go to Line: 120
change
return fixed4(2 * waveColor * color.rgb, color.a);
toreturn fixed4(color.rgb, color.a);
This fixed it for me. I hope it will fix your problem aswell.
The change you have provided is the exact same thing as the original
I think
return color;
is probably what was meant.
Yes! Thanks for this! I found my grass was too dark unless I left the 2*:
return fixed4(2 * color.rbg, color.a);
Also you can also change this line ins$$anonymous$$d:
fixed3 waveColor = lerp (fixed3(0.5,0.5,0.5), _WavingTint.rgb, fixed3(lighting,lighting,lighting));
to something like this to have a more subtle effect that doesn't go so dark.
fixed3 waveColor = lerp (fixed3(0.8,0.8,0.8), _WavingTint.rgb, fixed3(lighting,lighting,lighting));
If youre using URP, go to this folder "yourUnityProjectFolder"\Library\PackageCache\com.unity.render-pipelines.universal@7.1.8\Shaders\Terrain and open WavingGrassInput.hlsl in $$anonymous$$ono or Visual and go to line: 98 and change
return half4(2 * waveColor * color.rgb, color.a);
to
return half4(2 * _WavingTint.rgb * color.rgb, color.a);
Cheers for wasting my time unity
This did the trick for me, thank you very much! This probably saved me hours of work and who knows how much frustration.
What a ridiculous problem to have in the first place. If we wanted grass to change colors we would fricking tell it to.
I think I might be missing a step here. Changing this script seems to have no effect on anything, Even if I do something that would break the compiler it still compiles my project, Is there somewhere specific I should put the TerrainEngine.cginc file inside my project, I'm using unity 2019.4
Answer by TheKusabi · Sep 22, 2013 at 06:53 PM
Explain. When does it change color? How often? What colors?
A stab in the dark would be: try turning billboard distance up way high. Maybe the billboards are messed up.
It changes color when I press "play" button. One cycle takes about 12 seconds. From dark green to yellow-green. I have decreased "billboard start" parameter to it's $$anonymous$$ value - 5, but it has not brought a result.
Here are a few parameters that can influence this:
And look at the second picture. It is very strange to me that section Wind Settings has the Grass Tint parameter.
Answer by Xydez · Nov 05, 2016 at 09:42 PM
I figured this out for y'all, Here's the solution for you who didn't understand WillNelson's comment' First go to the settings menu in the terrain and find the grass tint in the wind settings. Then set your values to a 50% grey color or set the hex to 808080FF Follow the images EXACTLY or it will look wrong. !
Or this
Well that's about it i guess, approve this answer so this mess gets solved. cya
This doesn't solve anything except keeping the original color value of the grass. The grass still changes colors.
@M_R_M & @dynamicvoltagegames : did you guys actually read the comment properly? He's not talking about the color attributes for the detail mesh/texture; he's talking about the "grass tint" property under "wind settings for grass" which is a terrain property, found under the terrain settings.
Here is the code for how that tint (WavingTint.rgb) is treated in the shader:
fixed3 waveColor = lerp (fixed3(0.5,0.5,0.5), _WavingTint.rgb, lighting);
return fixed4(2 * waveColor * color.rgb, color.a);
Color.rgb is whatever color you've assigned to the grass yourselves. And notice the "2 * waveColor" part in there? Guess what happens if you multiply grey (0.5) with 2? Yes, you get 1. What is 1 times color.rgb? Exactly: still color.rgb. Not lighter, not darker, just 1 times color.rgb.
The only downside of setting this to 0.5 is that all these calculations still get done, so if you want this feature disabled, best to just copy the TerrainEngine.cginc like mentioned above and remove the wavecolor variable alltogether. Just have "return color.rgba" at the end there.
Go ahead and try again.
For those that find that setting this tint to 0.5 doesn't solve things: check what color space you're using. If set to Gamma, 0.5 would do the trick. If set to linear, you need a higher value, somewhere near 0.7 (not sure what exactly, but there is formulas out there you can google)
Answer by dynamicvoltagegames · Dec 11, 2020 at 11:05 PM
STOP SAYING SET THE GRASS TINT TO 50% IT DOESNT WORK
The grass is going to change colors no matter what. Its a garbage feature that you can NOT stop from happening.
Your answer
