Skip to main content
New Participant
August 28, 2013

Shader to undistort webcam video for AR Rift

I am building an AR display using the Rift and attaching two webcams to the front. I have two 120 degree webcams and am texturing two planes in my Unity scene with live the video feed using WebCamTexture. The plane has the same 1:1.78 aspect ratio as the webcam feed.

However, simply projecting the webcam video onto this flat plane of course suffers from normal barrel distortion of cheap cameras. This distortion is particularly pronounced as the cameras have a wide (120 degree) field-of-view lens.

I assume a shader would be the best way to correct for this distortion. The other possibility would perhaps be projecting the webcam video onto a mesh geometry that is the inverse of the webcam lens distortion. However, the shader approach seems to be the more general solution.

Does anyone have any ideas to get started on this? I have calibrated my camera with OpenCV and so I have the camera's distortion coefficients.
    This topic has been closed for replies.

    2 replies

    New Participant
    September 6, 2013
    Do you have any screenshots?
    Inspiring
    September 6, 2013
    Yes, a shader will be a good way to do this.

    This page seems to have the algorithm you need:

    http://stackoverflow.com/questions/6199636/formulas-for-barrel-pincushion-distortion
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV