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

Ellipsoid precision #1067

Merged
merged 6 commits into from
Aug 28, 2013
Merged

Ellipsoid precision #1067

merged 6 commits into from
Aug 28, 2013

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Aug 22, 2013

Find the intersection of the ray from the eye to a sphere with the ellipsoid's maximum radius. If it intersects, march the ray forward and find the intersection with the ellipsoid. This should fix some ellipsoids like in #899.

The artifacts will still occur for ellipsoids where the ratio of the maximum radius to the minimum radius is greater than 100. Marching rays the rays closer to the ellipsoid doesn't help.

You can test this in the Volume Sandcastle example by dividing an ellipsoid's smallest radius by 100.0. In master, you'll see the artifacts. If you divide by a higher value, say 1000.0, there are still artifacts.

http://cesium.agi.com/Cesium/Apps/Sandcastle/index.html?src=Volumes.html

@emackey Can you verify this fixes #899?

// may cause false negatives. This will discard fragments before marching the ray forward.
float maxRadius = max(u_radii.x, max(u_radii.y, u_radii.z));
vec3 radii = vec3(maxRadius * 1.5);
czm_ellipsoid ellipsoid = czm_ellipsoidNew(czm_modelView[3].xyz, radii);
vec3 direction = normalize(v_positionEC);
czm_ray ray = czm_ray(vec3(0.0), direction);
czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use a faster ray-sphere test here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, would a box be better for the very oblate case?

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 23, 2013

Update CHANGES.md since this was a known issue.

@bagnell
Copy link
Contributor Author

bagnell commented Aug 23, 2013

@pjcozzi This is ready for another review.

I didn't add a new function for ray-sphere intersections because the one in the ellipsoid fragment shader is optimized for rays whose origin is vec3(0.0) and the ray direction is unit length.

We aren't already doing the PERFORMANCE_TODO. It says the number of intersection tests can be reduced from 2 to 1.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 26, 2013

Any thoughts on using the bounding box as I suggested to help for really oblate ellipsoids?

@bagnell
Copy link
Contributor Author

bagnell commented Aug 27, 2013

I think using the ray-sphere intersection would be quicker than testing for the intersection points with 6 planes. Am I missing something about why using a bounding box would be better?

EDIT: I know the bounding box would be a tighter fit for really oblate ellipsoids, but moving the ray even closer doesn't seem to help much in that case.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 27, 2013

Am I missing something about why using a bounding box would be better?

I'm not concerned about performance; this fix is incremental, and we'll take it, but it still doesn't solve the root problem. Can we solve the root problem by stepping to the bounding box, instead of the sphere since, (for many view directions) the bounding box surface is much closer to an oblate ellipsoid than the ellipsoid's bounding sphere?

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 27, 2013

EDIT: I know the bounding box would be a tighter fit for really oblate ellipsoids, but moving the ray even closer doesn't seem to help much in that case.

If you are sure about this, then we can merge this and still leave #889 open I suppose.

@bagnell
Copy link
Contributor Author

bagnell commented Aug 27, 2013

@pjcozzi I marched the ray forward a few times and it didn't help. I checked testing the bounding box but I think it may have the same problems as getting the intersection points for the oblate ellipsoid.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 28, 2013

Ah, I see. Merging.

pjcozzi added a commit that referenced this pull request Aug 28, 2013
@pjcozzi pjcozzi merged commit 521e3fd into master Aug 28, 2013
@pjcozzi pjcozzi deleted the ellipsoidPrecision branch August 28, 2013 11:16
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.

Ellipsoid grid lines don't work well on flat ellipsoids
2 participants