Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JMF's avatar
JMF
Honored Guest
11 years ago

Barrel distortion NEW SOLUTION MADE!!!

I would like to point out main disadvantages of current barrel distortion solution know as "pixel mapping":

• Black borders around image (21% of screen is not in use)
• higher resolution (than screen) buffer slows down FPS
• current distortion is post-effect

Now that you know this mystery I can describe to you the solution that I invented.
Basically lets see how 3D objects are projected on flat "screen"

This is oversimplificated presentation

To create distorted image, projection on curved surface can be done, but you must know that computer sees single
polygons as projected objects...
and wall divided by 3 polys looks like this:


but... we can cheat it!

What is the difference between flat projection and curved projection?
The distance between focal point and the pixel! :D

simple presentation –>

Moving focal point for every pixel creates curved image.
How to achieve it?


Assume that you have 1920x1080 screen and 110 fov:
Xres = 1920
Yres = 1080
FOV_H = 110


Distance between pixel and focal point for left/right middle edge pixel is:

DistancePixToFocal = 960/ sin( FOV_H / 2 )
Focal4ThisPix = sqrt( DistancePixToFocal**2 - DistanceFromCenter**2 )


Focal points values can be calc to file and then readed when needed ;)

Aspherical distortion for Oculus Rift

Graph shows different projections for pixel distance.
Changing DistancePixToFocal to the value from graph creates flowing effects:
This graphs represent relationship between distance from pixel to center of the screen and pixel to focal point distance



If you like it please leave the comment...
I'm already making code for this

EDIT
I changed links to images ;)

15 Replies