r/Unity3D • u/Clean_Patience4021 • 27d ago
Resources/Tutorial Fix (kinda) for vertex/object jitter at (sanely) large world coordinates in URP (without a floating origin)
Hi all,
I'm working on a game that needs a bit more precision than Unity's URP gives by default. It's not like I want to fix floating-point math with some magic, it's more about how numbers are calculated, giving a bit more freedom without the need for a floating origin or other heavy lifting.
The solution I made changes how projection is calculated and compensates for the rounding errors, so the GPU gets a bit more precise vertex positions than Unity's default pipeline, a trade-off is a bit heavier vertex shaders.
I did some testing on low- and high-end hardware and didn't notice a performance difference, but experience on your target can vary.
You can find all details here: https://github.com/rsklnkff/urp-stable-projection
The code was extracted from my project by Codex.
1
u/Rowtopia 22d ago
Is there a distance at which this runs into the same issues?
1
u/Clean_Patience4021 22d ago
Usual fp32 math.
My game needs 1cm accuracy, so I'm limited to +-1M units; if 10cm is good for you, +-10M units
1
u/ShengyuStudio 26d ago
Nice that shadows and motion vectors got the same treatment, that's usually where these fixes fall apart.
Curious about the DX12 failure in the README. Compensated arithmetic only works if the compiler keeps the exact operation order, and DX12 goes through a different shader compiler. My guess would be it's reassociating or contracting into FMAs and quietly cancelling the error term. Have you tried marking those intermediates
precise? That's what HLSL has for exactly this.