Forum Discussion
larspensjo
12 years agoHonored Guest
Pincushion distortion transform
The current barrel transform is

where

As I understand it, you use that to transform the UV coordinates you sample from a bitmap. This works fine for deferred shaders. But how is the reverse transformation done? My math is a little rusty, but it looks to me that it would be non trivial. That is, if you are doing forward rendering and simply want to adjust the coordinates of the vertices in the vertex shader.
I realize such a transformation only works if the geometry is "small enough", with risk for artifacts.
where
As I understand it, you use that to transform the UV coordinates you sample from a bitmap. This works fine for deferred shaders. But how is the reverse transformation done? My math is a little rusty, but it looks to me that it would be non trivial. That is, if you are doing forward rendering and simply want to adjust the coordinates of the vertices in the vertex shader.
I realize such a transformation only works if the geometry is "small enough", with risk for artifacts.
3 Replies
- geekmasterProtegeYour embedded images do not work for me (broken links). Those broken images have rather odd looking URLs:
http://latex.codecogs.com/gif.latex?%5Cbegin%7Bbmatrix%7Du%5C%5Cv%5Cend%7Bbmatrix%7D%3D%5Cbegin%7Bbmatrix%7Du_0%5C%5Cv_0%5Cend%7Bbmatrix%7D%28k_0+k_1r%5E2+k_2r%5E4+k_3r%5E6%29
http://latex.codecogs.com/gif.latex?r%3Du_0%5E2+v_0%5E2
Google chrome reports that it cannot connect to "latex.codecogs.com". Although it uses a different IP address, "www.codecogs.com" is also not responding. Whois reports that it is a UK address, so if it does not have international restrictions, then perhaps their web servers are down for maintenance.
Regarding your question, you can find the current implementation in the SDK source code. Look in the fragment pixel shader.
It is based on the "Brown's model" lens distortion correction formula published at Wikipedia, but without the tangential correction (P) terms needed for lens offset:
http://en.wikipedia.org/wiki/Distortion_(optics)#Software_correction
When chromatic aberration correction is used, the formula is applied three times, with slightly different coefficients for each of Red/Green/Blue color planes.
The artifacts I have noticed seem to be caused by doing the lens distortion correction after downsampling instead of before downsampling (as can be determined by the sharp "stair-step" on the curved outer edges of the warped image output when viewed on a desktop LCD display). If performed before downsampling, that curved edge should be smooth, and their should be less blur in the rendered content, especially near the edges.
One way to prevent this is by using in-game distortion correction by using a (simulated) fisheye lens on the in-game camera, or by using the center part of a spherical reflection, as described by Paul Bourke back in 2004. There is no blur using this method (which I am using in my Ras Pi code). A complication is if you want to do chromatic aberration correction. - larspensjoHonored Guest
"geekmaster" wrote:
Funny, I can't explain that. It looks fine to me, as does the link. Maybe the server is up and running again now.
Your embedded images do not work for me (broken links).Regarding your question, you can find the current implementation in the SDK source code. Look in the fragment pixel shader.
But that is the barrel distortion, isn't it?It is based on the "Brown's model" lens distortion correction formula published at Wikipedia, but without the tangential correction (P) terms needed for lens offset:
I see, using a negative K1 gives a pincushion distortion. I just have to find what constants to use.
http://en.wikipedia.org/wiki/Distortion_(optics)#Software_correctionWhen chromatic aberration correction is used, the formula is applied three times, with slightly different coefficients for each of Red/Green/Blue color planes.
I have't got this far yet, and I am not sure it is needed? Well, I had to go and test it with the demo application (OculusWorldDemo). Indeed, there is a distinct color shift at the outer limits of the view field. But I didn't notice until I started to look for it.
There are three pairs of lenses provided. Do they all have the same chromatic aberration?
Thanks for the help! - geekmasterProtege
"larspensjo" wrote:
The images are working for me now too. Perhaps they were temporarily unavailable..."geekmaster" wrote:
Funny, I can't explain that. It looks fine to me, as does the link. Maybe the server is up and running again now.
Your embedded images do not work for me (broken links)."larspensjo" wrote:
Rift pre-warp does apply barrel distortion, to compensate for pincushion distortion in the lenses.
But that is the barrel distortion, isn't it?"larspensjo" wrote:
They should be identical lenses. The lens cups are different depths to adjust the focus for different people. The distortion coefficients may need adjusting after switching lens sets, but I did not notice much difference other than FoV using when switching to different lens eyecups. The chromatic aberration correction is not perfect in all cases, making color fringing visible is some areas (especially visible in OculusRoomTiny with all those sharp-edged floor tiles) but it is quite good, IMHO.
There are three pairs of lenses provided. Do they all have the same chromatic aberration?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 12 months ago
- 2 years ago