Skip to main content
June 16, 2013

Executing Barrel Warp by dependent texture lookup

I am currently working on the barrel warp part of Oculus integration and am trying to use dependent texture lookup instead of computing the distortion in the shader in realtime:

1) Encode the distortion function into a 2D texture.
2) In the shader, first lookup the distorted coordinate from here, then lookup the output color from the scene render target using this result.

It seems to me that this has various advantages over computing the distortion directly in the shader:

1) Since the distortion texture needs to be computed only once, more complicated distortion formulas can be used. For example use a real polynomial, instead of limiting to just even powers. Also correction for astigmatism or similar conditions might be possible.
2) Due to the pre-calculation it is known exactly which pixels will be looked up from the scene render target. So it is possible to optimize clipping.
3) The distortion texture could be combined with other fullscreen post-processing distortion filters
4) In theory this can be done without shader capabilities

Has anyone else experimented with this and can share his experiences?

    2 replies

    Up and Coming
    June 16, 2013
    It was reported that using a texture as a displacement map provided a 2.4x to 3.8x speedup over doing real-time per-pixel computations. GLSL shader source code was provided.

    Shader optimization (with displacement map texture):
    viewtopic.php?f=20&t=353

    Lens distortion correction using displacement mapping:
    http://www.mtbs3d.com/phpBB/viewtopic.php?f=140&t=17200&p=126095#p120358

    And a bit about how displacement map textures can be faster than direct computation:
    http://www.mtbs3d.com/phpBB/viewtopic.php?f=140&t=17200&p=126095#p120524

    Plans to use this in low-power devices:
    http://www.mtbs3d.com/phpBB/viewtopic.php?f=140&t=15247&p=95673#p95673

    There are a lot more posts discussing this in various threads here and at MTBS3D. Use the search functions to find more information.
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    June 17, 2013
    I tried the search, but didn't come up with any useful articles. Thanks for pointing out a few for me, I will contribute to the existing threads with my experiences :)