Parameters
Name | Type | Description |
---|---|---|
x | f32 | Input value. |
base | f32 | Exponential base. |
scale | f32 | Scale factor. |
offset | f32 | Vertical offset. |
Returns
vec2<f32>value and derivative.
WGSL Code
fn exponentialRamp(x: f32, base: f32, scale: f32, offset: f32) -> vec2<f32> {// Ensure base is positive and not 1 (which would make it linear)let b = select(base, 2.71828, abs(base - 1.0) < 0.001);// Calculate the exponential functionlet result = scale * pow(b, x) + offset;// Calculate the derivativelet derivative = scale * pow(b, x) * log(b);return vec2<f32>(result, derivative);}