Texture color variation?

I have a tree that I would like to randomize in color, size, etc. How can I randomize the color of the leaf textures such that if I place a tree down, it would randomly choose its leaf color?

Take a look at this tutorial: ?v=cp6JQVHWeEw :slight_smile:

For the texture create something like this: ://img.izismile/img/img6/20130223/640/captivating_photos_focused_on_pattern_motion_and_colour_640_40.jpg (just with other colours ^^)

Object position only returns one value for the entire object. There are many novel ways to do this, but here’s my suggestion for the best results and flexibility:

Make a grayscale map for your tree using the lightmap UVs. Map a random grayscale value to each leaf, and make the values varied from leaf to leaf. If you want to make leaves fade between one color and another, you can blend some values along the leaf… but make sure neighboring leaves have different values, otherwise they’ll both turn up as the same color! Then, make a 1*128 gradient that contains a smooth gradient of all the colors you wish to use. In the shader, multiply the grayscale map by 50 (consider this your “seed” value), then add it to a texture coordinate. The texture coordinate should be set to use the lightmap UVs of the tree with the texture scaling set to 0. Plug all that into the UVs of the gradient texture, and in the shader blend this with your normal leaf texture colors (multiply or lerp). I suggest desaturating the colors in your leaf texture. What you should see now is a shader that picks a color for the leaf using the gradient based off of an arbitrary value in the grayscale map.

Then this needs to be differentiated per-instance. You can multiply the grayscale map by the object’s position and get a random color per leaf, per tree, but only if each tree returns its own object value. If for any reason this does not work, then you’ll have to replace this extra setup with a large, soft noise texture and map it to the world using the XY values of the World Position texturing function. This should provide random grayscale values using world space.

The top part is similar to the technique I used to make this shader below. The colors come from a gradient that is a very small 1*128 texture with the UVs offset by a grayscale map. I can choose to make the tiles have more color blending by simply raising the scaling in the texture coordinate to a value more than 0, and I can reshuffle the colors completely by multiplying the grayscale map by a different “seed” value.