Download

polar distortion like in photoshop

Hi

I am playing around with procedural generating planets, and i run into the issue that i wanna distort my textures the way photoshop is doing it.
I do have the same effect as in photoshop when i do rectangle to polar, when i take that result and apply the math of polar to rectangle i get back my original image, so the math is working.
However in photoshop i can say polar to rectangle on the original image which is rectangular already, so far i am not able to find out how this is done, i cannot reproduce the same effect.
Here is an image that should explain what exactly i mean:
7764743756f4c481222de4ec0c1d35e4a6bed776.jpeg

Does anyone know what is going on behind the curtain and how the math looks like for that effect ?

cheers
eFieX

I’m a bit confused. You said above that you cannot reproduce the same effect, but your image comments say the conversion to polar and back works as expected.

Near the top of your image you say “Rectangular to Polar works” but looks like the input to that function was not the rectangular coordates you mention (which is actually Equirectangular or LongLat if I understand correctly) but standard UVs which you could think of as a 2D coordinate plane.

Conversion from 2D UV space to Equirectangular / LongLat can be done in UE4 with the material functions “UV to LongLat” and vice versa.

I wouldn’t really recommend using polar coordinates because the resolution distribution will be terrible. But there is a function “Vector to Radial Value” that can return radial coordinates, but I’d be surprised if it did the same thing as photoshop. Even in your example image, you can see that your ‘polar’ coordinates image doesn’t match the one on the left as there are a different number of radial rings. Maybe its limiting to the upper hemisphere? Maybe multiply G by 2 and see if it helps (just for testing as again I don’t recommend you encode that way).

A better option than any of these methods is Octahedron layouts. Much cheaper to convert between the space. There are material functions for that. You could import a regular cubemap and then use a render target pass to convert it to a single 2d octahedron. Then you’d have a texture thats cheaper than a regular cubemap to use because it wouldn’t have to map to 6 separate faces under the hood (and much cheaper than a longlat conversion since there is no trig involved). I am planning to do a detailed tutorial on this method for my blog soon, since octahedra have many uses.

Just for completeness sake, there is a free photoshop filter called Flexify2 that can do all kinds of space conversions for cubemaps.

Hi RyanB

Sorry it was a bit confusing explained by me, i meant that when i convert the image into polar and then back i get the original image, thats why i said the math has to be right.
But anyway i cannot explain but all after sudden it simply works, i didn’t change a thing i just opened up UE4 again because i wanted to check the UV to LongLat and it worked.
So the engine does produce the exact same image as photoshop when you use R as the angle and G as the radius it generates that image.
Because of the plugin, my idea is to not use cubemaps, instead distord the image with the uv’s in engine, since i wanna animate them with the panner i believe cubemaps won’t work.
You got me interested in the octahedron method but it sounds like i have to create a cubemap agian right ?
would it work with that method so i can animate the texture and don’t get distortions on the poles ?

How are you wanting to animate it? Just rotation? Can’t really ‘pan’ a cubemap. For rotation, you just do a rotate about axis on the input 3d vector.