log
Calculates the natural logarithm (ln(x)), used to non-linearly compress high-value ranges or expand details in low-value areas.
Core Advantages
Its core advantage is mapping values with a very wide dynamic range (like HDR colors) into a manageable range, while amplifying differences in low-value areas, making it ideal for tone mapping and enhancing dark details.
Common Uses
High Dynamic Range (HDR) Tone Mapping
Enhancing dark details in textures
Adjusting light falloff curves
Procedural pattern generation
How to adjust
The effect is determined by the input `x`. Since the log function grows very rapidly for `x` near 0 and slows down for larger `x`, it effectively 'brightens' dark areas of the input while 'compressing' bright areas to prevent overexposure, a common technique in tone mapping.
Code Examples
1// Brighten dark areas while compressing highlights using log
2// Adding 1.0 avoids taking the log of zero
3const tonemappedColor = log( hdrColor.add( 1.0 ) );