Skip to main content
Up and Coming
May 10, 2013

Rift Ray-tracing

[EDIT] This now has a demo, but I'll keep the link here up to date.

Download demo
(Updated to 12 Meg. Ver 0.50 on the Twentieth of June in the Year Twenty-Thirteen)).

Hi All,

I haven't got my Rift yet (UK near the end of the Kickstarter), but have been following the goings on with interest.

I've started to have a go at doing some CUDA based ray-tracing for VR and have managed to get some basic stuff going.

Rather than warping a resulting image I've made a start at modeling the lenses in the ray projection code.
(no texturing or shadows yet, just trying to get the distortion and stereo going.)

This is what I've got so far. It's probably waaaay out, but until I get my one, I'm flying blind. :D

Note: It's a bit wide to see in the post, you may need to open the image in another tab to see the entire screen.

    152 replies

    Up and Coming
    May 23, 2013
    The latest image is of a different area. There is nothing nearby in the center to tell if that bulge needs adjusting, but the distant wall looks okay. Because of large shadows on the outsides of the images, I cannot see clearly if the border is visible or not.

    But the problem is that my eyes are diverging pretty badly. Even though I can handle a fair amount of divergence (due to wide-eye stereo practice), there are parts of this scene that do not merge for me. You need to bring the 2D rendered output images closer together again.

    There is still truncation on the left edge of your left circle. Instead of fixing that, it looks like you lowered the stereoscopic overlap. The previous image was a lot better. I prefer the bulge to painful stereoscopic divergence.

    Also, on the next one, can we return to the previous scene where the bulge was visible (nearby wall in front)?

    EDIT: Even after typing this, my eyes still hurt a little from trying to view that last one in my Rift...
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    TeraBitAuthor
    Up and Coming
    May 23, 2013
    EDIT: Even after typing this, my eyes still hurt a little from trying to view that last one in my Rift...


    Oops. Sorry about that. I didn't move the circles, they got stretched away from the centre because of something else I did. :o

    I've put on a grid to help me keep track of placement for things now. :oops:
    Regards, Lee Page TeraBit Software
    TeraBitAuthor
    Up and Coming
    May 23, 2013
    This one should converge a bit easier... It lines up with the earlier ones, and is unclipped.
    Regards, Lee Page TeraBit Software
    Up and Coming
    May 23, 2013
    From what I can tell by the choice of scene, that one looks just about perfect in my Rift. I would like to view a flat wall from close up like that column, to know for sure if the barrel distortion is correct.

    Do you plan to publish your code? I would like to play with it...
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    TeraBitAuthor
    Up and Coming
    May 23, 2013
    I would like to view a flat wall from close up like that column, to know for sure if the barrel distortion is correct.

    Sure... here we go...


    Do you plan to publish your code? I would like to play with it...

    Not sure what I'm going to do with it yet, it's a bit (lot) ugly, as I'm just learning this stuff as I go.

    [edit] Anything in particular you were interested in seeing?
    Regards, Lee Page TeraBit Software
    TeraBitAuthor
    Up and Coming
    May 23, 2013
    Or.. even:
    Regards, Lee Page TeraBit Software
    Up and Coming
    May 24, 2013
    If you can only do first order correction, it is probably a good compromise as it is now.

    But if you can do second order correction, then when viewing the grid, I could see a little barrel distortion (bulge) in the center AND a little pincushion distortion (stretch) in the outer corners. You probably need to back off a little on the center AND add some second order distortion correction for those corners. I did not notice that bulge on the brick wall, but it was missing long vertical lines.

    Third order distortion correction is probably not needed for the relatively low resolution of the Rift.

    It is really looking good overall. What kind of rendering speed are you getting? How much will it slow down to add some reflective properties?
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    TeraBitAuthor
    Up and Coming
    May 24, 2013
    What kind of rendering speed are you getting? How much will it slow down to add some reflective properties?


    On a GTX470 I'm currently getting 60 FPS with a couple of lights going. Nothing is optimised just yet though, so may be able to improve on it soon. Currently I'm just uploading each frame as a texture, so am currently dropping 20 FPS on that (80 FPS when I don't upload the texture, just render it).

    On the other hand I will be adding other stuff like day differentials/mip mapping and contrast based anti aliasing in the middle of the views. The engine is held together with sticky tape at the moment, so will need to start nailing down the basics properly. Thanks for taking the time to help me get going. :D

    And... I just got my Rift shipping notification. So should be able to sort out the distortion interactively very soon. 8-)
    Regards, Lee Page TeraBit Software
    TeraBitAuthor
    Up and Coming
    May 24, 2013
    Implemented a Pixel Buffer Interop between CUDA and OpenGL (to eliminate the copy to host memory and upload to texture).

    Now getting between 80-90 FPS depending on where in the scene you are. 8-)
    Regards, Lee Page TeraBit Software
    Up and Coming
    May 24, 2013
    "TeraBit" wrote:
    Implemented a Pixel Buffer Interop between CUDA and OpenGL (to eliminate the copy to host memory and upload to texture).

    Now getting between 80-90 FPS depending on where in the scene you are. 8-)
    ...

    That looks pretty good, except I can see a significant amount of the bottom black border. That is a great speed for ray-tracing, I think...

    :)
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.