Skip to content

color

All BSL intrinsic functions related to color.

Return Name Description
float4 toGammaRGB( in float4 rgb ) Convert the color from a linear color into a Gamma color. Return pow( rgb, 0.454545 )
float4 fromGammaRGB( in float4 rgb ) Convert a Gamma color into a linear color. Return pow( rgb, 2.2 )
float fromsRGB8( in float rgb ) Convert a 8 bit like RGB monochrome color into a linear float color. fromsRGB8(255) => 1.0
float4 fromsRGB8( in float r, in float g, in float b ) Convert a 8 bit like RGB color into a linear float color. fromsRGB8(255,0,0) => float4(1,0,0,1)
float4 fromsRGB( in float4 rgb ) Convert a sRGB color into a linear float color.
float4 fromHueToRGB( in float h ) Return the RGB color corresponding to the given Hue value. Hue is defined in the range [0,1] but value out of range are valid.
float4 fromRGBtoHSV( in float4 c ) Return the HSV color corresponding to the given RGB color.
float4 fromRGBtoHCV( in float4 c ) Return HCV ( Hue ChromaKey, Value ) color corresponding to the given RGB color.
float4 fromHSVtoRGB( in float4 c ) Return the RGB color corresponding to the given HSVcolor.
float4 fromPreMulAlpha( in float4 c ) Return the RGBA in linear color space from the Premulitplied Alpha color space
float luminance( in [float4] c ) Return the luminance if the given color. Return dot( c.xyz, float3(0.299,0.587,0.114) ) Works with float3, float4
float mulA( in float4 c, float a ) Multiply the alpha channel of a color by a given factor. Return float4( c.xyz, c.w*a )
[float3] saturateColor( in [float3] c ) If color component are out of bound this function will automatically saturate according to the color luminance Works with float3, float4.
[float3] setLuminance( in [float3] c, in float l ) Return the given color with a modified luminance Works with float3, float4.
[float3] adjustBrightness( in [float3] c, float v ) Adjust the brightness of the input color c. Typically v should be in the range [-1,1] Works with float3, float4.
[float3] adjustContrast( in [float3] c, float v ) Adjust the contrast of the input color c. Typically v should be in the range [-1,1] Works with float3, float4.