From f74abf1d2b00343524252abf3385ab38082c6bf9 Mon Sep 17 00:00:00 2001 From: engineer_apple Date: Sun, 1 Mar 2020 16:19:03 +0000 Subject: [PATCH] burning: GL_FOG_COORDINATE_SOURCE ,GL_FRAGMENT_DEPTH -> abs(EyeSpace.vertex.z) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6104 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CSoftwareDriver2.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 0536491d..cb8f1a18 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -1592,16 +1592,21 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest { f32 fog_factor = 1.f; + // GL_FRAGMENT_DEPTH -> abs(EyeSpace.vertex.z) + ieee754 fog_frag_coord; + fog_frag_coord.f = EyeSpace.vertex.z; + fog_frag_coord.fields.sign = 0; + switch (FogType) { case EFT_FOG_LINEAR: - fog_factor = (FogEnd - EyeSpace.vertex.z) * EyeSpace.fog_scale; + fog_factor = (FogEnd - fog_frag_coord.f) * EyeSpace.fog_scale; break; case EFT_FOG_EXP: - fog_factor = (f32)exp(-FogDensity * EyeSpace.vertex.z); + fog_factor = (f32)exp(-FogDensity * fog_frag_coord.f); break; case EFT_FOG_EXP2: - fog_factor = (f32)exp(-FogDensity * FogDensity * EyeSpace.vertex.z * EyeSpace.vertex.z); + fog_factor = (f32)exp(-FogDensity * FogDensity * fog_frag_coord.f * fog_frag_coord.f); break; }