diff --git a/Source/Core/VideoCommon/Src/BPMemory.h b/Source/Core/VideoCommon/Src/BPMemory.h index 3a7bf46bee..9ffdce0582 100644 --- a/Source/Core/VideoCommon/Src/BPMemory.h +++ b/Source/Core/VideoCommon/Src/BPMemory.h @@ -686,6 +686,8 @@ union FogRangeKElement u32 LO : 12; u32 regid : 8; }; + // TODO: Which scaling coefficient should we use here? This is just a guess! + float GetValue(int i) { return (i ? HI : LO) / 32.f; } u32 HEX; }; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp index 3d5c0d7724..ec4018c7ae 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp @@ -748,10 +748,15 @@ void Tev::Draw() } - // stuff to do! - // here, where we'll have to add/handle x range adjustment (if related BP register it's enabled) - // x_adjust = sqrt((x-center)^2 + k^2)/k - // ze *= x_adjust + if(bpmem.fogRange.Base.Enabled) + { + // TODO: Check if this is correct (especially the magic values) + float offset = Position[0] - bpmem.fogRange.Base.Center + 324.f; + int index = 9 - abs(Position[0] - bpmem.fogRange.Base.Center + 324) / (162/5); + float k = bpmem.fogRange.K[index/2].GetValue(index%2); + float x_adjust = sqrt(offset*offset/162.f/162.f + k*k)/k; + ze *= x_adjust; + } ze -= bpmem.fog.c_proj_fsel.GetC();