diff options
| author | Stenzek <stenzek@gmail.com> | 2018-02-03 17:01:34 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-02-15 22:19:21 +1000 |
| commit | 340ee8fff86c3ec0d290566531fc58f9e7965b76 (patch) | |
| tree | 886d285aec98f5bd1f4c50de276826e056e124b8 /Source/Core/VideoCommon/PixelShaderManager.cpp | |
| parent | e7d0aae5be8b377aeaa1ede935dc70b34f670154 (diff) | |
PixelShaderGen: Implement table-based fog range as in software renderer
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderManager.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index 783f5e179c..3ff6f9f073 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -110,16 +110,23 @@ void PixelShaderManager::SetConstants() // they are the coefficients from the center to the border of the screen // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale // TODO: Shouldn't this be EFBToScaledXf? - constants.fogf[0][0] = ScreenSpaceCenter; - constants.fogf[0][1] = + constants.fogf[2] = ScreenSpaceCenter; + constants.fogf[3] = static_cast<float>(g_renderer->EFBToScaledX(static_cast<int>(2.0f * xfmem.viewport.wd))); - constants.fogf[0][2] = bpmem.fogRange.K[4].HI / 256.0f; + + for (size_t i = 0, vec_index = 0; i < ArraySize(bpmem.fogRange.K); i++) + { + constexpr float scale = 4.0f; + constants.fogrange[vec_index / 4][vec_index % 4] = bpmem.fogRange.K[i].GetValue(0) * scale; + vec_index++; + constants.fogrange[vec_index / 4][vec_index % 4] = bpmem.fogRange.K[i].GetValue(1) * scale; + vec_index++; + } } else { - constants.fogf[0][0] = 0; - constants.fogf[0][1] = 1; - constants.fogf[0][2] = 1; + constants.fogf[2] = 0; + constants.fogf[3] = 1; } dirty = true; @@ -409,17 +416,17 @@ void PixelShaderManager::SetFogParamChanged() { if (!g_ActiveConfig.bDisableFog) { - constants.fogf[1][0] = bpmem.fog.GetA(); + constants.fogf[0] = bpmem.fog.GetA(); + constants.fogf[1] = bpmem.fog.GetC(); constants.fogi[1] = bpmem.fog.b_magnitude; - constants.fogf[1][2] = bpmem.fog.GetC(); constants.fogi[3] = bpmem.fog.b_shift; constants.fogParam3 = bpmem.fog.c_proj_fsel.hex; } else { - constants.fogf[1][0] = 0.f; + constants.fogf[0] = 0.f; + constants.fogf[1] = 0.f; constants.fogi[1] = 1; - constants.fogf[1][2] = 0.f; constants.fogi[3] = 1; constants.fogParam3 = 0; } |
