docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ColorUtils

    A set of color manipulation utilities.

    Inheritance
    object
    ColorUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public static class ColorUtils

    Fields

    s_LensAttenuation

    Factor used for our lens system w.r.t. exposure calculation. Modifying this will lead to a change on how linear exposure multipliers are computed from EV100 values (and viceversa). s_LensAttenuation models transmission attenuation and lens vignetting. Note that according to the standard ISO 12232, a lens saturates at s_LensAttenuation = 0.78f (under ISO 100).

    Declaration
    public static float s_LensAttenuation
    Field Value
    Type Description
    float

    s_LightMeterCalibrationConstant

    Calibration constant (K) used for our virtual reflected light meter. Modifying this will lead to a change on how average scene luminance gets mapped to exposure.

    Declaration
    public static float s_LightMeterCalibrationConstant
    Field Value
    Type Description
    float

    Properties

    lensImperfectionExposureScale

    Scale applied to exposure caused by lens imperfection. It is computed from s_LensAttenuation as follow: (78 / ( S * q )) where S = 100 and q = s_LensAttenuation

    Declaration
    public static float lensImperfectionExposureScale { get; }
    Property Value
    Type Description
    float

    Methods

    CIExyToLMS(float, float)

    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
    float x

    The x value in the CIE xy chromaticity.

    float y

    The y value in the CIE xy chromaticity.

    Returns
    Type Description
    Vector3

    Vector3 representing the conversion from CIE xy chromaticity to CAT02 LMS color space.

    ColorBalanceToLMSCoeffs(float, float)

    Converts white balancing parameter to LMS coefficients.

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

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

    float tint

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

    Returns
    Type Description
    Vector3

    LMS coefficients.

    ComputeEV100(float, float, float)

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

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

    The camera aperture.

    float shutterSpeed

    The camera exposure time.

    float ISO

    The camera sensor sensitivity.

    Returns
    Type Description
    float

    An exposure value, in EV100.

    ComputeEV100FromAvgLuminance(float)

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

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

    An average luminance value.

    Returns
    Type Description
    float

    An exposure value, in EV100.

    ComputeISO(float, float, float)

    Computes the required ISO to reach targetEV100.

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

    The camera aperture.

    float shutterSpeed

    The camera exposure time.

    float targetEV100

    The target exposure value (EV100) to reach.

    Returns
    Type Description
    float

    The required sensor sensitivity (ISO).

    ConvertEV100ToExposure(float)

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

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

    The exposure value to convert, in EV100.

    Returns
    Type Description
    float

    A linear multiplier.

    ConvertExposureToEV100(float)

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

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

    A linear multiplier.

    Returns
    Type Description
    float

    An exposure value, in EV100.

    Luminance(in 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
    float

    A luminance value.

    PrepareLiftGammaGain(in Vector4, in Vector4, in 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
    (Vector4, Vector4, Vector4)

    The three input colors pre-filtered for shader use.

    PrepareShadowsMidtonesHighlights(in Vector4, in Vector4, in 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
    (Vector4, Vector4, Vector4)

    The three input colors pre-filtered for shader use.

    PrepareSplitToning(in Vector4, in Vector4, float)

    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.

    float balance

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

    Returns
    Type Description
    (Vector4, Vector4)

    The two input colors pre-filtered for shader use.

    StandardIlluminantY(float)

    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
    float x

    The input value representing the chromaticity measure.

    Returns
    Type Description
    float

    Returns the calculated value of the standard illuminant's Y-coordinate based on the input x.

    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
    uint

    A 32-bit hexadecimal representation of the color.

    ToRGBA(uint)

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

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

    A 32-bit hexadecimal value.

    Returns
    Type Description
    Color

    A color value.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)