TriLib
Search Results for

    Show / Hide Table of Contents

    Class ColorUtils

    Provides utility methods for color calculations, including conversions from specular properties to glossiness or metallic values. These methods are useful when adapting material properties between different shading models or pipelines.

    Inheritance
    object
    ColorUtils
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: TriLibCore.Utils
    Assembly: TriLibCore.dll
    Syntax
    public static class ColorUtils

    Methods

    SpecularToGlossiness(Color, float)

    Converts a specular color and a shinniness exponent into a glossiness value.

    Declaration
    public static float SpecularToGlossiness(Color specularBase, float shinninessExponent)
    Parameters
    Type Name Description
    Color specularBase

    The base specular color. Its red, green, and blue components are used to compute a weighted average for intensity.

    float shinninessExponent

    The exponent representing the shininess of the material. Larger values indicate a sharper specular highlight.

    Returns
    Type Description
    float

    A glossiness value computed using the formula:

    DiffuseGlossiness = 1 - sqrt(2 / (shinninessExponent * specularIntensity + 2))

    where specularIntensity is calculated as: 0.2125 * specularBase.r + 0.7154 * specularBase.g + 0.0721 * specularBase.b.

    SpecularToMetallic(Color, Color)

    Converts a specular color and a default diffuse color into a metallic value.

    Declaration
    public static float SpecularToMetallic(Color specularBase, Color defaultDiffuse)
    Parameters
    Type Name Description
    Color specularBase

    The base specular color of the material, which affects how “metal-like” the surface appears.

    Color defaultDiffuse

    The default diffuse color of the material. This color is used to calculate the diffuse brightness.

    Returns
    Type Description
    float

    A metallic value between 0 and 1, computed by comparing the brightness of the specular and diffuse components. The calculation involves a correction for dielectric specular reflectance (set to 0.04).

    In this article
    Back to top Generated by DocFX