Screen space reflections

Discussion in 'Rendering Technology and APIs' started by Graham, Jan 10, 2010.

  1. Graham

    Graham Hello :-)
    Moderator Veteran Subscriber

    Joined:
    Sep 10, 2005
    Messages:
    1,479
    Likes Received:
    209
    Location:
    Bend, Oregon
    So I had an idea tonight...

    Could you do screen space reflections.
    Well, I'll get to the point: You can! :)

    My implementation is hacky, nasty, buggy and - well - ugly. But it proves it's a workable technique.

    Basically, it works like this:
    For each pixel, you have position/normal. Given the vector to the pixel, you can work out the reflection vector from the surface normal.

    So... Then it's a matter of taking that reflection vector and sample it at a bunch of intelligent points.
    Work out where those samples project to into screen space.
    For each sample, check it's depth, if the depth is closer than the sample point - then the reflection ray has impacted some screen space geometry.

    Yay! Simple. Slow, but simple.
    I'm sure there are a zillion ways it could be optimised.


    Anywho. Here are some proof of concept pics:

    *NOTE THESE ARE PROOF OF CONCEPT*

    *I know they have visual issues!*

    [​IMG]

    As you can see, lots of glitches :razz:

    Here are some more (even more glitches!)

    [​IMG]
    [​IMG]
     
  2. Talonman

    Newcomer

    Joined:
    Jan 2, 2010
    Messages:
    64
    Likes Received:
    0
    Outstanding! :)

    Love the effort...
     
  3. Farid

    Farid Artist formely known as Vysez
    Veteran Subscriber

    Joined:
    Mar 22, 2004
    Messages:
    3,844
    Likes Received:
    108
    Location:
    Paris, France
    Now that's an interesting technique you developed there, Graham. Do you plan on ironing it out and have something useable, or did you just want to get the idea out?

    Also, how does it look in motion? Usually, the screen space effects limitations really show when in motion.

    And more importantly, is it cheaper than having a render target cubemap for each of these primitives?
     
  4. Graham

    Graham Hello :-)
    Moderator Veteran Subscriber

    Joined:
    Sep 10, 2005
    Messages:
    1,479
    Likes Received:
    209
    Location:
    Bend, Oregon
    Well. Now the fun part is over (seeing if it works) I'm not so keen on improving it :twisted: :mrgreen:

    Then again, there are much smarter people out there who could do a much better job.
    One thing which would make sense is using lower LODS on the position / colour texture the further you sample - which (in theory) would produce fake soft reflections, and require less samples and be faster :) I would do this, but XNA only allows point filtering for autogenerated mipmaps - which looks a bit naf - but does make it much faster.

    It's actually not too bad in motion. It's the flickery glitch pixels obviously pop out. It's actually very stable otherwise.

    As for expense, this implementation is *horribly* expensive :mrgreen:
     
  5. Remmie

    Newcomer

    Joined:
    Jun 23, 2010
    Messages:
    2
    Likes Received:
    0
    Can you share any code? I'd love to improve on this. Main application would be water surfaces. By taking a reflected image and use your method to create more accurate UV of the reflected scene we should be able to get much better results. Also, for pixels outside the view or far away we can use a cube map.
     
  6. Remmie

    Newcomer

    Joined:
    Jun 23, 2010
    Messages:
    2
    Likes Received:
    0
  7. Rodéric

    Rodéric a.k.a. Ingenu
    Moderator Veteran

    Joined:
    Feb 6, 2002
    Messages:
    4,031
    Likes Received:
    898
    Location:
    Planet Earth.
    Interesting, might be usable for some games, depending how fast the implementation can be made.
     
  8. Colourless

    Colourless Monochrome wench
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    1,274
    Likes Received:
    30
    Location:
    Somewhere in outback South Australia
    Interesting, but you really wouldn't want a reflective surface pointing right back at the camera. The thing I'd think this would be most useful for would be something like water reflections.
     
  9. Npl

    Npl
    Veteran

    Joined:
    Dec 19, 2004
    Messages:
    1,905
    Likes Received:
    6
    how would it look if you`d lift one of those objects in the air far enough so that you should see part of the bottom-side in the reflections?
    This quite reminds me of old 2D-Games which draw the reflection by merely mirroring the horizontal pixel rows above it. Probably usefull for those 2.5D Games =)
     
  10. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Interesting approach, but the question is if this technique is faster than doing an actual reflection pass. Reflection passes don't need to be very expensive since they usually don't necessarily have to be very accurate.
     
  11. jlippo

    Veteran Regular

    Joined:
    Oct 7, 2004
    Messages:
    1,487
    Likes Received:
    658
    Location:
    Finland
    Indeed, although this effect might be usefull for a self reflection/occlusion cases.
     
  12. tamat

    Newcomer

    Joined:
    Mar 6, 2009
    Messages:
    4
    Likes Received:
    0
    I remember watching this algorithm in Call of Juarez: Bound in blood.

    They used it for a scene where its raining and everything is wet. It worked quite nice, you could see reflections in characters bodies, but the main problem were the objects near the camera being reflected in far away objects, like the gun being held by the player.

    Anyway, nice approach.
     
  13. mrFusion

    Newcomer

    Joined:
    Sep 28, 2011
    Messages:
    1
    Likes Received:
    0
    I have managed create an approximation of this and what was described at Siggraph by crytek... I was wondering, when you say, "intelligently derived samples", were you referring to Secant searching?
     
  14. tabs

    Veteran

    Joined:
    Jan 11, 2007
    Messages:
    1,717
    Likes Received:
    258
    Location:
    UK
    Did Crytek give Graham any money though, that's the real issue. :p
     
  15. homerdog

    homerdog donator of the year
    Legend Veteran Subscriber

    Joined:
    Jul 25, 2008
    Messages:
    6,286
    Likes Received:
    1,061
    Location:
    still camping with a mauler
    I'm glad this thread was resurrected. When I heard Crytek was doing SSR I knew I'd seen the technique somewhere before.

    The problem with screen space reflections is that they are screen space. Very often shiny objects are reflecting things that are not already on the screen. In fact the whole point of a mirror is to show something that you cannot presently see from your viewpoint.
     
  16. jlippo

    Veteran Regular

    Joined:
    Oct 7, 2004
    Messages:
    1,487
    Likes Received:
    658
    Location:
    Finland
    True, but they can add some very nice visual cues and same time work as a specular mask for cubemap.

    Specular AO is pretty much something I hope that all games would use as it fixes a big problem with IBL. (IE, characters tongue or eyes are lighted by light coming from behind his head, specular ssao (sssao?) or SSR would fix this easily.)
    It also reduces highly aliasing edges as many of them are occluded in some way.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...