## Mollweide Projection Map Accurately Onto a Sphere? document.SUBSCRIPTION_OPTIONS = { "thing": "thread", "subscribed": false, "url": "subscribe", "icon": { "css": "fa fa-envelope-o" } };

OniOid
2013-11-02
2014-03-14
1 2 > >> (Page 1 of 2)
• OniOid - 2013-11-02

Is this possible in AoI? If not, might it be scriptable?

Also, if I already have a spherical graphic-- an image taken of a 3D spherical map-- how would I map this to a sphere without it being subjected to a second spherization?

• Peter Eastman - 2013-11-03

The obvious approach would be a procedural texture. Wikipedia gives a closed form for the inverse transform: http://en.wikipedia.org/wiki/Mollweide_projection. The difficulty is that it involves an arcsin, which isn't a built in function for procedures. But you could probably approximate it with a simple polynomial, since it's a pretty well behaved function.

Another approach would be to convert your sphere to a mesh, then write a script to set texture coordinates correctly. That should also be pretty easy.

how would I map this to a sphere without it being subjected to a second spherization?

That depends how the map was created. Do you know what mapping it's based on?

• Pete - 2013-11-04

The difficulty is that it involves an arcsin, which isn't a built in function for procedures

But there is the "angle" function in AoI.math, which is in practice one form of arcustangent? If you have something that represents the sine, then shouldn't the Pythagoras equation give you the cosine as well? And with those you can produce the tangent ... or rather just feed the sine and cosine to the angle fuction, to get the angle?

I did not work the equations through. Just a thought. :)

• Peter Eastman - 2013-11-06

If you're writing a script there's no problem. Math.asin() is exactly what you want. I meant that there's no asin module to include in procedures, so trying to define the transformation purely through a procedural texture would be harder.

Peter

• Peter Eastman - 2013-11-06

And by the way - I should probably add one!

Peter

• Pete - 2013-11-07

That's right, I was thinking of turning that ellipse-map into a spherical procedural texture -- But then I came to think, that an easier way would probably be to stretch the ellipse into a rectangle by the procedural engine and then use spherical mapping on it.

Not that I'd be trying that any day soon -- it seems, that my PC thought that 8 or 9 years of service is enough....

And by the way - I should probably add one!

I second that :)

• Luke S - 2013-11-07

a spherical graphic-- an image taken of a 3D spherical map--
how would I map this to a sphere without it being subjected to a second spherization?

That depends how the map was created. Do you know what mapping it's based on?

When I first read this, I took it to mean a rendered image of a sphere with a 3d texture mapped to its surface... think of the famous "earthrise" photos. In which case, you would simply use basic projection mapping.

Last edit: Luke S 2013-11-07
• OniOid - 2013-11-09

Hi guys,
Thanks for your responses...
For your information, it is hypothetical Pangaea (in Mollweide projection) as it was roughly just before the Permian-Triassic extinction event

I've been unable to secure the high-res rectangular version of Pangaea, which, presumably, AoI can image-map to a sphere correctly/best:
But the Mollweide that I have seems a better resolution than the lower-resolution rectangular one, which is why I thought to inquire about it.
Here are the two globe images I was also talking about:

If I could map them to a sphere together somehow accurately, I could then spin the sphere and get the view I want. What do you think?
I am not mathematically adept enough or have nearly enough time to write any kind of script, but in any case, I will try to get what I want with what I have. Maybe I should speak with Nate. Is Nate still around? How is the rest of the gang?

For additional information, it is part of the story behind the formative Permaea, which everyone is invited to participate in. Part of the idea is that, what with potential runaway climate change, Fukushima, coercive crony-capitalist oligarchies, and an apparent sixth mass extinction event underway, and so forth, we may be entering yet another Great Dying if we don't get our acts together real soon.

Last edit: OniOid 2013-11-23
• Luke S - 2013-11-09

Those globe images are exactly what I had in mind... You just set up a pair of image-mapped textures, and then use projection mapping. Move the projection around until they line up. (Easier said than done - there seems to be some room for an improved tool or plugin here. ;)

I only see one problem with this... the two globe shots are not directly opposite. The islands just south of the equator, on the far right of the first shot, are sitting just left of center in the second shot. I'd say that those two shots overlap by about 60-70 degrees. That leaves a wedge of about 50-60 degrees of the globe un-mapped on the far side. If you are hoping to show the entire world spinning, you'll need to find a way to cover that last wedge.

The approach that Peter and Pete have been discussing would probably yield better results if these are the only two images you have to work with, but will require either a script, or an arcsine module for the procedural system...

I did a little looking about in regard to map projections, and if you want one that just maps, look for these projections:

• Equirectangular projection should map directly with "Spherical" mapping.
• Lambert projection (AKA Lambert Cylindrical) should map with "Cylindrical" mapping.

• OniOid - 2013-11-10

Hi Luke,
Since the two globe shots are already images on a sphere, if projection mapping will not add an extra spherical iteration, then that should work. All I'd have to do is spin it a little.
What I'm trying to do, in part, is to simply get less of the ocean on the left and more of the islands to the right, so any missing wedge in back is immaterial.
As for any rectangular projections to map around a sphere; yes, that is what I've been looking for-- in high-res.
What I also want to do is to gather a very good outline of the land/island areas for a black and white design. I do quite like the Lambert Azimuthal Equal Area Projection of Pangaea, but have so far been unable to track down a hi-res version of it as well. (As an aside, I wonder how you could map something like that to AoI.) A transparent (ocean areas) globe of Pangaea (of at least 255 million years ago) would also be nice.

Last edit: OniOid 2013-11-10
• Luke S - 2013-11-10

The L-A Equal area looks like it should map fairly easily, but I must be doing something wrong with the math - I've tried a couple of different approaches.

Once you track down a map that you can map to a sphere easily, you can use image editing software to create other maps, such as transparencies, and then use them with the same mapping settings.

A problem that you are going to run into with those projections is that they are rendered with light and shadows on them. You will probably have a hard time getting them to blend together...

I've done a little searching myself, and maps that fit this description are indeed hard to come by. In fact, the only ones I have actually seen are the sample versions from the source you found. Depending on the purpose of your project, paying for the DVD version might be worth it. (I found it a bit steep, but I'm just looking at this as an interesting personal project. Given the quality of the product, I'm not even tempted to complain of price-gouging here.)

• OniOid - 2013-11-10

The shadows are not a problem, since the rotation involved is outside of them and also since I will be doing outlines and then black and white fills. So I think I will go for the two sphere images. How far back on the sphere do I lay/project the images for 100% accuracy? Halfway?

• Luke S - 2013-11-10

What I would do:

• Use an image-editor to cut that image into two pieces. (Do your outline/fill stuff at this time)
• Trim them so that the circles touch the edges
• Create an image mapped texture for each of them
• Create a layered texture on your sphere, with each of the images as a single layer
• Adjust the mapping of the first image. (In the 'set textures and materials' box.) Set 'scale texture to object', 'projection mapping'. No other adjustments should be needed.
• Set 'object fraction' of second image to about 0.5 (allows you to see what you are doing)
• Adjust the mapping of the second image. Same settings. NOW: adjust the rotation until the images line up. (about 90 degrees on the Y axis should be a good start)

You shouldn't need to adjust any of the position/scale stuff.

Due to limited resolution of the source images, or mistakes in creating your outlines, you may not be able to get the two shots to line up perfectly...

When you are satisfied, set the object fraction of image 2 to 1.0.

Render in AOI.

• Pete - 2013-11-10

Hi!

I started to look at this too and it really looks, that the Pangea people are fond of Mollweide :)

A couple of notes.
- On Windows systems, give the javaw-process the lowest possible priority before you launch it. Otherwise it may hijack your CPU until it's done.
- As a script this naturally is very slow.
- It does the work in a thread, so it can report of it's progress along the way.
- It assumes, that there are no "frame pixels" around the actual map. The Mollweide imgae should just touch the edges of the image.
- Just write your own workingdirectory- and file names there in the bginning of the script to get started... :)

Currently the script produces stripes and sawtooth pattenrs, because it is not blending between pixels, when reading the Mollweide. It just picks the closest pixel and I have some doubts about my convcersion from coordinates to pixels too :D. Also something funny may happen at the very poles, when rewrapping the rectangle onto a sphere. However, the proportions of the produced rectangle looked right to me.

As it turned out, the way of working here is to look through the rectangular map and use the forward conversion to find the correct spot of the Mollweide for each pixel of the rectangular. Also it turned out that the y-size, that the original equations produce is entirely arbitrary (y from -2,21... to +2.21...) So it needed to be scaled to fit [-1.0, +1.0] to make any sense of it.

Assuming, that my PC will start tomorrow, I could have a look at the blending issue... Should not be too hard now.

CU

• Luke S - 2013-11-11

I've tried it, and things seem to come out nice and straight. It even maps to a sphere well, which is kind of the whole point of the exercise.

I wouldn't worry about the blending issue. What you are seeing is an artifact of the projection. If you start interpolating between pixels, you will be adding a layer of smoothing, even though you don't really want it. Some parts of the image seem to fan out because as you go toward the poles, you are copying data from the same source pixels more than once. When you map a rectangle onto a sphere, you have the opposite thing happen. As you move toward the poles, the image mapper pulls in data from more and more pixels... those wavy lines render fairly straight!

Re: Performance.
In multi-core systems, (Sort of the norm these days) CPU hijacking shouldn't be much of a problem, since there is only one work thread. I'd wonder if this script is a good candidate for being re-written in Groovy, to take advantage of the bytecode-compiled speed boost?

Last edit: Luke S 2013-11-11
• Pete - 2013-11-11

If you start interpolating between pixels, you will be adding a layer of smoothing, even though you don't really want it.

Not really, I think. The original maps should already be anti aliased or slightly smoothed, so there would not really be an extra smoothing in there. But of course it could be made optional...

The idea would just be to calculate a weighted average of the four pixels, that are closest to the point where the "ray" hits to avoid very visible artifacts. (They'd probably not be entirely gone. To do that you'd need something much more complex.) And in this particular case the four pixels might not even make a square 8|. Which produces the sawtooth patterns to meridians if those are present.

Of course the patters would be smoothed towards poles, but that'd be what I'd look for. As said, the spherical mapping reverses the effect. :)

Last edit: Pete 2013-11-11
• chris w - 2013-11-12

Another aproach could be to create a geoid sphere and unfold the
uv map using wings3d. Ajust the uv chart so the sphere is split into
2 equal hemispheres thru the poles then create the texture showing
all edges. With an image editor your disc images can then be cut and pasted
over the uv map.

• OniOid - 2013-11-14

Hi guys,
Thanks, and kiitos to Pete. I will try it out when I get the time and report back.
Hei hei 4 now.

Last edit: OniOid 2013-11-15
• Pete - 2013-11-16

Eipä kestä. :)

I worked it a bit further. New version behind the same link.

This one can do a simple interpolation between four pixels (if you like it to). It gets rid of the saw tooth patterns. Also without the interpolation it would read the same rows of pixels a couple of times over by the poles and skip maybe 1 out of 3 rows by the equator. Now the transitions are smoother and the result looks pretty much what I was hopinng for.

Unfortunately there is some kind of a thinking error somewere. It looks as if the interpolating part was reading the input image about half a pixel off in y-direction. Any quick attempts to correct this was leading into other problems, so I probabbly should do my homework on that part again. The good thing is, that it seems to get disturbing only on relatively small images.

I also changed the calculations into floats where possible, to speed it up but the effect on processing time was only about 10%.

And I began to think, that a way to exclude pixels on top, bottom, left and right edges of the original is necessary. Unused pixels in the input image create a crack in the rewrapped output... :| ...But let's see about that. :)

Have fun !

Edit #1: I found the bug. Strangely the interpolation was working better with the bug than now. I don't quite understand why, but I have an idea how to improve it. Also added the possibility to exclude pixeld at the edges.

Edit #2: OK - Finally it works the way I was expecting it to. -- I had gotten confused with how to calculate the weights for the interpolation... :/ Now The interpolation is just about as good as it can get by interpolating over a square of pixels. Also, it is now a little bit faster than before, as I separated the two ways of generating the image into their own methods, instead of putting "ifs and whens an maybes" into the procedure itself.

I was also looking at a bit of a smarter way of doing the interpolation, using a rhomboid (a slanted rectangle) of four pixels instead of a square. That one does work better, but I have some strange issues at the poles again ... on the first and last rows it chooses to select the (0,0) pixel to repsesent half of the rhomboid :P

• CU!

Last edit: Pete 2013-11-21
• Pete - 2013-11-22

Hi!

Finally got the interpolating working the way I was originally picturing it to happen. Now the rhomboid approach it is again slower than the square of pixels, but I believe it is worth it. The increased processing time is because there are now two sets of x-coordinates and weights to be calculated)

Here is the folder where you can find it. In case you wish to check the old ones, look into the History folder (The square based interpolation is working correctly in the 0.5-version.)

• OniOid - 2013-11-23

Hi Pete! ^u^
(Hey, Happoradio's back in studio! ;)

It has been awhile since using AoI but I may delve back into it next week, along with your script and let you know.

For Peter E.: if you are reading this; for what it's worth, I tried the most recent AoI with my old lightbulb-- remember that?-- and it threw an exception with an attempt at a Monte Carlo render. If we are still reporting bugs in the usual place, you may expect one.

Thanks guys. Until next time.

Last edit: OniOid 2013-11-23
• Peter Eastman - 2013-11-24

If we are still reporting bugs in the usual place, you may expect one.

That would be great. I'll take a look and see what's going on.

Peter

• OniOid - 2013-12-20

Pete, the below is not understood:

String WorkDir = "C:\Documents and Settings\Ihalainen\Työpöytä\"; // NOTE THE DOUBLE BACK-SLASHES!!

Why the double back-slashes and where do I put the Mollweide.jpg file? In Työpöytä? I tried creating the Documents and Settings folder (Win 7) but it said that it already was there even though it couldn't be seen:
Script output:

I changed, in the script-code, the directory for the Mollweide-projection.jpg file:

String WorkDir = "C:\Users\User\Programs\ArtOfIllusion\Textures and Materials\Library\"; // NOTE THE DOUBLE BACK-SLASHES!!

(Curiously, SourceForge is dropping one of the double slashes, despite my use of the pre and code html tags)
I then got this output:

The file should be found because it is in there, spelled correctly.

Last edit: OniOid 2013-12-20
• Pete - 2013-12-22

Hi.

The "\" is, what you call an escape character in Strings of Java. That means, that it is used to express chracters that are otherwise hard to write into the code. For example "\t" means tab, "\n" means a line change ... and there are guite a few more of those. So to express "\" you need to write it twice.

Of course the back-slash is the directory separator only in Windows. On other systems they usually use the "normal" slash, and also in Windows it works just as well if you use "normal" (single) slashes. I did not think of this when I wrote the script -- sorry for that-- but it just tested it and it works. ...and the "Työpöytä" is of course Finnish for "Desktop".

So on my new, just acquired PC (the old one is about 8 yrs and just barely working), that would then be "C:/Users/Petri/Desktop/".

And how I found that: Just opened the file-explorer. Started browsing from the hard-disk and when I had the desktop-folder open, I copied the information from the address-box... and changed the slashes.

You can put the file anywhere you like. If the WorkDir and MollweideName strings are written correctly, then it should work. To make it sure you could just use the root of the hard disk... e.g "C:/".

And yes: SF seems to have some flaws in consistency, when it comes to text formatting. :D

I hope you can get it Work...

• OniOid - 2013-12-23

Hi Pete,
So then how do I get it working? Get rid of the double back-slashes? I am still getting an error. If I can put the file anywhere, I presume this still has to be reflected in the line-of-code-in-question?
I got rid of the double slashes and have the file in the location as specified above; in the Library folder of the Texture and Materials folder.

Here it is:

String WorkDir = "C:\Users\User\Programs\ArtOfIllusion\Textures and Materials\Library\"; // NOTE THE DOUBLE BACK-SLASHES!! String MollweideName = "Mollweide-projection.jpg"; String RectangleName = "Rectangle-projection"; // No file-extension here! The script will add it. String SavingFormat = "png"; // png, jpg, gif or bmp should work

Script Output:

artofillusion.script.ScriptException: Sourced file: inline evaluation of: ``return new ObjectScript() {void execute(ScriptedObjectController script) { //*** . . . '' Token Parsing Error: Lexical error at line 18, column 23. Encountered: "U" (85), after : "\"C:\\" at artofillusion.script.BeanshellScriptEngine.createObjectScript(BeanshellScriptEngine.java:91) at artofillusion.script.ScriptRunner.parseObjectScript(ScriptRunner.java:92) at artofillusion.script.ScriptedObject.getObjectScript(ScriptedObject.java:86) at artofillusion.script.ScriptedObjectController\$1.run(ScriptedObjectController.java:48) Caused by: Sourced file: inline evaluation of: ``return new ObjectScript() {void execute(ScriptedObjectController script) { //*** . . . '' Token Parsing Error: Lexical error at line 18, column 23. Encountered: "U" (85), after : "\"C:\\": <at unknown="" location=""> at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at artofillusion.script.BeanshellScriptEngine.createObjectScript(BeanshellScriptEngine.java:87) ... 3 more

Last edit: OniOid 2013-12-23
1 2 > >> (Page 1 of 2)