5
\$\begingroup\$

I'm using the formula I've found here to map procedural texture on to a quad sphere.

For example I'm working with a 3d panoramic cube map that I've generated with a simplex noise.

Each face of the cube will be seamless. That's not the point.

My problem is that the corners of each face will have the typical distortion after mapping it onto the quad sphere.

Therefore I want to "manipulate" or prepare the texture ( in this case, the heightmap ) of each face individually with a curvilinear pincushion distortion.

  1. Am I assuming right that the curvilinear pincushion distortion will compensate the distortion effect on the quad sphere ?
  2. Can someone point me to a formula of the curvilinear distortion or the corresponding calculation of the formula I've linked ?

enter image description here

A: original texture. B: what my texture should look like after preparing.

note that B is only a sketch !

\$\endgroup\$
4
  • 1
    \$\begingroup\$ If you want to achieve what is seen on B rihgt, you can simply use planar mapping, but this isn't going to be seamless. As you see the texture edges don't match the cubesphere edges. \$\endgroup\$
    – akaltar
    Commented Jul 20, 2015 at 13:56
  • \$\begingroup\$ I've solved this problem by directly generating the noise textures the way they should be projected onto the sphere. \$\endgroup\$
    – Ace
    Commented Jul 21, 2015 at 8:51
  • \$\begingroup\$ If that would be an answer to your question, then please make it an answer and elaborate on the technique you used. Also if you are working with a subset of textures, noise in the example, then you should have added that to your question. \$\endgroup\$
    – akaltar
    Commented Jul 21, 2015 at 12:36
  • \$\begingroup\$ I have an animated gif demonstrating a similar distortion in this answer — is that the kind of thing you're looking for? In this example it's not an exact analytical solution, just a tweak to subjectively improve the uniformity of the sphere projection in terms of area per grid cell. The angular distortion at the corners remains the same. If that's useful to you I can post the formula I used. \$\endgroup\$
    – DMGregory
    Commented Nov 25, 2015 at 6:46

1 Answer 1

2
\$\begingroup\$
  1. No, Pincushion distortion is not actually the inverse of Barrel distortion. (Proof below)

  2. This paper seems to be shooting for exactly what you want: A Real-time FPGA Implementation of a Barrel Distortion Correction Algorithm with Bilinear Interpolation (by Gribbon, Johnston, & Bailey) (Formulas inside)

2 Algorithms

Barrel distortion occurs when the magnification of the lens decreases with axial distance causing each image point to move radially towards the centre of the image. This results in the characteristic “barrel” shape. The barrel distortion model [2] is:

\$r_u=r_d(1+kr^2_d)\$        (1)

where \$r_u\$ and \$r_d\$ are the distance from the centre of distortion in the undistorted and distorted images respectively, as shown in Figure 1, and \$k\$ is the distortion parameter, which is specific to the lens.

Illustration of barrel distortion model

Figure 1: Illustration of barrel distortion model


Proof as promised: By contradiction for simplicity.

Extracting the relevant fact about Barrel (and/or Pincushion) distortion:

(2): \$R_{skew}=f_k(R_{flat})\$

We construct an equation we can solve for our correction constant "j" in terms of the distortion constant "k":

(3): \$R_{flat} = f_j(f_k(R_{flat}))\$

(4): \$R_{{flat}}=R_{{flat}}(R_{{flat}}^2k+1) R_{{flat}}^2j(R_{{flat}}^2k+1)^2+1)\$

Which we can then re-arrange to isolate "j":

(5): \$j=\frac{-k}{R_{{flat}}^6 k^3+3 R_{{flat}}^4 k^2+3 R_{{flat}}^2 k+1}\$

Which depends on the independent variable, and thus is not a constant. Therefore a Pincushion or Barrel distortion does not compensate its complement distortion.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .