Skip to content

This repository contains a Unity demo that shows the use of predistortion to counter lens distortion effects such as barrel and pincushion distortion as well as chromatic aberration

Notifications You must be signed in to change notification settings

DanchGit/Unity-XR-Display-Distortion-Correction-Demo

Repository files navigation

Unity XR Display Pre-Distortion for Distortion Correction

Unity prototypes demonstrating image-space pre-distortion techniques used in XR display pipelines, focusing on:

  • Barrel / Pincushion Distortion
  • Chromatic aberration

The goal of this project is to show how virtual content can be pre-distorted in software so that, after optical distortion, the perceived image appears correct.

All parameters are synthetic and chosen to make the effects clearly visible.

This repository demonstrates the logic of pre-distortion and correction, both of which are simulated

Display pipeline: Rendered image → software pre-distortion → optical distortion → perceived image The goal of pre-distortion is to ensure that, after optical distortion, the perceived image appears geometrically and chromatically correct.


What this demo shows

  • Barrel and Pincushion distortions and their inverse pre-distortion correction
  • Chromatic aberration and its inverse pre-distortion correction
  • Unity-based implementation using shaders and simple runtime controls

Scenes

  • Scene 1: Barrel/Pincushion Distortion Pipeline
    Barrel and pincushion distortion applied to a checkerboard pattern, with toggleable pre-distortion correction.

  • Scene 2: Chromatic Aberration Pipeline
    Chromatic aberration applied to a Siemens sinusoidal star pattern, with toggleable pre-distortion correction.

Each scene allows visual comparison between:

  • original content
  • optics distortion only
  • pre-distortion only
  • pre-distortion + optics distortion (corrected result)

Distortion model for Barrel and Pincushion distortion

Brown’s simplified Forward radial transform:

$$r_{d}=f\left(r_{u}\right)=r_{u}+c_{1} r_{u}^{3}+c_{2} r_{u}^{5}$$

Brown’s simplified Inverse radial transform:

$$f^{-1}\left(r_{d}\right) \approx \frac{c_{1} r_{d}^{2}+c_{2} r_{d}^{4}+c_{1}^{2} r_{d}^{4}+c_{2}^{2} r_{d}^{8}+2 c_{1} c_{2} r_{d}^{6}}{1+4 c_{1} r_{d}^{2}+6 c_{2} r_{d}^{4}}$$


Images

Barrel Distortion (Low)


Reference Image

Simulated Barrel Distortion (Low)

Pre-Corrected Image

Distorted Image appears close to reference image

Barrel Distortion (High)


Reference Image

Simulated Barrel Distortion (High)

Pre-Corrected Image

Distorted Image appears close to reference image

Pincushion Distortion (Low)


Reference Image

Simulated Pincushion Distortion (Low)

Pre-Corrected Image

Distorted Image appears close to reference image

Pincushion Distortion (High)


Reference Image

Simulated Pincushion Distortion (High)

Pre-Corrected Image

Distorted Image appears close to reference image

Chromatic aberration (Low)


Reference Image

Simulated CA (Low)

Pre-Corrected Image

Distorted Image appears close to reference image

Chromatic aberration (High)


Reference Image

Simulated CA (High)

Pre-Corrected Image

Distorted Image appears close to reference image

How to implement

  1. Open the Unity project.
  2. Load a scene from the Scenes/ folder.
  3. Click on the Main Camera in the inspector pannel.
  4. Use the exposed toggles and sliders to inspect distortion and correction behavior.
  5. In Unity, the "games" tab is used to see the effect of modifying the toggles/sliders.

Description of image
Modify the toggles and sliders here

About

This repository contains a Unity demo that shows the use of predistortion to counter lens distortion effects such as barrel and pincushion distortion as well as chromatic aberration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published