UKismetMathLibrary::LinearColor_Distance
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Computes the Euclidean distance between two linear colors treated as 4D vectors (R, G, B, A). Useful for threshold checks like "are these colors similar enough?".
Caveats & Gotchas
- • Operates in linear (HDR) color space — colors with values outside [0,1] are valid inputs and will produce distances greater than sqrt(4).
- • The alpha channel is included in the distance calculation, so two colors that differ only in opacity will still have a non-zero distance.
Signature
static UE_INL_API float LinearColor_Distance(FLinearColor C1, FLinearColor C2); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| C1 | FLinearColor | First color point. | — |
| C2 | FLinearColor | Second color point. | — |
Return Type
float Example
Check if two colors are perceptually close C++
FLinearColor A = FLinearColor(1.f, 0.f, 0.f, 1.f);
FLinearColor B = FLinearColor(0.9f, 0.05f, 0.05f, 1.f);
float Dist = UKismetMathLibrary::LinearColor_Distance(A, B);
if (Dist < 0.2f)
{
// Colors are close enough
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?