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!
PS: I used some drivers so you need to enable Auto-run Python scripts, also you need to open it in 2.8.
You and @Secrop obviously have the maths in hand 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:
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.
We don’t need Z for image textures… they don’t have Z.
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.
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.