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
Fixed depth matrix shaders in OpenGL and Direct3D to be more precise. #823
Conversation
|
Don't use tabs for indenting the comments. The coding style says to use spaces for vertical alignment. |
|
You're also doing implicit integer to float conversions in those shaders which will fail on GL ES targets. |
|
Can you squash these changes back into the original commit? |
|
Sorry I'm not familiar with git yet, seems that what I did instead is created a new commit with the changes combined. :/ |
|
@KScorp Alright do the following Then put 's' in the place of 'edit' for all of the commits except the original. |
|
What do you think of the version which galop1n came up with? |
|
@dolphin-emu-bot rebuild |
|
Sorry, I seem to be incompetent when it comes to interfacing with Git... |
… Fixes some graphical glitches in some games.
|
Ok, finally did it! One commit, with the corrections needed so far. I'll look over galop1n's changes tomorrow. |
|
This appears to fix the remaining issues where Mii faces are broken. Good job! Edit: Okay, I have to take that back. Good job just isn't right for this. This fixes a whole BUNCH of weird issues that have plagued the emulator. Luigi's Mansion Black Lines! And likely other things that were only working in D3D9. So, excellent job Edit2: Found more! Mario Golf Shadow clipping bugs! |
|
@dolphin-emu-bot rebuild |
|
Oh, I see how the old code is broken... Nice fix, so LGTM with round(). Out of scope, but I think we should get rid of this colmat variable and just compile a different shader per color format :/ |
|
nvm, I'm wrong with the round() vs floor(). LGTM |
|
If your fixes work better, then so be it. I think the point was to get a look at another implementation that "fixed" the issues. If your version produces better results (which seems to be apparent) I'd prefer your version regardless of tiny speedups. |
|
Actually it was just trying to find if that fix was in that branch or not :P ...guess not. (Sorry if this appears twice, github apparently ignores mails from my phone) |
|
FYI: Original D3D-MSAA shader compiles into 22 instructions. Again, unsure if this means there will be any performance reduction or not as a result of this change. (I'm not suggesting to continue using the broken code, this is just a heads up.) |
|
Well, I tested a bunch more games, I don't really see any regressions. LGTM. |
Fixed depth matrix shaders in OpenGL and Direct3D to be more precise.
|
What about Mario Tennis, Does this fix any of those issues? |
|
That's zfreeze, different issue. |
|
In OpenGL the effect is not as effective as it is in D3D, there is still shadow lines in Luigi's mansion under OpenGL, but not as much as there used to be, in D3D it is entirely gone. |
|
That's correct though, there were some there on console. It depends on video card, apparently. |
|
There are still some inaccuracies that can be fixed. I only fixed a minor coding issue which improved things quite a bit, but the implementation itself is probably flawed. Encoding three 8 bit integers into a float is a (potentially) awful and inaccurate implementation. I'm still familiarizing myself with the code. I will likely try to redesign these shaders if possible. galop1n's code probably changed both the decoding and encoding, which is why when I tested it it failed miserably. |

The depth matrix shaders were experiencing loss of precision because the most significant bits were not being subtracted out when shifting the least significant bits left. This change separates the calculations into several statements in order to subtract out the bits that have already been decoded before shifting left, minimizing precision loss. This fixes some graphical glitches when using Copy EFB to Texture. (EDIT: It seems to fix some issues that appear on both copy to tex and copy to RAM as well.)
Code inspired by the old ARBfp1.0 shader that existed before GLSL-master was merged.
One obvious graphic glitch example (from Skyward Sword):


OpenGL without fix, Copy EFB to Texture:
OpenGL with fix, Copy EFB to Texture:
Similar results with D3D.