Skip to content

Commit

Permalink
Fix pixel offset at higher IRs
Browse files Browse the repository at this point in the history
  • Loading branch information
iwubcode committed Jan 22, 2017
1 parent 5cee3f9 commit aaa428d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions Source/Core/VideoCommon/BPStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ static void BPWritten(const BPCmd& bp)
srcRect.left = (int)bpmem.copyTexSrcXY.x;
srcRect.top = (int)bpmem.copyTexSrcXY.y;

// Here Width+1 like Height, otherwise some textures are corrupted already since the native
// resolution.
// TODO: What's the behavior of out of bound access?
// The width/height of the region is off by 1 from what the game developer actually intended
// so add 1 to compensate
srcRect.right = (int)(bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1);
srcRect.bottom = (int)(bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1);

Expand Down
12 changes: 7 additions & 5 deletions Source/Core/VideoCommon/VertexShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,13 @@ void VertexShaderManager::SetConstants()
// in VertexShaderGen.cpp for details.
// NOTE: If we ever emulate antialiasing, the sample locations set by
// BP registers 0x01-0x04 need to be considered here.
const float pixel_center_correction = 7.0f / 12.0f - 0.5f;
const float pixel_size_x = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.wd);
const float pixel_size_y = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.ht);
constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x;
constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y;
// NOTE 2: We use a scalar to fix offset bugs at higher resolutions (Silent Hill, Spongebob, Sonic games)
const float scalar = Renderer::EFBToScaledXf(1);
const float pixel_center_correction = (7.0f / 12.0f) * scalar - 0.5f;
const float pixel_size_x = (2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.wd));
const float pixel_size_y = (2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.ht));
constants.pixelcentercorrection[0] = (pixel_center_correction * pixel_size_x);
constants.pixelcentercorrection[1] = (pixel_center_correction * pixel_size_y);

// By default we don't change the depth value at all in the vertex shader.
constants.pixelcentercorrection[2] = 1.0f;
Expand Down

0 comments on commit aaa428d

Please sign in to comment.