UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FLinearColor Struct Reference

#include <Color.h>

Public Member Functions

 FLinearColor ()=default
 
UE_FORCEINLINE_HINT FLinearColor (EForceInit)
 
constexpr UE_FORCEINLINE_HINT FLinearColor (float InR, float InG, float InB, float InA=1.0f)
 
constexpr UE_FORCEINLINE_HINT FLinearColor (const FColor &Color)
 
CORE_API FLinearColor (const FVector3f &Vector)
 
CORE_API FLinearColor (const FVector3d &Vector)
 
CORE_API FLinearColor (const FVector4f &Vector)
 
CORE_API FLinearColor (const FVector4d &Vector)
 
CORE_API FLinearColor (const FFloat16Color &C)
 
bool Serialize (FArchive &Ar)
 
bool Serialize (FStructuredArchive::FSlot Slot)
 
CORE_API FColor ToRGBE () const
 
floatComponent (int32 Index)
 
const floatComponent (int32 Index) const
 
FLinearColor operator+ (const FLinearColor &ColorB) const
 
FLinearColoroperator+= (const FLinearColor &ColorB)
 
FLinearColor operator- (const FLinearColor &ColorB) const
 
FLinearColoroperator-= (const FLinearColor &ColorB)
 
FLinearColor operator* (const FLinearColor &ColorB) const
 
FLinearColoroperator*= (const FLinearColor &ColorB)
 
FLinearColor operator* (float Scalar) const
 
FLinearColoroperator*= (float Scalar)
 
FLinearColor operator/ (const FLinearColor &ColorB) const
 
FLinearColoroperator/= (const FLinearColor &ColorB)
 
FLinearColor operator/ (float Scalar) const
 
FLinearColoroperator/= (float Scalar)
 
FLinearColor GetClamped (float InMin=0.0f, float InMax=1.0f) const
 
UE_FORCEINLINE_HINT bool operator== (const FLinearColor &ColorB) const
 
UE_FORCEINLINE_HINT bool operator!= (const FLinearColor &Other) const
 
UE_FORCEINLINE_HINT bool Equals (const FLinearColor &ColorB, float Tolerance=UE_KINDA_SMALL_NUMBER) const
 
constexpr FLinearColor CopyWithNewOpacity (float NewOpacity) const
 
CORE_API FLinearColor LinearRGBToHSV () const
 
CORE_API FLinearColor HSVToLinearRGB () const
 
FColor QuantizeRound () const
 
FColor QuantizeFloor () const
 
CORE_API FColor ToFColorSRGB () const
 
FColor ToFColor (const bool bSRGB) const
 
CORE_API FLinearColor Desaturate (float Desaturation) const
 
CORE_API float GetLuminance () const
 
UE_FORCEINLINE_HINT float GetMax () const
 
bool IsAlmostBlack () const
 
UE_FORCEINLINE_HINT float GetMin () const
 
CORE_API FString ToString () const
 
CORE_API bool InitFromString (const FString &InSourceString)
 

Static Public Member Functions

static UE_FORCEINLINE_HINT FLinearColor FromSRGBColor (const FColor &Color)
 
static CORE_API FLinearColor FromPow22Color (const FColor &Color)
 
static CORE_API FLinearColor MakeFromHSV8 (uint8 H, uint8 S, uint8 V)
 
static CORE_API FLinearColor MakeRandomColor ()
 
static CORE_API FLinearColor MakeFromColorTemperature (float Temp)
 
static CORE_API FLinearColor MakeRandomSeededColor (int32 Seed)
 
static float Dist (const FLinearColor &V1, const FLinearColor &V2)
 
static CORE_API float EvaluateBezier (const FLinearColor *ControlPoints, int32 NumPoints, TArray< FLinearColor > &OutPoints)
 
static CORE_API FLinearColor LerpUsingHSV (const FLinearColor &From, const FLinearColor &To, const float Progress)
 
static float Clamp01NansTo0 (float InValue)
 
static FLinearColor IntToDistinctColor (const int32 Seed, const float Saturation=1.f, const float Value=1.f, const float HueRotation=180.f)
 Helper function to generate distinct colors from a sequence of integers where each integer increment spins around the Hue wheel by increments of the golden ratio.
 

Public Attributes

union { 
 
   struct { 
 
      float   R 
 
      float   G 
 
      float   B 
 
      float   A 
 
   }  
 
   float   RGBA [4] 
 
};  
 

Static Public Attributes

static float Pow22OneOver255Table [256]
 
