- Home /
Tree color variation with _TreeInstanceColor not working anymore?
In a new scene, I create a terrain obj, and I add a tree prefab using the built-in terrain tool. The tree uses the Nature/Tree Creator Leaves
and Nature/Tree Creator Bark
shaders in its materials. I set the color variation slider to 1
and mass place the trees using the built-in terrain tool.
The trees are placed successfully, but there is no color variation on the trees. I mass place again with the color variation slider set to 0
, and the result looks identical.
I checked out the unity doc: https://docs.unity3d.com/Manual/terrain-Trees.html with the relevant part about the _TreeInstanceColor property in the table mid-page, and looked at the code for the Tree Creator shaders in this repo: https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader
The _TreeInstanceColor property is present in the shader, and should work, but doesn't.
I also tried the scripted approach with this code:
var inst = new TreeInstance();
inst.color = new Color32(255, 0, 0, 255); // Trees should be shades of red.
Which should work according to this manual entry: https://docs.unity3d.com/ScriptReference/TreeInstance.html
The trees are placed as expected, but not taking the color variation into account.
I use Unity 2019.03.0f6
, and I had the same problem with all`2019.02` releases. Does anyone know what's going on?
Answer by nplekhanov · Jun 27, 2021 at 09:37 PM
any update on this?
_TreeInstanceColor always receives white color instead of being randomized
Answer by Barnett784 · Jun 28, 2021 at 08:55 AM
You can get a list of all the edges via graph.get_edge_list() Each source node should have two target nodes, the one with the lower index is evaluated as True, the higher index as False Colors can be assigned via set_fillcolor()
Your answer
Follow this Question
Related Questions
How can I generate terrain trees at runtime? 1 Answer
Terrain system trees slightly sharpen and blur depending on camera rotation 2 Answers
Why does my tree script not work 2 Answers
Terrain trees or GameObjects? 0 Answers
Why does my tree script not work 0 Answers