Color gradient

The color gradient class is used to colorize the diffuse map.

Predefined color gradient

The material generator plugin has 2 predefined color gradients. You can use it by calling the “construct” functions:

  1. The black and white color gradient, which explained in Introduction, is mainly used for displacement/roughness/metallic map generation or debugging.
  2. The terrain color gradient based on a visual representation of a terrain. Values below 0 are supposed to be water, they are colorized in blue; values between 0 and 0.375 are supposed to be grass, they are colorized in green; values between 0.375 and 0.75 are dirt (yellow/brown) and finally, values above 0.75 are rock and snow:

If you want to create your own color gradient (eg: yellow/orange/brown colors for a wood texture), you have two possibilities: either from a map or from a curve.

Color gradient from map

If you use the ConstructGradientFromMap function, you need to create a local variable to store the map values.

Map’s keys are the values of the noise between -1 and 1. Map’s values are the color to choose for this value. If a map entry isn’t defined for this noise value, a linear interpolation is made to compute the color for this noise value.

Below, the picture shows the map entries to recreate the black and white gradient. Ad you can see, only -1 and 1 values are defined. The 0 value is interpolated and equals (R:128,G:128,B:128,A:255).

Color gradient from curve

If you use the ConstructGradientFromCurve function, you need to create a curve asset containing the color gradient.

In order to create the curve asset, right click in your content browser>Miscellaneous>Curve. Then in the Pick curve class window, select the CurveLinearColor.

Now you can select output colors based on the noise value. You need to define colors between -1 and 1 in the X axis.

In order to edit the curve, you can either put color keys or manually edit the 3 base color curves. Check documentation on Unreal Website about Curves and Color Picker.

Here is some examples of curves. On the left you can see a black and white gradient, on the right you can see the terrain gradient recreated in curve editor.