-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
Normalize normal, tangent, and binormal before interpolating in the mobile renderer to avoid precision errors on heavily scaled meshes #99163
Conversation
6148b25
to
1a9263f
Compare
@clayjohn This fixes everything for us except 1 shader! :) So with that news we can celebrate! I have attached an mrp of our one shader that still has this issue: DesktopAndroidThis shader was created using Godot's shader graph. Here is the shader for quick reference: We are so close though! The fix is almost there and this is most definitely a HUGE improvement! :) |
And you may be wondering why we would create such a simple shader in the shader graph. That actually isn't the whole shader. That is just a stripped down version of the shader where this issue occurs. Aka, the mrp shader 😎. The real shader we use is animated so that the Blocky Ball logo moves across the arch in the background. But I figured an mrp shader would be easier to debug :) |
@TCROC Thank you for the MRP! Looks like we need to do the same fix for tangents and binormals (which are needed when using anisotropy). Just testing now, but I should be able to push a fix in a few minutes |
…ile renderer to avoid precision errors on heavily scaled meshes
1a9263f
to
2c158c3
Compare
@TCROC I just pushed a change that fixes this for your new MRP too! Should be good to go now |
Brilliant! I'll go try it out now! :) |
@clayjohn I can confirm that it works! Thank you so much for the quick fix on this issue! :) Just in case you weren't aware, I just want you to know that you are indeed the man! 😎 |
And the Godot community in general! You all never fail to impress me! :) |
Does it mean that after this PR is merged I should roll back the change in my fork's |
Yes, mediump will be slightly faster in some situations on mobile devices |
Thanks! |
Fixes: #89101
Fixes: #86275
Fixes: #86707
We interpolate normals using half precision in the Mobile renderer. As a result, very small normals can become corrupted. We can end up with very small normals when using a small scale in a MeshInstance's transform. In all three bug reports large meshes are used with a tiny scale (0.01 or smaller), the tiny scale transforms the normals to also be tiny, then the conversion to half float breaks them.
There are two options to solve that problem:
I chose the second option since a single normalize in the vertex shader will be relatively cheap and we need to minimize the amount of varying data that we use as it can easily be a bottleneck on Mobile devices.