Intrinsics1 min read

log10

Computes the base-10 logarithm.

Reading Time
1 min
Word Count
80
Sections
7
Try It Live

Test log10 in a live shader

Open the playground, start from a visual preset, and wire log10 into the fragment stage to see how it behaves with real values.

Open Playground

The log10 function returns the base-10 logarithm of a value. BWSL lowers it portably as log2(x) * 0.30102999566.

Live Demo

Signature

bwsl
log10 :: (T x) -> T

Where T can be float, float2, float3, or float4.

Parameters

ParameterTypeDescription
xTInput value. Components must be greater than 0

Return Value

Returns the base-10 logarithm of x.

Example

bwsl
float luminance = max(dot(color, float3(0.2126, 0.7152, 0.0722)), 0.0001);
float exposureStops = log10(luminance);

Compiled Output

When compiled portably:

bwsl
log2(x) * 0.30102999566

See Also

  • log - Natural logarithm
  • log2 - Base-2 logarithm
  • exp - Natural exponential