General CRYENGINE Discussion

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Thomy's CryDev Blog [December 17th: Terrain AO]
PostPosted 04.07.2011, 13:43 
This thread is my personal blog about Crytek, CryEngine and of course some CryDev development. Find my blogs and articles on the links below and enjoy.
If enough people are interested, I am going to make some small articles about things in CryEngine 3 which I find interesting to show off or to compare to older iterations of the Engine. This articles are not meant to be truly professional. Do not make this a hate thread, everything presented here is special.
I included a Level Designer's Checklist at the end of the list of links. I hope this will help a lot of newbies :)


Article Series:
"CryEngine 3 Tech you might not know about"

Chapter 8: Sandbox Version 3.4.4
Light Attentuation Maps

Chapter 7: Sandbox Version 3.4.3
Vegetation Rendering and interesting uses

Tips and Tricks: Crysis 2 Mod SDK
SandBox 3

Chapter 6: Crysis 2 Mod SDK
From S^3 to S^5

Chapter 5: Crysis 2 Mod SDK
Global Illumination

Chapter 4: Crysis 2 Mod SDK*
Hidden Feature: Point Light Shafts!

Chapter 3: Crysis 2 Mod SDK*
Let's tile those lights!

Chapter 2: Crysis 2 Mod SDK
What's up with Screen-Space Realtime Reflections?
(see below)

* - not working in current SDK.



Thomy's CryDev Blog:

A Crysis 3 review (new)
A personal analysis of the Crysis 3 trailer
A short summary of some new FREE SDK Update features
A short analysis of the first Mechwarrior Online Screenshots (and some things on PostMSAA)
Light Attentuation, SSDO and GDC 2012
What I'd modify in CryEngine 3 if I could
Some more Sandbox and Warface! (SuperSampling Antialiasing!)
A word about our community
Crytek's future Part2
Crytek's future Part 1




Level Designer's Checklist:

  • Always use projected lights if possible, avoid a lot of shadow casting lights
  • Check if Global Illumination actually has the desirable effect on your level (by enabling/disabling the effect in the Time of Day Editor), if it's not satisfactory disable GI and maybe fake the reflection with point lights.
  • If you are having large forests, check if instancing might be an option (see Sandbox Tipps and Tricks)
  • Remember that light sources have a view distance. In many cases levels can be optimized with lower view distance of lights. Remember not to test this in Very High though, your view distance is different depending on the specs, unless you unify this in your cvars. Same thing applies to all other objects, especially vegetation can make a big difference.
  • Layer Switching is a great method to disable all objects of the past part of the level and enable the upcoming ones, thereby saving a lot of recources. You can do this via flowgraph -> Engine::LayerSwitch.
  • I will try to keep this updated. If you have suggestions, simply post them in the thread.

useful: How to take screenshots: viewtopic.php?f=311&t=92863&hilit=capture+frame




Image

EDIT: Chapter 1 is embarrassingly clunky and non-professional. I will leave it as it is here, but there are many inaccuracies in this article.

Chapter 1:
How good is SSDO? It's THAT good!

So for anyone who does not know what SSDO is
SSDO is a new kind of screen space indirect shadow approximation, effectively replacing SSAO.

Screen Space Directional Occlusion darkens edges where to approximate indirect shadowing, but in contrast to SSAO, it takes into account the position of every light source affecting the area.
SSAO is always static in comparison, it works only with geometry.

SSDO is enabled with the "Ultra" Shading spec for both Dx9 and Dx11 in CryEngine 3.

To show you how well this technique already works I made a small comparison
The first picture shows a Light source with regular shadow casting enabled, the second image has only an ambient light activated.
Image
Image

One can see the difference best if one opens them in two different tabs:
With Shadows
SSDO only

Notice the quite accurate indirect shadowing behind the boxes and the vastly better frame rate.

Part 2:
Now - how does SSDO in comparison to SSAO?
Very well you will see!