static CORE_API float sRGBToLinearTable [256]
 
static CORE_API const FLinearColor White
 
static CORE_API const FLinearColor Gray
 
static CORE_API const FLinearColor Black
 
static CORE_API const FLinearColor Transparent
 
static CORE_API const FLinearColor Red
 
static CORE_API const FLinearColor Green
 
static CORE_API const FLinearColor Blue
 
static CORE_API const FLinearColor Yellow
 

Friends

FArchiveoperator<< (FArchive &Ar, FLinearColor &Color)
 
void operator<< (FStructuredArchive::FSlot Slot, FLinearColor &Color)
 
UE_FORCEINLINE_HINT uint32 GetTypeHash (const FLinearColor &LinearColor)
 

Detailed Description

A linear, 32-bit/component floating point RGBA color.

Examples
/work/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

Constructor & Destructor Documentation

◆ FLinearColor() [1/9]

FLinearColor::FLinearColor ( )
default

◆ FLinearColor() [2/9]

UE_FORCEINLINE_HINT FLinearColor::FLinearColor ( EForceInit  )
inlineexplicit

◆ FLinearColor() [3/9]

constexpr UE_FORCEINLINE_HINT FLinearColor::FLinearColor ( float  InR,
float  InG,
float  InB,
float  InA = 1.0f 
)
inlineconstexpr

◆ FLinearColor() [4/9]

constexpr UE_FORCEINLINE_HINT FLinearColor::FLinearColor ( const FColor Color)
constexpr

Converts an FColor which is assumed to be in sRGB space, into linear color space.

Parameters
ColorThe sRGB color that needs to be converted into linear space. to get direct conversion use ReinterpretAsLinear

◆ FLinearColor() [5/9]

FLinearColor::FLinearColor ( const FVector3f Vector)

◆ FLinearColor() [6/9]

FLinearColor::FLinearColor ( const FVector3d Vector)
explicit

◆ FLinearColor() [7/9]

FLinearColor::FLinearColor ( const FVector4f Vector)

◆ FLinearColor() [8/9]

FLinearColor::FLinearColor ( const FVector4d Vector)
explicit

◆ FLinearColor() [9/9]

FLinearColor::FLinearColor ( const FFloat16Color C)
explicit

Member Function Documentation

◆ Clamp01NansTo0()

static float FLinearColor::Clamp01NansTo0 ( float  InValue)
inlinestatic

Helper for pixel format conversions. Clamps to [0,1], mapping NaNs to 0, for consistency with GPU conversions.

Parameters
InValueThe input value.
Returns
InValue clamped to [0,1]. NaNs map to 0.

◆ Component() [1/2]

float & FLinearColor::Component ( int32  Index)
inline

◆ Component() [2/2]

const float & FLinearColor::Component ( int32  Index) const
inline

◆ CopyWithNewOpacity()

constexpr FLinearColor FLinearColor::CopyWithNewOpacity ( float  NewOpacity) const
inlineconstexpr

◆ Desaturate()

FLinearColor FLinearColor::Desaturate ( float  Desaturation) const

Returns a desaturated color, with 0 meaning no desaturation and 1 == full desaturation

Parameters
DesaturationDesaturation factor in range [0..1]
Returns
Desaturated color

◆ Dist()

static float FLinearColor::Dist ( const FLinearColor V1,
const FLinearColor V2 
)
inlinestatic

Euclidean distance between two points.

◆ Equals()

UE_FORCEINLINE_HINT bool FLinearColor::Equals ( const FLinearColor ColorB,
float  Tolerance = UE_KINDA_SMALL_NUMBER 
) const
inline

◆ EvaluateBezier()

float FLinearColor::EvaluateBezier ( const FLinearColor ControlPoints,
int32  NumPoints,
TArray< FLinearColor > &  OutPoints 
)
static

Generates a list of sample points on a Bezier curve defined by 2 points.

Parameters
ControlPointsArray of 4 Linear Colors (vert1, controlpoint1, controlpoint2, vert2).
NumPointsNumber of samples.
OutPointsReceives the output samples.
Returns
Path length.

◆ FromPow22Color()

FLinearColor FLinearColor::FromPow22Color ( const FColor Color)
static

Converts an FColor coming from an observed Pow(1/2.2) output, into a linear color.

Parameters
ColorThe Pow(1/2.2) color that needs to be converted into linear space.

◆ FromSRGBColor()

static UE_FORCEINLINE_HINT FLinearColor FLinearColor::FromSRGBColor ( const FColor Color)
inlinestatic

