Class ColorUtils | Core RP Library | 7.3.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class ColorUtils

    A set of color manipulation utilities.

    Inheritance
    Object
    ColorUtils
    Namespace: UnityEngine.Rendering
    Syntax
    public static class ColorUtils

    Methods

    CIExyToLMS(Single, Single)

    CIE xy chromaticity to CAT02 LMS. http://en.wikipedia.org/wiki/LMS_color_space#CAT02

    Declaration
    public static Vector3 CIExyToLMS(float x, float y)
    Parameters
    Type Name Description
    Single x
    Single y
    Returns
    Type Description
    Vector3

    ColorBalanceToLMSCoeffs(Single, Single)

    Converts white balancing parameter to LMS coefficients.

    Declaration
    public static Vector3 ColorBalanceToLMSCoeffs(float temperature, float tint)
    Parameters
    Type Name Description
    Single temperature

    A temperature offset, in range [-100;100].

    Single tint

    A tint offset, in range [-100;100].

    Returns
    Type Description
    Vector3

    LMS coefficients.

    ComputeEV100(Single, Single, Single)

    Computes an exposure value (EV100) from physical camera settings.

    Declaration
    public static float ComputeEV100(float aperture, float shutterSpeed, float ISO)
    Parameters
    Type Name Description
    Single aperture

    The camera aperture.

    Single shutterSpeed

    The camera exposure time.

    Single ISO

    The camera sensor sensitivity.

    Returns
    Type Description
    Single

    An exposure value, in EV100.

    ComputeEV100FromAvgLuminance(Single)

    Computes an exposure value (EV100) from an average luminance value.

    Declaration
    public static float ComputeEV100FromAvgLuminance(float avgLuminance)
    Parameters
    Type Name Description
    Single avgLuminance

    An average luminance value.

    Returns
    Type Description
    Single

    An exposure value, in EV100.

    ComputeISO(Single, Single, Single)

    Computes the required ISO to reach targetEV100.

    Declaration
    public static float ComputeISO(float aperture, float shutterSpeed, float targetEV100)
    Parameters
    Type Name Description
    Single aperture

    The camera aperture.

    Single shutterSpeed

    The camera exposure time.

    Single targetEV100

    The target exposure value (EV100) to reach.

    Returns
    Type Description
    Single

    The required sensor sensitivity (ISO).

    ConvertEV100ToExposure(Single)

    Converts an exposure value (EV100) to a linear multiplier.

    Declaration
    public static float ConvertEV100ToExposure(float EV100)
    Parameters
    Type Name Description
    Single EV100

    The exposure value to convert, in EV100.

    Returns
    Type Description
    Single

    A linear multiplier.

    ConvertExposureToEV100(Single)

    Converts a linear multiplier to an exposure value (EV100).

    Declaration
    public static float ConvertExposureToEV100(float exposure)
    Parameters
    Type Name Description
    Single exposure

    A linear multiplier.

    Returns
    Type Description
    Single

    An exposure value, in EV100.

    Luminance(Color)

    Returns the luminance of the specified color. The input is considered to be in linear space with sRGB primaries and a D65 white point.

    Declaration
    public static float Luminance(in Color color)
    Parameters
    Type Name Description
    Color color

    The color to compute the luminance for.

    Returns
    Type Description
    Single

    A luminance value.

    PrepareLiftGammaGain(Vector4, Vector4, Vector4)

    Pre-filters lift, gamma and gain trackball values for shader use.

    Declaration
    public static (Vector4, Vector4, Vector4)PrepareLiftGammaGain(in Vector4 inLift, in Vector4 inGamma, in Vector4 inGain)
    Parameters
    Type Name Description
    Vector4 inLift

    A color used for lift.

    Vector4 inGamma

    A color used for gamma.

    Vector4 inGain

    A color used for gain.

    Returns
    Type Description
    ValueTuple<Vector4, Vector4, Vector4>

    The three input colors pre-filtered for shader use.

    PrepareShadowsMidtonesHighlights(Vector4, Vector4, Vector4)

    Pre-filters shadows, midtones and highlights trackball values for shader use.

    Declaration
    public static (Vector4, Vector4, Vector4)PrepareShadowsMidtonesHighlights(in Vector4 inShadows, in Vector4 inMidtones, in Vector4 inHighlights)
    Parameters
    Type Name Description
    Vector4 inShadows

    A color used for shadows.

    Vector4 inMidtones

    A color used for midtones.

    Vector4 inHighlights

    A color used for highlights.

    Returns
    Type Description
    ValueTuple<Vector4, Vector4, Vector4>

    The three input colors pre-filtered for shader use.

    PrepareSplitToning(Vector4, Vector4, Single)

    Pre-filters colors used for the split toning effect.

    Declaration
    public static (Vector4, Vector4)PrepareSplitToning(in Vector4 inShadows, in Vector4 inHighlights, float balance)
    Parameters
    Type Name Description
    Vector4 inShadows

    A color used for shadows.

    Vector4 inHighlights

    A color used for highlights.

    Single balance

    The balance between the shadow and highlight colors, in range [-100;100].

    Returns
    Type Description
    ValueTuple<Vector4, Vector4>

    The two input colors pre-filtered for shader use.

    StandardIlluminantY(Single)

    An analytical model of chromaticity of the standard illuminant, by Judd et al. http://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D Slightly modifed to adjust it with the D65 white point (x=0.31271, y=0.32902).

    Declaration
    public static float StandardIlluminantY(float x)
    Parameters
    Type Name Description
    Single x
    Returns
    Type Description
    Single

    ToHex(Color)

    Converts a color value to its 32-bit hexadecimal representation.

    Declaration
    public static uint ToHex(Color c)
    Parameters
    Type Name Description
    Color c

    The color to convert.

    Returns
    Type Description
    UInt32

    A 32-bit hexadecimal representation of the color.

    ToRGBA(UInt32)

    Converts a 32-bit hexadecimal value to a color value.

    Declaration
    public static Color ToRGBA(uint hex)
    Parameters
    Type Name Description
    UInt32 hex

    A 32-bit hexadecimal value.

    Returns
    Type Description
    Color

    A color value.

    In This Article
    • Methods
      • CIExyToLMS(Single, Single)
      • ColorBalanceToLMSCoeffs(Single, Single)
      • ComputeEV100(Single, Single, Single)
      • ComputeEV100FromAvgLuminance(Single)
      • ComputeISO(Single, Single, Single)
      • ConvertEV100ToExposure(Single)
      • ConvertExposureToEV100(Single)
      • Luminance(Color)
      • PrepareLiftGammaGain(Vector4, Vector4, Vector4)
      • PrepareShadowsMidtonesHighlights(Vector4, Vector4, Vector4)
      • PrepareSplitToning(Vector4, Vector4, Single)
      • StandardIlluminantY(Single)
      • ToHex(Color)
      • ToRGBA(UInt32)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023