mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-14 01:59:34 +01:00
Merge pull request #15155 from unknownbrackets/softgpu-fog
softgpu: Clamp and round fog by mantissa bits
This commit is contained in:
1 file changed
+13
-4
@@ -97,12 +97,21 @@ static inline Vec4<float> Interpolate(const float &c0, const float &c1, const fl
|
||||
}
|
||||
|
||||
static inline u8 ClampFogDepth(float fogdepth) {
|
||||
if (fogdepth <= 0.0f)
|
||||
union FloatBits {
|
||||
float f;
|
||||
u32 u;
|
||||
};
|
||||
FloatBits f;
|
||||
f.f = fogdepth;
|
||||
|
||||
u32 exp = f.u >> 23;
|
||||
if ((f.u & 0x80000000) != 0 || exp <= 126 - 8)
|
||||
return 0;
|
||||
else if (fogdepth >= 1.0f)
|
||||
if (exp > 126)
|
||||
return 255;
|
||||
else
|
||||
return (u8)(u32)(fogdepth * 255.0f);
|
||||
|
||||
u32 mantissa = (f.u & 0x007FFFFF) | 0x00800000;
|
||||
return mantissa >> (16 + 126 - exp);
|
||||
}
|
||||
|
||||
static inline int ClampUV(int v, int height) {
|
||||
|
||||
Reference in new issue
Block a user