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.
Inherited Members
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:
where |
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). |