Outerra forum

Outerra Engine => Technology => Topic started by: knackered on September 21, 2011, 03:49:50 pm

Title: projection
Post by: knackered on September 21, 2011, 03:49:50 pm
could you describe your algorithm for converting from a cylindrical projection to your quadrilateralized spherical cube please?
Title: Re: projection
Post by: cameni on September 21, 2011, 04:48:06 pm
The javascript code (http://www.outerra.com/navmap/js/cubeface.js) used in the Map for testing tile allocation (http://www.outerra.com/forum/index.php?topic=395.0) contains the routines used for the conversion.

Here's the description of math for a basic version http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html (http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html)
Our version additionally tries to correct the uneven subdivision length along the cube face.
Title: Re: projection
Post by: knackered on September 21, 2011, 07:47:17 pm
thanks, very generous of you.
Title: Re: projection
Post by: knackered on October 12, 2011, 05:59:02 am
is your planetary model a sphere or an oblate spheroid?
Title: Re: projection
Post by: cameni on October 12, 2011, 06:01:44 am
A sphere, not doing the adjustment to spheroid yet.
Title: Re: projection
Post by: knackered on October 12, 2011, 12:28:29 pm
thanks.
One more thing - do you convert from cube to sphere in the vertex shader? or do you generate patch vertices with this transformation already applied?
i'm having a hard time working out how to localise the patches while also applying this cube-to-sphere projection....i need to be working at the earths radius to get the correct deformation, but then i can't do double precision in the vertex shader....
Title: Re: projection
Post by: cameni on October 12, 2011, 02:35:04 pm
I'm generating all terrain meshes in shaders, but the algorithms change depending on the quad-tree depth, which is related to required precision. Up until a given level it generates the coordinates normally in a global coordinate system using floats, as the precision is satisfactory. From that level on it uses a local coordinate system, interpolating the vertices between tile corners linearly or with a curvature correction, but the curvature error is like 0.02m on 2km so it can be also neglected.

You may also want to check the 3D Engine Design for Virtual Globes (http://www.virtualglobebook.com/) book for other approaches.
Title: Re: projection
Post by: knackered on October 13, 2011, 12:49:14 pm
oh i had an 'orrible feeling you were going to say that. Thought I'd missed something elegant.

i've read that book and it's terrible. There's absolutely nothing in it that's not already thoroughly covered in many articles and papers linked to from vterrain.org. I bought it online and consider it an expensive mistake.