-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Ellipsoid precision #1067
Conversation
// 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
Update CHANGES.md since this was a known issue. |
@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 We aren't already doing the PERFORMANCE_TODO. It says the number of intersection tests can be reduced from 2 to 1. |
Any thoughts on using the bounding box as I suggested to help for really oblate ellipsoids? |
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. |
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? |
If you are sure about this, then we can merge this and still leave #889 open I suppose. |
Conflicts: CHANGES.md
@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. |
Ah, I see. Merging. |
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?