-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable toggle to round vertices to nearest pixel #4715
Add configurable toggle to round vertices to nearest pixel #4715
Conversation
aaa428d
to
92a79df
Compare
Can you provide some images of what this effects? |
// 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 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@MayImilae - here's some comparisons of what I've found...I'm planning on doing more testing of other areas/games: (see below for updated comparisons) |
Is it possible to use the FIFO CI system for higher IR screens? This seems like something that would be a good candidate for that kind of testing. |
You'd have to ask @delroth about the viability of a special bot for that. |
bebc912
to
863414d
Compare
Does this fix the pixel border in TS2 ? |
@Lee91x - which game is that from? Feel free to test it and let me know! |
I do believe TS2 stands for "TimeSplitters 2" https://en.wikipedia.org/wiki/TimeSplitters_2 |
863414d
to
19db701
Compare
01b44dd
to
6785644
Compare
// however, higher resolutions than the Wii outputs | ||
// cause an additional pixel offset | ||
// due to a higher pixel density | ||
// we need to correc this by converting our |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// clip-space position into the Wii's screen-space | ||
// acquire the right pixel and then convert it back | ||
out.Write("float ss_pixel_x = ((o.pos.x + 1.0f) * (640.0f * 0.5f));\n"); | ||
out.Write("float ss_pixel_y = ((o.pos.y + 1.0f) * (480.0f * 0.5f));\n"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:
automated-fifoci-reporter |
@phire and I were talking about this and he informed me that my math for converting to screenspace from clip-space was wrong because I was not including 'w' into the calculation. This wasn't intentional but after messing around with it, adding 'w' gives jumpy effects to some vertices. So I plan on leaving it out. Phire commented on what effect this would have:
Lastly, this was never meant for 1x resolution. I left it in, to get an idea of what kind of impact my changes would have. Ideally, there'd be no changes in the fifolog but unfortunately that seems to be very difficult to achieve. How would other Dolphin developers feel about adding this as a hack to fix these additional games at higher IR? (as in, only generate this shader code when higher irs are chosen) @phire did mention we could potentially do this with a "dynamic offset", I need to talk to him more about how he would decide what offset-to-apply on which object. |
@JMC47 - tested this and says this fixes "Mario Kart Wii" menus at 3x+, "Sonic Heroes" and "Shadow the Hedgehog". |
Updated comparisons: Mario Kart Wii Example 1 Master 1x (directx) http://i.imgur.com/VVbHVYB.png Master 3x (directx) http://i.imgur.com/Lo5uQQQ.png This PR 3x (directx) http://i.imgur.com/50j1Jgu.png Example 2 Master 1x (directx) http://i.imgur.com/cl4QQNM.png Master 3x (directx) http://i.imgur.com/W3h5IOZ.png This PR 3x (directx) http://i.imgur.com/c03b6a4.png Silent Hill Shattered Memories Example 1 Master 1x (directx) http://i.imgur.com/VaMirGD.png Master 3x (directx) http://i.imgur.com/pbeZoTb.png This PR 3x (directx) http://i.imgur.com/C88pxAe.png Example 2 Master 1x (directx) http://i.imgur.com/RrRbRhs.png Master 3x (directx) http://i.imgur.com/O8CYhFY.png This PR 3x (directx) http://i.imgur.com/zrig3B8.png Spongebob Master 1x (directx) http://i.imgur.com/tMQDHwf.png Master 3x (directx) http://i.imgur.com/l0jQpnf.png This PR 3x (directx) http://i.imgur.com/Iylk4Jw.png No known major regressions |
de8e2d6
to
c667906
Compare
e28f1ec
to
bd94366
Compare
@degasus @Armada651 @stenzek are we okay with something like this? |
@@ -284,6 +284,9 @@ static wxString true_color_desc = | |||
wxTRANSLATE("Forces the game to render the RGB color channels in 24-bit, thereby increasing " | |||
"quality by reducing color banding.\nIt has no impact on performance and causes " | |||
"few graphical issues.\n\n\nIf unsure, leave this checked."); | |||
static wxString vertex_rounding_desc = | |||
wxTRANSLATE("Round vertices to whole pixels. Fixes some " |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -465,6 +465,29 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da | |||
// get rasterized correctly. | |||
out.Write("o.pos.xy = o.pos.xy - o.pos.w * " I_PIXELCENTERCORRECTION ".xy;\n"); | |||
|
|||
if (g_ActiveConfig.bVertexRounding) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
092f916
to
e3c6006
Compare
@@ -38,6 +38,7 @@ struct vertex_shader_uid_data | |||
u32 numColorChans : 2; | |||
u32 dualTexTrans_enabled : 1; | |||
u32 pixel_lighting : 1; | |||
u32 vertex_rounding : 1; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -465,6 +466,29 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da | |||
// get rasterized correctly. | |||
out.Write("o.pos.xy = o.pos.xy - o.pos.w * " I_PIXELCENTERCORRECTION ".xy;\n"); | |||
|
|||
if (uid_data->vertex_rounding && g_ActiveConfig.iEFBScale != SCALE_1X) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -28,6 +28,7 @@ VertexShaderUid GetVertexShaderUid() | |||
uid_data->numTexGens = xfmem.numTexGen.numTexGens; | |||
uid_data->components = VertexLoaderManager::g_current_components; | |||
uid_data->pixel_lighting = g_ActiveConfig.bEnablePixelLighting; | |||
uid_data->vertex_rounding = g_ActiveConfig.bVertexRounding; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Actually, can we change how the GUI for this works. It need to handle the following case:
Either we leave the UI alone and the checkbox is always clickable -- Or -- we gray it out whenever the IR is set to 1x (checkbox says checked or unchecked, whatever it previously was) |
df608a9
to
b92e20a
Compare
@@ -45,6 +46,7 @@ struct VertexShaderConstants | |||
float4 normalmatrices[32]; | |||
float4 posttransformmatrices[64]; | |||
float4 pixelcentercorrection; | |||
float2 viewport; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -8,6 +8,7 @@ | |||
|
|||
// all constant buffer attributes must be 16 bytes aligned, so this are the only allowed components: | |||
typedef float float4[4]; | |||
typedef float float2[2]; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -382,15 +382,24 @@ void VertexShaderManager::SetConstants() | |||
// 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 / g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd); | |||
const float pixel_size_y = 2.f / g_renderer->EFBToScaledXf(2.f * xfmem.viewport.ht); | |||
const float viewport_width = g_ActiveConfig.bVertexRounding ? |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
const float viewport_width = g_ActiveConfig.bVertexRounding ? | ||
(2.f * xfmem.viewport.wd) : | ||
g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd); | ||
const float viewport_height = g_ActiveConfig.bVertexRounding ? |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -284,6 +284,9 @@ static wxString true_color_desc = | |||
wxTRANSLATE("Forces the game to render the RGB color channels in 24-bit, thereby increasing " | |||
"quality by reducing color banding.\nIt has no impact on performance and causes " | |||
"few graphical issues.\n\n\nIf unsure, leave this checked."); | |||
static wxString vertex_rounding_desc = | |||
wxTRANSLATE("Round 2D vertices to whole pixels. Fixes some " | |||
"games at higher internal resolutions.\n\nIf unsure, leave this unchecked."); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
2fecc6f
to
20e6f24
Compare
All of @phire 's requested changes are in. Also went with phire's suggestion of "we gray it out whenever the IR is set to 1x" and keep the checkbox at whatever it was previously set to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All your fixes look good, but I managed to find a few extra issues.
out.Write("if (o.pos.w == 1.0f)\n"); | ||
out.Write("{\n"); | ||
|
||
out.Write("float ss_pixel_x = ((o.pos.x + 1.0f) * (" I_VIEWPORT_SIZE ".x * 0.5f));\n"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
else | ||
{ | ||
vertex_rounding_checkbox->Enable(true); | ||
vconfig.bVertexRounding = vertex_rounding_checkbox->GetValue(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
20e6f24
to
fa6c38a
Compare
w=1. This fixes some games at higher IRs.
fa6c38a
to
a9d08a3
Compare
Code looks good to me, but I haven't tested it. If everything is working as expected, it can be merged. |
LGTM. Performs pretty much as expected, turns off at 1x IR. |
Oddly enough, in Burnout 2, this fixes an issue in the main menu (notice the pixel-wide gap on the left where the background is showing through. It's not very noticeable in this image, but it is when in motion), but introduces another issue (the widths of the letters are off, take a look at the letters in "Acceleration.") |
@disorderIy - the change in UI is expected and is known to happen in most games. (All the games listed by the bot above were games that had UI changes by this hack) I didn't realize Burnout2 was one of the games that benefited from the hack, thanks for letting me know. |
Slightly annoying that the font gets worse while the line gets better, but that's kind of expected. (Looks like Burnout 2 is doing sub-pixel rendering of the font, which this hack destroys) |
This is the result of investigating why there's corruption in some games at higher IR (Spongebob, SilentHill) which often occurs during an efb copy. What I ended up finding out was that our pixel offset was not properly taking into account higher IRs correctly. At 6x IR for instance, we were often off by 3 pixels.
I believe this occurs because the Wii vertices often have higher precision than what the Wii resolution could show. In order to combat this, we scale the vertices to the native resolution before they get handed off to the pixel shader and outputted in the higher resolution.
Since this fix only helps a handful of games specifically at higher IR, we've decided to make this a toggle.