Some things to note:
Image

One can see the difference best if one opens them in two different tabs:
SSDO
SSAO

Due to depth bias, shadows sometimes "begin" with a little distance from the casting object.
With SSDO, this problem obviously is addressed in some way.

Also note on the correct indirect shadowing from the soldiers arm, in comparison to the SSAO picture.

The indirect shadowing on the back wall looks a lot cleaner and more natural.

Also, notice around the head of the soldier to the very left, how SSAO sometimes brightens up things in the back around characters. This leads to unrealistic looking images.
SSDO does not deal with those kind of problems.

Different example (maybe a better one)
SSDO
SSAO
again, one can see the awesome indirect shadowing of the sandbarriers with SSDO. Also with SSAO, one can notice a brightening up on the balustrade to the right.

---------------------------------------------------------------------------------------------------

Image
First up is a picture showing SSAO
Image
The second image shows SSAO with the technique derived from CE2.
Note: The image quality is comparable but the framerate drops significantly
Image
Third picture showcases SSDO. Note: Framerate is comparable with the new SSAO technique.
Image
No Ambient Lighting, for the sake of comparison

Info: So yeah I've always done some kind of blog on Crymod, the last one was on Underground


Last edited by Thomy on 18.12.2013, 16:01, edited 32 times in total.

User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Re: CryEngine 3 Tech you might not know about [article serie
PostPosted 04.07.2011, 13:43 
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!
Image
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 mirroring
Pros
- screen independent
(- you could mirror yourself)
- good image quality, little image artifacts if reflected objects were close enough

Cons
- 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.

Image
Image

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 reflexion (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 right?

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!
Image
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.
Image
Image
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 Reflections
Cons
- 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.
Thanks guys!

Additional thoughts:
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
Image
(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.


Last edited by Thomy on 08.07.2011, 15:43, edited 1 time in total.
User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Re: CryEngine 3 Tech you might not know about [article serie
PostPosted 04.07.2011, 21:39 
Chapter 3:
Let's tile those Lights!

In this article I want to talk about "Screen Space Tiling of Deferred Lighting", which is one of the techniques used in the CryEngine 3 to handle massive Lighting.
What is this kind of tiling and why do we need it?
Well, with deffered lighting basically all lights, except for the sun, became postprocessing effects. During rendering each pixel is checked whether it is affected by a light or not and then colored appropriately. In comparison to the Forward Rendering used in CE2, one can afford way more lights before framerates drop significantly.
However, if hundreds of lights fill the screen, sometimes it the processing overheat for every pixel gets intense, because one has to check all those light sources.

A workaround used in many Deferred Engines (first pioneered by Naughty Dog in Uncharted and now used by CE3 and Frostbite 2 for example) is the tiling of the screen.
First of all the screen gets divided into tiles, default settings are 16x12 tiles.
For each tile it is checked which light's radius affects the area, and the pixel colors inside only have to be calculated with those lights only. (Look further down the post, there are some screens of the tiling!)
Now of course, if one only has 2 or 3 lights on the screen, it does not make a lot of sense checking light accessibility for 16x12 / 192 tiles, because that would, overall, slow down the whole process.

And that actually is the reason why this feature is disabled by default in Crysis 2. Most of the gameplay is outside and rarely do we have light amounts that would actually justify the use of this technique (an example would be central station though). Maybe some errors unknown to me were also part of the decision to work without tiling in the game.


So let's see how it performs!

First of all, I'll provide some CVars for the ones of you who want to try it out in the Editor

r_DeferredShadingDebug Standardvalue="0" - "1" will disable deffered lights, "2" will only display 1 deffered light, usually an Environmental Probe. "3" will show the fillrate cost (overdraw)
r_DeferredShadingTiled Standardvalue="0" - "1" will enable tiling, "2" will show the tiles with appropriate color information showing the amount of lights for each tile
r_DeferredShadingTilesX Standardvalue="16"
r_DeferredShadingTilesY Standardvalue="12"
- these two determine how many tiles are used. By default the screen is divided by 16 horizontally and by 12 vertically.

So let's get to some comparison shots, right?
I filled this scene with about 120 lights with different colors, because, as said before, tiling makes only sense and significant differences when dealing with many lights.
First screenshot has no tiling, the second one is tiled 16x12.

If you want to open those in different tabs, click and click!

Image
Image
First thing one notices - the tiled image runs at a 25% faster framerate. Not bad actually.
Second thing one sees is a little bit strange. CryEngine somehow increases the radius and intensity of the lights when they are calculated in tiles.
Why? I don't know, but the image quality is essentially the same if one adjusts these parameters accordingly in each mode.
Also, the DPs in the scene go up massively (982 without tiles, 1920 with 16x12, 5463 with 30x30), but one shouldn't care if the performance works.

Now let's take a look at fill rates.
Again the first screen ist untiled, the second one operates with 16x12 tiles.
If you want to open those in different tabs, click and click!

Image
Image
Do you see the clear difference? Even though the tiled render clearly has the radius of the lights increased, if we look at the overdraw, it shows a significantly better image.

Next up let's see how the big the difference gets when we increase the radius of the lights, so that they intersect more (radius 6 m, lights every 1m from each other)
click and click!

Image
Image

Again one can see how the lights radius and specular intensity is somewhat bigger with tiles, but more significantly the framerates climbs from definetely unplayable 14 fps to 25 fps! That's almost 80% (for my specs, keep that in mind :) and by the way, I was taking these shots on "Ultra", but my computer is really not playing in this league)
In this shot however, the lighting also shows some more visible changes, note the window frame in the background. However, clear visual artifacts are not to be encountered if one runs with tiles.

Now let's get to the next example
I've set up a scene with 150 lights with radiuses of 10 in Battery Park.
no tiles and 16x12 tiles

Image
Image
Again we can see an increase of FPS by about 20%.

Now let's turn on r_DeferredShadingTiled 2.
We can now see where lighting is concentrated. The more yellow a tile, the more lights are being processed in this area. No colored tiles mean no deffered light.
16x12 and 50x50 tiles

Image
Image

One can see that a "golden middle" has to be found in order to be successful with this tiling technique. 50x50 tiles already clearly decreases framerates.

Just to let you guys see that in Crysis 2 itself it does not make any sense, I uploaded a shot with the cVar specified above, from a usual C2 scene.
Image
The only tiles visible are blue and green, therefore only few lights intersect. Framerate is a little slower than without tiles (0.2 frames per second).

Even in "Terminal" deffered tiles do not make sense frameratewise!

So what is it good for?

Screen Space Tiled Deferred Shading/Lighting

Pros
- significant increase in framerate when dealing with hundreds of lights
- becomes even more relevant if lights overlap

Cons
- always some "ground up cost"
- with few lights rarely more efficient
- balancing the amount of tiles vs. amount of lights
- some visible changes in CryEngine (lights get brighter)

Conclusion:
Tiles are awesome sometimes but nothing special in other cases. It really depends on the game. If it features hundreds of lights in almost every scene, using tiles is highly recommended, but Crysis 2 for instance does not profit a lot from it.


Liked the read? Want more? Give me some feedback!
Want something to be featured? Say it!


Last edited by Thomy on 06.07.2011, 23:08, edited 4 times in total.
User avatar   Hardcore Modder Hardcore ModderMember since: 23.09.2009, 19:59Posts: 999 Likes: 29
 

 Post Topic: Re: CryEngine 3 Tech you might not know about [article serie
PostPosted 04.07.2011, 22:00 
great work. very indepth and with great visual backup and understandable for beginners. keep it up :)
User avatar   THE Shader Guy THE Shader GuyMember since: 11.09.2008, 21:08Posts: 3048Location: Frankfurt Likes: 47
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 04.07.2011, 22:11 
You shouldn't be measuring performance with FPS. FPS is unreliable, as it encompasses the entire frame time. You should use milliseconds instead.

For example:

60fps -> 50fps = 16ms -> 20ms
20fps -> 10fps = 50ms -> 100ms

You see the difference here? At 60fps, a 10fps drop is only 4ms. But at 20fps, a 10fps drop is quite literally dropping the speed in half. By measuring in milliseconds you can define the constant performance loss of an effect. A 4ms effect will be a 4ms effect regardless of the overall performance, whereas a 10fps effect varies dramatically based on the current framerate.

To use milliseconds, just set "r_displayInfo" to 2. :)


Also thanks a ton for theses posts, I can't use CE3 and have been wanting to explore the new effects. :) Great help.
User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 04.07.2011, 22:14 
You are right, should have done that.
I really was considering doing everthing with Milliseconds, but I thought it might be easier to understand to the greater audience with FPS.
Good idea, I'll do both in future


Last edited by Thomy on 11.03.2012, 03:01, edited 1 time in total.
  Uber Modder Uber ModderMember since: 17.06.2011, 10:49Posts: 1473Location: Germany Likes: 7
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 04.07.2011, 23:03 
thx it was a bit hard to understand :cheesy:

now "GI" pls :))


Intel Core i5-2500K
ASRock P67 Pro3
8 GB DDR3-1333
GTX560 2GB
Win7 x64
User avatar   THE Shader Guy THE Shader GuyMember since: 11.09.2008, 21:08Posts: 3048Location: Frankfurt Likes: 47
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 04.07.2011, 23:53 
Quote by Thomy:
I really was considering doing everthing with Milliseconds, but I thought it might be easier to understand to the greater audience with FPS.
Good idea, I'll do both in future


ooh ok. :)
  Has no life Has no lifeMember since: 27.10.2007, 20:48Posts: 15150Location: Nottingham, UK Likes: 0
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 11:48 
Really awesome series of articles, very interesting read! :)
User avatar   Has no life Has no lifeMember since: 11.07.2008, 20:25Posts: 11740Location: Nottingham, UKStatus: Online Likes: 89
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 12:24 
Once we've sorted out exactly how new content will go on the wiki, this is a stellar example of something that needs to be placed there. Great work! :)