Converts an FColor coming from an observed sRGB output, into a linear color.

Parameters
ColorThe sRGB color that needs to be converted into linear space.

◆ GetClamped()

FLinearColor FLinearColor::GetClamped ( float  InMin = 0.0f,
float  InMax = 1.0f 
) const
inline

◆ GetLuminance()

float FLinearColor::GetLuminance ( ) const

Computes the perceptually weighted luminance value of a color.

◆ GetMax()

UE_FORCEINLINE_HINT float FLinearColor::GetMax ( ) const
inline

Returns the maximum value in this color structure

Returns
The maximum color channel value

◆ GetMin()

UE_FORCEINLINE_HINT float FLinearColor::GetMin ( ) const
inline

Returns the minimum value in this color structure

Returns
The minimum color channel value

◆ HSVToLinearRGB()

FLinearColor FLinearColor::HSVToLinearRGB ( ) const

Converts an HSV color to a linear space RGB color

◆ InitFromString()

bool FLinearColor::InitFromString ( const FString &  InSourceString)

Initialize this Color based on an FString. The String is expected to contain R=, G=, B=, A=. The FLinearColor will be bogus when InitFromString returns false.

Parameters
InSourceStringFString containing the color values.
Returns
true if the R,G,B values were read successfully; false otherwise.

◆ IntToDistinctColor()

static FLinearColor FLinearColor::IntToDistinctColor ( const int32  Seed,
const float  Saturation = 1.f,
const float  Value = 1.f,
const float  HueRotation = 180.f 
)
inlinestatic

Helper function to generate distinct colors from a sequence of integers where each integer increment spins around the Hue wheel by increments of the golden ratio.

Parameters
Seedthe "seed" for a semi-random, but deterministic color
Saturation0-1 saturation of resulting color
Value0-1 brightness of resulting color
HueRotation0-360 amount to rotate around the hue wheel
Returns
color with semi-random hue

◆ IsAlmostBlack()

bool FLinearColor::IsAlmostBlack ( ) const
inline

useful to detect if a light contribution needs to be rendered

◆ LerpUsingHSV()

FLinearColor FLinearColor::LerpUsingHSV ( const FLinearColor From,
const FLinearColor To,
const float  Progress 
)
static

Linearly interpolates between two colors by the specified progress amount. The interpolation is performed in HSV color space taking the shortest path to the new color's hue. This can give better results than FMath::Lerp(), but is much more expensive. The incoming colors are in RGB space, and the output color will be RGB. The alpha value will also be interpolated.

Parameters
FromThe color and alpha to interpolate from as linear RGBA
ToThe color and alpha to interpolate to as linear RGBA
ProgressScalar interpolation amount (usually between 0.0 and 1.0 inclusive)
Returns
The interpolated color in linear RGB space along with the interpolated alpha value

◆ LinearRGBToHSV()

FLinearColor FLinearColor::LinearRGBToHSV ( ) const

Converts a linear space RGB color to an HSV color

◆ MakeFromColorTemperature()

FLinearColor FLinearColor::MakeFromColorTemperature ( float  Temp)
static

Converts temperature in Kelvins of a black body radiator to RGB chromaticity.

◆ MakeFromHSV8()

FLinearColor FLinearColor::MakeFromHSV8 ( uint8  H,
uint8  S,
uint8  V 
)
static

Converts byte hue-saturation-brightness to floating point red-green-blue.

◆ MakeRandomColor()

FLinearColor FLinearColor::MakeRandomColor ( )
static

Makes a random but quite nice color.

◆ MakeRandomSeededColor()

FLinearColor FLinearColor::MakeRandomSeededColor ( int32  Seed)
static

Makes a random color based on a seed.

◆ operator!=()

UE_FORCEINLINE_HINT bool FLinearColor::operator!= ( const FLinearColor Other) const
inline

◆ operator*() [1/2]

FLinearColor FLinearColor::operator* ( const FLinearColor ColorB) const
inline

◆ operator*() [2/2]

FLinearColor FLinearColor::operator* ( float  Scalar) const
inline

◆ operator*=() [1/2]

FLinearColor & FLinearColor::operator*= ( const FLinearColor ColorB)
inline

◆ operator*=() [2/2]

FLinearColor & FLinearColor::operator*= ( float  Scalar)
inline

◆ operator+()

FLinearColor FLinearColor::operator+ ( const FLinearColor ColorB) const
inline

◆ operator+=()

FLinearColor & FLinearColor::operator+= ( const FLinearColor ColorB)
inline

◆ operator-()

