UKismetMathLibrary::LinearColor_SetFromSRGB
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Converts an 8-bit sRGB FColor into linear-space FLinearColor using the proper sRGB transfer function. Use this when your source color originated in a color picker, asset, or texture that encodes values in sRGB.
Caveats & Gotchas
- • The sRGB transfer function is not a simple power-of-2.2 curve — it uses a piecewise formula with a linear segment near zero. Using LinearColor_SetFromPow22 instead will give slightly wrong results for dark colors.
- • FColor's byte values are 0–255. Values are divided by 255 and then decoded. There is no range check; malformed FColor inputs with high bytes are technically valid but produce values > 1.0 after decode only if the byte was 255.
Signature
static UE_INL_API void LinearColor_SetFromSRGB(UPARAM(ref) FLinearColor& InOutColor, const FColor& InSRGB) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutColor | FLinearColor& | The LinearColor variable to write the converted result into. | — |
| InSRGB | const FColor& | An 8-bit FColor assumed to be in sRGB gamma space (as read from a texture or color picker). | — |
Return Type
void Example
Convert a designer-specified sRGB color to linear for material use C++
FColor DesignerColor = FColor(255, 128, 0, 255); // orange from color picker
FLinearColor LinearOrange;
UKismetMathLibrary::LinearColor_SetFromSRGB(LinearOrange, DesignerColor);
// LinearOrange now holds the correct linear-space equivalent See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?