Out now! CryENGINE Game Programming with C++, C#, and Lua
Ex-Crytek, now with Deep Silver Dambuster Studios
User avatar   Skilled Modder Skilled ModderMember since: 15.04.2008, 13:25Posts: 759Location: Russia, MoskowStatus: Online Likes: 34
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 13:05 
Useful research, thanks :)
User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 13:29 
I put up the next 2 on the next page, once that one is online
Thanks for those who replied though :)


Last edited by Thomy on 05.07.2011, 14:51, edited 2 times in total.
  Beginner BeginnerMember since: 02.07.2011, 02:58Posts: 49 Likes: 0
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 14:29 
It's only been 24 hours :)

Honestly, I'm guessing most people don't have much to say about it other than 'Thanks!'. Many wouldn't have the expertise to give constructive criticism on articles dealing with the more technical aspects of the engine (this includes me :P).
User avatar   Uber Modder Uber ModderMember since: 14.03.2008, 21:31Posts: 1760 Likes: 38
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 14:52 
The next articles will be useful for every Editoruser, if expert or not, who wants to beautify their scenes.
User avatar   Superstar Dolphin Superstar DolphinMember since: 16.08.2004, 10:46Posts: 9879Location: Finland Likes: 185
 

 Post Topic: Re: CE 3 Tech you might not know about [article series] - Pa
PostPosted 05.07.2011, 20:37 
This is a great article, I consider myself a render tech junkie (especially when dealing with Cryengine) but even for me there was some new info about SSDO, and I actually didn't know anything about the tiled lighting. Great work, I will enjoy reading your next articles! :)