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

demo: Improve boundsError to take camera parameters into account #786

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

zeux
Copy link
Owner

@zeux zeux commented Oct 7, 2024

While boundsError is an approximation and the precise version would compute the projected sphere bounds taking into account perspective distortion and near plane clipping, our simpler variant can work as well and is invariant to camera rotation which is a nice property in certain cases; for example in VR you might want to compute LOD based on a "third" eye, a center camera, so that the geometry is in sync between two eyes.

Our boundsError implementation was mostly serviceable but did not depend on camera field of view and had some potential issues with monotonicity for cases where the camera position was inside the sphere.

We now clip the distance to znear and properly scale it so that the result is a normalized screen space error (0..1, multiply by screen height to get pixels). This ensures that if the bounds.error is 0, boundsError will return 0 even if the camera is inside, which should ensure proper cluster selection for extreme closeups.

This contribution is sponsored by Valve.

While boundsError is an approximation and the precise version would
compute the projected sphere bounds taking into account perspective
distortion and near plane clipping, our simpler variant can work as well
and is invariant to camera rotation which is a nice property in certain
cases; for example in VR you might want to compute LOD based on a
"third" eye, a center camera, so that the geometry is in sync between
two eyes.

Our boundsError implementation was mostly serviceable but did not depend
on camera field of view and had some potential issues with monotonicity
for cases where the camera position was inside the sphere.

We now clip the distance to znear and properly scale it so that the
result is a normalized screen space error (0..1, multiply by screen
height to get pixels). This ensures that if the bounds.error is 0,
boundsError will return 0 even if the camera is inside, which should
ensure proper cluster selection for extreme closeups.
@zeux
Copy link
Owner Author

zeux commented Oct 7, 2024

Also adding preliminary normal support; this is with a fairly low normal weight and ~2px error bound so shading issues remain. Note that the LOD selection here is only performed every ~10% of the video, because this was rendered in Blender by manually keyframing camera motion and cuts visibility 😅

edit oh, Blender's camera field of view is also substantially smaller than the 60 degree vertical FOV I've computed the cuts for; so that makes the pops more pronounced, as the object would have been smaller on screen with the right settings. Let's say this video is correct within a constant scaling factor of the thresholding...

0001-0110.webm

We previously output the normal values but not normal indices; when
imported, editors tend to ignore the normal data as a result.
For now we use a fairly low weight (0.5); 1.0 is generally more
appropriate for full mesh simplification at least but we'll start
conservative for now.
@zeux zeux merged commit 1e48e96 into master Oct 9, 2024
12 checks passed
@zeux zeux deleted the nanite-errpx branch October 9, 2024 15:58
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

Successfully merging this pull request may close these issues.

1 participant