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

Fix gaps and cracks issues #720

Merged
merged 3 commits into from
Jan 7, 2021
Merged

Fix gaps and cracks issues #720

merged 3 commits into from
Jan 7, 2021

Conversation

huwb
Copy link
Contributor

@huwb huwb commented Jan 7, 2021

Status: Ready to merge

Fix for two issues, both tracked by #665

Gaps: When ocean placed near a regular position (such as an integral boundary or multiple of 0.333333, etc), precision issues related either to how transforms propagate in the unity hierarchy or how the values arrive to the shader mean different tiles can snap to different locations and leave a gap. This adds a slight nudge to push the ocean away from a bunch of common boundaries). The nudge is very small and will not affect the ocean simulation/rendering as everything snaps to much larger values than the nudge. In the future, if gaps appear, it may be the boundary is not on 1/60. The boundary might be lod resolution / lod 0 width. If we get a report of gaps, we should get the camera transform and oceanrenderer settings, and see if we can compute the boundary.

Thin cracks: The scale of each tile is increased by a small epsilon. This should be subpixel, but should be large enough to overcome precision issues. If cracks appear in the future, this value could be increased. It might be that this value is too small when far from the origin, we could potentially scale the epsilon by dist from origin to help combat this if needed.

@daleeidd could you let me know what you think and please give this a run on mac if you could. Thanks!

@huwb huwb requested a review from daleeidd January 7, 2021 21:50
Copy link
Collaborator

@daleeidd daleeidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works really well from the test cases. I found for the scaling fix a value as low as 1.0000001 worked for the test case.

@@ -809,6 +809,18 @@ void LateUpdatePosition()
// maintain y coordinate - sea level
pos.y = Root.position.y;

// Don't land very close to regular positions where things are likely to snap to, because different tiles might
// land on either side of a snap boundary due to numerical error and snap to the wrong positions. Nudge away from
// common by using increments of 1/60 which have lots of factors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add :OceanGridPrecisionErrors to keep track?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

@daleeidd daleeidd added the Bug label Jan 7, 2021
@daleeidd daleeidd added this to the Crest 4.8 milestone Jan 7, 2021
@huwb
Copy link
Contributor Author

huwb commented Jan 7, 2021

Great news, thanks!

I updated the descr above about what we might try if we get reports of gaps or cracks in the future.

Merging!

@huwb huwb merged commit ce3a084 into master Jan 7, 2021
@huwb huwb deleted the fix/gaps-and-cracks branch January 7, 2021 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants