mx_srgb_texture_to_lin_rec709
Accurately converts a color sampled from an sRGB texture into the linear Rec.709 color space, required for physically-based lighting calculations.
Core Advantages
Encapsulates the standard sRGB-to-Linear conversion formula, ensuring physically accurate rendering and simplifying the color management workflow by removing the need for manual math implementation.
Common Uses
Decoding the base color (Albedo) texture for PBR materials to prepare it for lighting calculations.
Preprocessing sRGB textures to linear color before performing image processing operations like blending or adjustments.
Converting emissive maps to ensure their intensity correctly accumulates with other light sources.
How to adjust
This is a fixed mathematical function with no adjustable parameters. Its effect is seen in the input vs. output difference: for example, a mid-gray sRGB input of `vec3(0.5)` is converted to a much darker linear value of `vec3(0.214)`. Crucially, any color blending or math operations should be performed *after* this conversion, in linear space, to ensure physically correct results.
Code Examples
1// Convert the sRGB texture sample to a linear color
2const linearColor = mx_srgb_texture_to_lin_rec709( texture( mySrgbTexture ) );
3
4// Use the converted color for the material
5material.colorNode = linearColor;