Page 1 of 1

Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 11:53 am
by FluffyFreak
Ok, one for maths people: Does anyone know how to go about projecting a plane/grid onto a sphere?

Lets say you're projecting it from the view frustum of the camera, so you've divide the screen up into a grid where each square is of a uniform size and you're looking at a planet.
My first though would be to just do some kind of ray projection onto a sphere, the maths for that isn't too bad.

However, now imagine the sphere is only partially visible, how do you handle the bits of the grid that are projected off into space?

I really have no idea how to handle this, I suspect that you wrap them around onto the side of the sphere that you cannot actually see, but I don't know how to go about doing this.

Any suggestions, ideas, existing code(!!!) is most welcome. Even if you just find something on Google and help summarise it so a five year old (i.e. me) could understand it :)

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 12:31 pm
by FluffyFreak
To help answer my own question: It seems that the problem I referred too is called the "backfiring problem" and is solved by separating the projection of the plane from the view frustum itself so that lines always intersect with the sphere. This distorts the grid somewhat but apparently the distaortions aren't too bad. Found a paper called "Projective Grid Mapping for Planetary Terrain" which look interesting and has some descriptions of the technique they used.

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 5:27 pm
by jpab
The video for that thesis looks really good. Is that what you're intending to implement?

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 5:59 pm
by FluffyFreak
No just doing research for things, typically anything I'm researching is something I'm thinking of for a few months time :) not sure exactly where I can go with this train of thought and wouldn't want to get peoples hopes up.

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 8:40 pm
by testadilegno
Dear all,
after a quick search I found this, maybe it's close to what you're looking for:

http://cadal.cse.nsysu.edu.tw/3D_Team/3 ... _paper.pdf
http://fileadmin.cs.lth.se/graphics/the ... /projgrid/
http://www.informatik.uni-rostock.de/~f ... g_2009.pdf
http://www.cs.bgu.ac.il/~grinshpo/Persi ... apping.pdf

[OT]
I haven't forgotten drag & lift but it's complex stuff...
[/OT]

Also, check this out:

http://frictionalgames.blogspot.it/2010 ... chive.html

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 9:07 pm
by FluffyFreak
jpab wrote:The video for that thesis looks really good. Is that what you're intending to implement?
I should expand upon my answer! No, because it would require use to pre-generate the terrain data or to be able to generate it on the fly - possibly in a shader.
A lot of that projects research is into efficient out-of-core storage for massive datasets. The terrain viewer is prefaced on the assumption that you already have all of the data and just need to determine which bits you will want to sample and then efficiently display them.

Our system at no point has the word "efficient" involved ;)

Re: Project a plane/grid onto a sphere

Posted: Tue Apr 08, 2014 9:10 pm
by FluffyFreak
Thanks testadilegno :)

Side fact: I applied for a job at FrictionalGames but they wanted a graphics coder and I was always more of a gameplay coder.