Skip to content
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

Precision problems on the GPU side #1

Open
Spiri0 opened this issue Nov 24, 2024 · 1 comment
Open

Precision problems on the GPU side #1

Spiri0 opened this issue Nov 24, 2024 · 1 comment

Comments

@Spiri0
Copy link

Spiri0 commented Nov 24, 2024

The Nanite version, which carries out the visibility check on the CPU side, works very precisely. The trident webgpu version with the visibility check in the gpu leads to meshlet overlaps. I don't see any difference between the functions on the CPU side in Nanite and those in the cull shader in Trident. But what is very different is the fact that the GPU is worlds more powerful, but with the 32 bit limitation it is also significantly more vulnerable when it comes to accuracy.
This has presented me with challenges several times in my apps. @AIFanatic what do you think? Does a factor of 10e-10f really make sense in the GPU?

fn isMeshletVisible(meshlet: MeshletInfo, modelview: mat4x4<f32>) -> bool {
    var projectedBounds = vec4(meshlet.boundingSphere.xyz, max(meshlet.error.x, 10e-10f));
    projectedBounds = transformSphere(projectedBounds, modelview);

    var parentProjectedBounds = vec4(meshlet.parentBoundingSphere.xyz, max(meshlet.parentError.x, 10e-10f));
    parentProjectedBounds = transformSphere(parentProjectedBounds, modelview);

    let clusterError = projectErrorToScreen(projectedBounds);
    let parentError = projectErrorToScreen(parentProjectedBounds);
    return clusterError <= settings.dynamicLODErrorThreshold && parentError > settings.dynamicLODErrorThreshold;
}

This will probably not be the only place where precision will play a role.

@AIFanatic
Copy link
Owner

I’m not sure if that’s what’s causing overlaps. I need to check the errors of the meshlets to see if they are within the limits of 32 bits. A whole bunch of tests need to be done to ensure they work flawlessly. Although the priority would be on the meshlet generation itself. Currently the problem is the same nanite-webgpu has, which is the simplifier getting stuck. In the latest update I have used meshoptimizer simplifyWithAttributes and only lock the borders of the meshlets wrt to its group but I’m not sure if this is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants