Distort from central cylindrical projection to equirectangular

Hi,
I need to distort a central cylindrical projection image texture (covering any vertical angle range) to an equirectangular projection in order to map it properly onto a sphere (all directly with material nodes).

As you can see in the file I provide, I could map the texture onto a cylinder (the rotated empty object serves of visual proof by intersecting with the upper bound of the texture).

Then I tried something to distort it to become equirectangular but I guess I got things mixed up. Been stuck for longer than I’d be proud to admit for such a simple problem so I’m calling for help.
Pleeeaaase!

:warning: PS: I used some drivers so you need to enable Auto-run Python scripts, also you need to open it in 2.8.

Cylindrical to equirectangular.zip (1.5 MB)

I think this should work… perhaps a bit more precision in the angle values, as I used 78.7º instead of 78.69º…

@Secrop I assume you are basing your formula on a flat projection since you left the Z input empty but it still gives a distorted Earth.

Hi,

You and @Secrop obviously have the maths in hand :slight_smile: and the precision and flexibility this provides might be essential for your goals, in which case ignore what follows.

As an alternative to the regular ‘image texture’ node use the ‘environment texture’ node, it has equirectangular projection built in. You’ll just need to feed in the correction to the height ( as a scaler value on the Z axis) depending on the proportions of the image you’re using:

Cheers,
Dj.

Thanks for hopping by @DamianJ.
Now the Earth is not supposed to look distorted on the sphere. On your screenshot the continents are squashed in the middle and stretched towards the poles.
I’ve tried various projections for the image node (incl. an environment texture) but I get stuck at the same step. There is one more distortion to apply so that the Earth looks right, which is pretty much where I’m having trouble.

Yep, that’s some tricky trigonometry . . .

Oh my god I’m so dumb!
I just had to put my stupid distortion before the scale to cylinidrical.

Booyah!

Cylindrical to equirectangular.zip (1.5 MB)

To make it simple for anyone who wants to use this file to plug your own cylindrical map :

  1. browse to your image
  2. report its dimensions onto the node (some drivers will use them)
  3. replace the image in the material node (don’t create a new node or if you do, make sure to select the tube projection type inside it)
  4. Scroll in the 3D viewport so that the texture gets updated (this is due to the drivers not updating instantly).

:warning: Again make sure you have “Auto-run python scripts” enabled in your User Preferences and open the file with Blender 2.8.

We don’t need Z for image textures… they don’t have Z. :wink:
What it does:
X is just atan2 normalized (atan2 is like the tangent, but it uses a x and y value to return an angle in ±180º)
For Y, it takes the tangent of the angle, then normalize it to [-78.7º, 78.7º]… Perhaps using asin(z) instead of z*pi/2 could produce better results… Thought I haven’t tried.

EDIT:

Nice… Glad you found a way.

Sure when you use the flat projection in the image node there is no Z but on the tube and sphere ones we do use the 3 dimensions.
Thanks for your help anyway. You’re very generous as always.
I looked up atan2, it’s pretty neat.