Outerra forum
Outerra Engine => Technology => Topic started 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?

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/mappingcubetosphere.html (http://mathproofs.blogspot.com/2005/07/mappingcubetosphere.html)
Our version additionally tries to correct the uneven subdivision length along the cube face.

thanks, very generous of you.

is your planetary model a sphere or an oblate spheroid?

A sphere, not doing the adjustment to spheroid yet.

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 cubetosphere 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....

I'm generating all terrain meshes in shaders, but the algorithms change depending on the quadtree 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.

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.