Controlling exact color of texture for terrain painting

Hi everyone!

I just discovered the terrain object in unity and I’m amazed by how easy one can form a landscape with it. But I have a problem which I could find a solution to yet. My game is in 3D and in low-poly style. Since I’m experimenting a bit with colors to use for the terrain, I want to be able t paint a texture onto the terrain, of which I can change the color value as I go on. But because textures already have a color, it is really hard to nail the exact color that I want. I tried using a purely white texture but this just made the color brighter. Now even though I could just make the color darker, I would love to just apply a texture, change it’s color and have this color be what I wanted.

Is there any way you would know how I could do this?

Thanks in advance for the help!

Hello,
To change the color of a texture on Unity terrain, try this: Official Site

  1. Create a Custom Material: Assign this material to your terrain.
  2. Use Shader Graph: Create a vertex shader to adjust colors based on terrain height.
  3. Adjust Colors: Use a gradient to set colors for different heights.

Best Regards,
John Dane

Hey thanks for the reply!

I tried creating a material and assigning it to the terrain but the terrain component only accepts physics material and I couldn’t figure out how to make one. When creating a material with shader graph I could assign that one either. Could you maybe elaborate on the steps?

Thanks!

Backing up what @john589dane said, in the shader you can also check out Shader graph’s triplanar node: Triplanar Node | Shader Graph | 6.9.2

Triplanar shading is specifically designed to let you make materials changes based on various ranges of X, Y and X corrdinates. I.e. height is used as well. This is a common tool for generating terrain visuals where height dictates Materials changes. But the uses go beyond that.

@OliverHos99
Another method you could consider, is writing a tool that alters the coloring at design time. Effectively. the splat map is a texture. Each color (Red Green Blue and Alpha) is used to dictate how much of a texture should be blended into the current output. When you go beyond 4 textures, it needs to use another splatmap texture.

This also means that you can write your own code to set this. I.e. opening the splatmap you can alter the pixels using the X/Y coordinates against to determine the value to assign for the color. Here is an example script that sets it by height:

Unity - Scripting API: TerrainData.SetAlphamaps

As a third option, if you were to just select a pure red material, pure green and pure blue, you could then literally assign them as the 1st, 2nd and 3rd meterials in the terrain, and then use a bitmap of the color pattern you want over the entire surface and import it as the splatmap. It should blend perfectly, though I have not done this specific action before. I.e. the R channel will tell it how much red, the G green and b Blue. Its somewhat straight forward.