Random Color for Trees in Foliage

Hello Guys,

I made a Material for a tree with random color.
I place the trees in the world and it works but if i place the trees with Foliage tool, all the trees change the color to same.

someone knows how to setup a material for this ?

[video]- YouTube

This is my Setup

Greez DarkSoe

Hey,

This is because ObjectPosition does not return a valid number for Foliage objects (always 0,0,0). Try using “Per Instance Random”. Or you could try instead try using const3 (0,0,0) Transform(Local->World) instead to get the actual object position, but I think that may also have to be computed via CustomUVs:

https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/CustomizedUVs/index.html

FWIW, you can debug the output of nodes like objectposition using a material function called “DebugFloat3Values”. There is also one called “DebugScalarValues” etc. It will actually print out text of the float values of your material expressions. Just make your mesh into a box and hook the debug node up to emissive and you can quickly figure out where this stuff breaks down. Often trying things via CustomUVs will get them to return values when they don’t work in the pixel shader:

There is also a node called SpeedTreeColorVariation that does something similar that works on foliage.

Thanks,

SpeedTreeColorVariation works fine, and with a Mask(R,G) i got the result i want.

Greez

1 Like