Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: lenticular virtual image

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    4

    lenticular virtual image

    I'm trying to visualize a model of lenticular images virtually with opengl

    pov-ray seen that it is possible by making an array of semi-cylinder lens in front of the square in POV-Ray to "play"
    Anyone know how to do with opengl?

    tks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    On the surface it just looks like the blend of 2 textures (your 2 images) based on a function of the eye-point to fragment vector. You will have the construct this function and pop it into the fragment shader

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    4
    Quote Originally Posted by tonyo_au View Post
    On the surface it just looks like the blend of 2 textures (your 2 images) based on a function of the eye-point to fragment vector. You will have the construct this function and pop it into the fragment shader
    I tried but do not work very well, do you have any examples of how to do this?

  4. #4
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,946
    Your lens will refract light and I assume you want to fly around this lens as it does so not simply stare through it.

    You need to claculate the novel viewpoint and frustrum to generate the refracted image. Render that image to a texture and then apply that texture to the lens rectangle.

    The simplest way to get the refraction is to raycast your rectangle corners through the lense rectangle according to Snell's law. Use the *EXIT RAYS* only and store these for all four corners. These four corner rays define your new frustum and will intersect at a novel view point. That Viewpoint's view direction should be orthogonal to the plane of the lens rectangle. From there you can compute the window of your frustum discarding the corner rays.

  5. #5
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,946
    P.S. there are other simpler hacks that are not as accurate that you could also try that would not account for localviewer lens position, but simply use the existing rendered framebuffer image and readback. Or you could go more complex and implement non linear geometric distortions by subdividing the lens rectangle and applying additional corrections on a peicewise grid that warped the image you generated.

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    4
    tks dorbie
    I'll try doing using refraction

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •