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
    June 12, 2013
    "jwilkins" wrote:
    This is really nice, you can hardly notice the aliasing.

    Try something for me please if you have time. Randomly jitter your source rays so they do not all go straight through the pixel centers. I'd really like to see if that destroys the aliasing like I expect, especially if you change the seed every frame.

    I did that in some of my code. It really did destroy the antialiasing, but added "snow" to high contrast edges and texture aliased details (a little like a weak analog TV signal). I ended up using a mean average of the random (monte carlo) downsampling with the low-pass filtered content (as used in MIP maps) for my default setting. One GREAT beneficial feature of this added random-sample noise is that it allowed my to discern much finer detail (including much smaller readable text). I really do have way too many code-snippets and proof-of-concept programs that I need to polish off and wrap together, so others can use this stuff too...

    So, I strongly suspect that doing random sampling in this ray-tracer will also allow the perception of finer detail (increased perceptual resolution enhancement), like I saw in my experimental code. Some may complain about the increased noise, so like I was planning, a user-adjustable "quality" slider to balance between MIP-map and monte carlo sampling may end up being a good feature to use here.
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 12, 2013
    I'm just really curious how it would look. I have my own path tracing code I could modify, but I don't feel like that would be a good use of my time at the moment :(

    With dozens of samples random jitter is amazingly good, but even with one sample and bit of squinting it destroys any appearance of what I privately call "ordered" anti-aliasing (that fact that any regular pattern applied to anti-aliasing results in its own new problems).

    It also seems that random jitter in ray casting is far better than random jitter in screen space.
    (╯°□°)╯︵┻━┻
    Up and Coming
    June 12, 2013
    "jwilkins" wrote:
    It also seems that random jitter in ray casting is far better than random jitter in screen space.

    Random dither is evenly distributed over time and space. Whereas "jitter" tends to imply global shifting in time and/or space. Multi-generational VHS copies caused spatial jitter, while multi-GPU SLI problems tend to cause temporal jitter.

    Random dither good -- jitter (of any type) bad... IMHO. Definitions can prevent unwanted confusion.
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 12, 2013
    Hmm, now I need to look up the terms used in Foley and van Dam because I'm pretty sure that is where I picked that up. (And if it is, any argument you make is automatically invalid :) )
    (╯°□°)╯︵┻━┻
    Up and Coming
    June 12, 2013
    "jwilkins" wrote:
    Hmm, now I need to look up the terms used in Foley and van Dam because I'm pretty sure that is where I picked that up. (And if it is, any argument you make is automatically invalid :) )

    I immediately (first glance) spotted my Foley and Van Dam down in "the stacks" even though I have not even looked at those books in years. Excellent "muscle memory", eh?

    Fundamentals of Interactive Computer Graphics, March 1983 "Reprint with Corrections" edition. They published later books together, but this was the original "Foley and Van Dam".

    Anyway, I had to move a bunch of stuff to actually get near that shelf, but now that I have book in hand, the 'J' index only has "Joystick", "Joyswitch", and "Jump instruction". No "Jitter". Hmm... I seem to be having difficulty finding a "grep" function in this "dead tree" edition of the book...
    :o

    Maybe Google has a copy? Yes, and searching for "jitter" finds zero matches (but some pages may be missing from their online copy):
    http://books.google.com/books?id=zZJRAAAAMAAJ&q=jitter

    And here are some cheap ones on eBay, if anybody wants to read a "dead tree":
    http://www.ebay.com/itm/221238783159
    http://www.ebay.com/itm/121007754871
    http://www.ebay.com/itm/360015756130
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 12, 2013
    Carmack recently remarked he needed to look at the book to see if anything that had seemed to have become obsolete may be new again. These things catch my eyes as I thumb through it:

    page 356. A data glove.
    page 616. Stereopsis
    pages 616-647 AA and filtering theory from the ground up
    page 788, Stochastic sampling

    Figure 16.59 on page 788.... wow, I didn't even think I was right but there it is. My memory is inhuman.

    Maybe I will have a another browse through this classic work.

    The figure 16.63(d) is a perfect example of the kind of "order" artifacts that I hate about using regular AA patterns.
    (╯°□°)╯︵┻━┻
    Up and Coming
    June 12, 2013
    "jwilkins" wrote:
    Carmack recently remarked he needed to look at the book to see if anything that had seemed to have become obsolete may be new again. These things catch my eyes as I thumb through it:

    page 356. A data glove.
    page 616. Stereopsis
    pages 616-647 AA and filtering theory from the ground up
    page 788, Stochastic sampling

    Figure 16.59 on page 788.... wow, I didn't even think I was right but there it is. My memory is inhuman.

    Maybe I will have a another browse through this classic work.

    The figure 16.63(d) is a perfect example of the kind of "order" artifacts that I hate about using regular AA patterns.

    Man, the last page of my INDEX is page 664. The last page of content is page 623. I do have a chapter 16 (Shading Models) but no "stochastic sampling" in there. And my index does not contain "stochastic" or "sampling" (or anything similar).

    So, falling back to our trusty WikiPedia:
    "
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 12, 2013
    You have the first edition? Nice.
    This should be fair use.
    jitter.png

    Oh, and my original statement that jittering in ray space is better than screen space is because of nonlinearities and discontinuities in where the rays end up going gives a more accurate picture of where the rays are passing through that particular pixel.
    (╯°□°)╯︵┻━┻
    Up and Coming
    June 12, 2013
    Although they called random sampling "jittered sampling" in your edition, mine seems to be lacking that reference. And in general, that is an archaic term. I usually see "random sampling", or "monte carlo sampling" used these days.

    Even "Downsampling" seems to deal mostly with time-domain sampling, rather than spatial sampling:
    http://en.wikipedia.org/wiki/Downsampling
    I guess when it comes to sampling, time and space are mostly interchangeable.

    Anyway, I found a mixture of MIP-map and random (jitter) downsampling to be the most pleasing to the eye (or my eyes, at least), and the added bonus was increased effective resolution (especially when combined with sub-pixel "wobulation").
    :D
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 12, 2013
    "geekmaster" wrote:
    Although they called random dither "jitter dither" in your edition, mine seems to be lacking that reference. And in general, that is an archaic term. I usually see random dither, or random sampling, or monte carlo sampling.


    But isn't dithering a method of distributing error? Jitter is a method of adding noise. You dither in order to hide errors due to quantization. You jitter in order to keep a quantization from being too regular. I think it is more than just semantics.

    (and where do you see them mention dithering at all?)
    (╯°□°)╯︵┻━┻