mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
More robust approximation of distance attenuation at extreme settings.
Fixes artifacts that occur when attenuation zone coef = 1.0 and distance > 32m.
This commit is contained in:
parent
4c502cdbc9
commit
328809f008
1 changed files with 4 additions and 2 deletions
|
@ -43,8 +43,9 @@ static inline float fastLog2f(float x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// for -127 <= x < 128, returns exp2(x)
|
// for -126 <= x < 128, returns exp2(x)
|
||||||
// otherwise, returns undefined
|
// for x < -126, returns 0
|
||||||
|
// for x >= 128, returns undefined
|
||||||
//
|
//
|
||||||
// rel |error| < 9e-6, smooth (exact for x=N)
|
// rel |error| < 9e-6, smooth (exact for x=N)
|
||||||
//
|
//
|
||||||
|
@ -60,6 +61,7 @@ static inline float fastExp2f(float x) {
|
||||||
x -= xi.i;
|
x -= xi.i;
|
||||||
|
|
||||||
// construct exp2(xi) as a float
|
// construct exp2(xi) as a float
|
||||||
|
xi.i &= ~(xi.i >> 31); // MAX(xi.i, 0)
|
||||||
xi.i <<= IEEE754_MANT_BITS;
|
xi.i <<= IEEE754_MANT_BITS;
|
||||||
|
|
||||||
// polynomial for exp2(x) over x=[0,1]
|
// polynomial for exp2(x) over x=[0,1]
|
||||||
|
|
Loading…
Reference in a new issue