Chapter 2:What's up with Screen-Space Realtime Reflections?
I bet many of you guys have been wondering what the SSR technique really meant for the game.
First up, let's recover some of the reflection background in Crysis 1.
Basically, in CryEngine 2 it was possible to set up the same reflection technique used for the water reflections on a material, so that it would work on some kind of plane.
How did it look? Quite nice!
This picture is actually taken from an old thread of mine
How did it integrate into the game?
Very poorly actually. First of all, the performance hit was very significant. Crysis 1 was almost unplayable on any PC in 2007, had they included those reflections there was no way any regular CPU could handle the game.
The second, even more significant problem was that it was incredibly buggy.
Constant Editor crashes were to be expected if one wanted to try out this kind of mirroring. 2 Mirrors? Almost no chance. Performance? Let's not talk about it.
Also, if one did not have the object planes aligned horizontally, many many perspective problems were to be solved first. The screenshot you see up there really took hours and hours of making until the perspectives actually worked.
Could you mirror yourself? Yes you could. Because those mirrors were working with a raytracing technique, they would be able to display your reflection. Well, if you were close enough. And if you weren't in such an angle that the asymmetrical culling was to cut out your character.
Real mirroring was only possible in a very small room (that's actually how it is in almost all PC-Games which use this "ancient" technique, for instance Duke Nukem Forever)CE2 standard raycasting mirroringPros
- screen independent
(- you could mirror yourself)
- good image quality, little image artifacts if reflected objects were close enoughCons
- for real ingame use 1 Mirror maximum (!)
- Reflecting Object must be a plane (!)
- significant performance hit
- reflection culling (+ no horizontal culling)Ok and what's different about SSR?
First of all, I need to say that SSR came with the new 1.9 patch and is enabled if one sets "Shader" to "Ultra" spec.
For the Editor users (which I guess most of the readers are)
here are the CVars.r_SSReflCutoff Standardvalue="0.2"
- sets the glossiness value above which every material uses SSR. 0.2 stands for the percentage though, so 20% means one has to set the glossiness to 20% of 255, so everything above 51 should do.r_SSReflections Standardvalue="1"
- Toggles the Reflections on or off (0)r_SSReflExp Standardvalue=".25"
- Reflection exponent. The lower the value, the more the glossy materials will reflect. Negative values are possible and exxagerate the effect, but they also produce some overdarkening artifacts.FOR THE SAKE OF EXPLANATION THOUGH
, I USE r_ssreflExp = -1 in the following shots.
Looks good right?
What's different to the shots before? A lot.
First of all the Reflections are all taken from images in Screen-Space. That has some big advantages as well as some huge disadvantages which we will see in the upcoming posts.
The technique works more or less like this (might be wrong, but probably is close to the truth)
For every pixel on the screen
one already has the depth value and the actual color saved, because of the deferred rendering used in CryEngine 3.
Now, for every block of pixels on the screen
a ray is casted. If it hits an object, the reflex
ion (with x
) is calculated and the future ray path is compared to the pixel/depth values we already have.
If they match, the according color is being added on the appropriate position on the reflecting object. Because this is not done for every pixel, but for every block of maybe 20x20 pixels, the resulting images are a little blurred into each other.
This hole process only has to be done once for the whole screen and every reflection is approximated for every object on the screen. Awesome
Yeah except there are some obvious problems with it.
First of all, ray casting is still somewhat expensive, so the ray distance is limited (like before).
But that is not the real deal of issues.
Let's take a close look at the results (again effect is exxagerated) Click on the image to zoom in!
1. We see some obvious stepping on the car's front. Why?
Because the rays which come from the mirroring object hit the car on two spots and the distance between these two spots in the mirror is bigger
than the distance of those two pixels on screen which they are taken from.
2. Do you see the car's shadow on the reflected image?
Oh wait, there is no shadow in the real image... Why's that?
Because we don't have the pixels requested in the reflection on the Screen.
Now you might be confused.
Let's make it easier to understand.
In both cases the reflection on the mirror should be the same, but it isn't.
This is BECAUSE it the reflected ray relies on the pixel/depth information we already gathered when rendering the image before. This makes it a lot more cheaper to process, but at the same time one cannot mirror things that are not on the screen
Effectively this means, looking down the floor won't let you see the roof.So let's collect what we have:Screen Space Realtime ReflectionsCons
- Screen/Image dependent
(- you cannot mirror yourself)
- significant artifacts and missing reflections on objects not visible on the screen
Does not sound too good, does it?
Well, Crytek wisely uses this technique only in subtle moments. The reflection gradually gets more visible the more obtuse your reflection angle is.
That's actually like in real life. You cannot mirror yourself in a piece of blank metal or polished wood, but if you look from a more horizontal angle, the object will reflect it's surroundings.
And if you reflect something horizontally, chances are way better that the mirrored object is actually on screen. Sooo... Pros
- in comparison very fast and cheap
- can be applied to every object, the amount of reflecting objects is infinite
- can be applied to non-planar objects
- acceptable results with obtuse angles
- in CryEngine 3 it works hand in hand with local Environmental Probes to cover other, more distant static reflections.Conclusion:
Is this new technique any better than the old one? It is different. (It can't be compared in the way CE2 and CE3 can be compared
Reflections have always been one of the most difficult things to render in real-time, but at the same time one of the key elements to a more realistic looking image.
Most of the effects everyone is used to in Rasterization Realtime Graphics are more or less approximations or fakes, which most of the audience accept as good enough.
And so is SSR in my eyes.
It is the first approach to equip every piece of glossy material with reflections in gaming history and at the same time it is, quite surprisingly, affordable to almost every PC which can run Crysis 2 (and that is almost every gamer's PC).
It has obviously never been the goal to create a mirror for the protagonist to watch himself with it, and what it actually does, it does quite good.
So overall, I think everyone should be quite happy with the work of the RnD department.
I have to say that some more control over the effect via CVars would have been nice. But that's nitpicking.
I've heard some people say it's "buggy"... thats just the way it works, one cannot "fix" these bugs, it's just the way it works! Get over it! Use it in the way it's supposed to be used!
One could of course set up multiple cameras to improve quality, but this would be complicated, costly and would not eradicate all bugs either. The next step is raytracing.
Got interested? Want to see for yourself in the game?
Play the Mission on Roosevelt Island, after Central Station and you will see images like this
(no change in effect)
Liked the read? Want more? Give me some feedback!
And please, please do not
make this a CE3 vs CE2 discussion thread.