Gradients

Multi-stop gradient types for sampling color, float, and vector values over a normalized range — used by motion tracks and feedback effects.

The Gradients utility provides three parallel gradient types for interpolating values over a normalized [0,1] range using a sorted list of marker points. All types are fully reflected (SerializeContext + EditContext) and editable in the Inspector with visual marker placement. Gradients are lazily sorted before evaluation.

Used by: FeedbackMaterialTrack (color/float animation), UiImageColorTrack, procedural visual effects, any system needing editable color or value ramps.

For usage guides and setup examples, see The Basics: GS_Core.

Gradient Slider in the O3DE Inspector

 

Contents


Gradient Types

TypeValue TypeDescription
FloatGradientfloatSingle float value ramp
Vector2GradientAZ::Vector22D vector ramp
ColorGradientAZ::ColorRGBA color ramp with separate color and alpha channels

Marker Structs

Each gradient type has a corresponding marker struct that defines a single stop on the gradient.

FloatGradientMarker

FieldTypeDescription
markerValuefloatThe float value at this stop
markerPositionfloatPosition in [0, 1] along the gradient

Vector2GradientMarker

FieldTypeDescription
markerValueAZ::Vector2The 2D vector value at this stop
markerPositionfloatPosition in [0, 1] along the gradient

ColorGradientMarker

FieldTypeDescription
markerColorAZ::ColorThe color (RGB + A) at this stop
markerPositionfloatPosition in [0, 1] along the gradient

Gradient Classes

All three gradient types share the same structure and interface:

Field / MethodDescription
sliderAZStd::vector<Marker> — the sorted list of gradient stops (field name for Float/Vector2)
sortedInternal dirty flag; gradient is lazily sorted before Evaluate is called
SortGradient()Sorts markers by position. Called automatically before evaluation when markers change.
Evaluate(float t)Returns the interpolated value at normalized position t in [0, 1]

ColorGradient

ColorGradient maintains two separate marker lists for independent RGB and alpha control:

FieldDescription
colorSliderAZStd::vector<ColorGradientMarker> — RGB stops
alphaSliderAZStd::vector<ColorGradientMarker> — alpha stops

ColorGradient Channels

ColorGradient exposes three evaluate methods for flexible sampling:

MethodReturnsDescription
Evaluate(float t)AZ::ColorFull RGBA color — samples both colorSlider and alphaSlider
EvaluateColor(float t)AZ::ColorRGB only — alpha is always 1.0
EvaluateAlpha(float t)floatAlpha channel only

Usage Example

#include <GS_Core/Utility/Gradients/FloatGradientUtility.h>
#include <GS_Core/Utility/Gradients/ColorGradientUtility.h>

// Sample a float gradient at normalized progress (0 → 1)
float value = myFloatGradient.Evaluate(normalizedProgress);

// Sample full RGBA color
AZ::Color color = myColorGradient.Evaluate(normalizedProgress);

// Sample RGB and alpha independently
AZ::Color rgb   = myColorGradient.EvaluateColor(normalizedProgress);
float alpha     = myColorGradient.EvaluateAlpha(normalizedProgress);

See Also

For related resources:


Get GS_Core

GS_Core — Explore this gem on the product page and add it to your project.