FLinearColor FLinearColor::operator- ( const FLinearColor ColorB) const
inline

◆ operator-=()

FLinearColor & FLinearColor::operator-= ( const FLinearColor ColorB)
inline

◆ operator/() [1/2]

FLinearColor FLinearColor::operator/ ( const FLinearColor ColorB) const
inline

◆ operator/() [2/2]

FLinearColor FLinearColor::operator/ ( float  Scalar) const
inline

◆ operator/=() [1/2]

FLinearColor & FLinearColor::operator/= ( const FLinearColor ColorB)
inline

◆ operator/=() [2/2]

FLinearColor & FLinearColor::operator/= ( float  Scalar)
inline

◆ operator==()

UE_FORCEINLINE_HINT bool FLinearColor::operator== ( const FLinearColor ColorB) const
inline

Comparison operators

◆ QuantizeFloor()

FColor FLinearColor::QuantizeFloor ( ) const
inline

Quantizes the linear color and returns the result as a FColor. This bypasses the SRGB conversion. Uses floor quantization, which does not match the GPU standard conversion. Restoration to float should be done with a +0.5 bias to restore to centered buckets. Do NOT use this for graphics or textures or images, use QuantizeRound instead.

◆ QuantizeRound()

FColor FLinearColor::QuantizeRound ( ) const
inline

Quantizes the linear color with rounding and returns the result as a FColor. This bypasses the SRGB conversion. QuantizeRound can be dequantized back to linear with FColor::ReinterpretAsLinear (just /255.f) this matches the GPU UNORM<->float conversion spec and should be preferred

◆ Serialize() [1/2]

bool FLinearColor::Serialize ( FArchive Ar)
inline

◆ Serialize() [2/2]

bool FLinearColor::Serialize ( FStructuredArchive::FSlot  Slot)
inline

◆ ToFColor()

FColor FLinearColor::ToFColor ( const bool  bSRGB) const
inline

◆ ToFColorSRGB()

FColor FLinearColor::ToFColorSRGB ( ) const

Quantizes the linear color and returns the result as a FColor with optional sRGB conversion. Clamps in [0,1] range before conversion. ToFColor(false) is QuantizeRound

Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal.

◆ ToRGBE()

FColor FLinearColor::ToRGBE ( ) const

Converts from a linear float color to RGBE as outlined in Gregory Ward's Real Pixels article, Graphics Gems II, page 80. Implementation details in https://cbloomrants.blogspot.com/2020/06/widespread-error-in-radiance-hdr-rgbe.html

◆ ToString()

FString FLinearColor::ToString ( ) const

Friends And Related Symbol Documentation

◆ GetTypeHash

UE_FORCEINLINE_HINT uint32 GetTypeHash ( const FLinearColor LinearColor)
friend

◆ operator<< [1/2]

FArchive & operator<< ( FArchive Ar,
FLinearColor Color 
)
friend

◆ operator<< [2/2]

void operator<< ( FStructuredArchive::FSlot  Slot,
FLinearColor Color 
)
friend

Member Data Documentation

◆ [union]

union { ... } FLinearColor

◆ A

float FLinearColor::A

◆ B

float FLinearColor::B

◆ Black

const FLinearColor FLinearColor::Black
static

◆ Blue

const FLinearColor FLinearColor::Blue
static

◆ G

float FLinearColor::G

◆ Gray

const FLinearColor FLinearColor::Gray
static

◆ Green

const FLinearColor FLinearColor::Green
static

◆ Pow22OneOver255Table

float FLinearColor::Pow22OneOver255Table
static

Static lookup table used for FColor -> FLinearColor conversion. Pow(2.2)

Pow table for fast FColor -> FLinearColor conversion.

FMath::Pow( i / 255.f, 2.2f )

◆ R

float FLinearColor::R

◆ Red

const FLinearColor FLinearColor::Red
static

◆ RGBA

float FLinearColor::RGBA[4]

◆ sRGBToLinearTable

float FLinearColor::sRGBToLinearTable
static

Static lookup table used for FColor -> FLinearColor conversion. sRGB

Table for fast FColor -> FLinearColor conversion.

Color > 0.04045 ? pow( Color * (1.0 / 1.055) + 0.0521327, 2.4 ) : Color * (1.0 / 12.92);

◆ Transparent

const FLinearColor FLinearColor::Transparent
static

◆ White

const FLinearColor FLinearColor::White
static

◆ Yellow

const FLinearColor FLinearColor::Yellow
static

The documentation for this struct was generated from the following files: