Atmospheric effects in the Cry engine

This is a summary report of the presentation that Crytek did at Siggraph 2006 in Boston. This concentrated on atmospheric effects used in the Cry Engine 2. Read more after the break.

Atmospheric Effets


The course was concentrated on atmospheric effects and not at all on the rest (no physic talk, no motion blur, no depth of field, lighting, shadows etc..). Were included in the atmospheric effects, the sky model, the global fog, the local fog (volumetric), the clouds, the smoke effects, the volumetric lights and the rivers.


Depth pass


All those effects rely on a first pass that fills a temporary buffer with the distance to the far plane. It isn't exactly the z-buffer, because the scale of a regular zbuffer is not the same and because the storage format is usually opaque and cannot be read directly from the pixel shader. This first pass only includes opaque objects, the translucent and semi transparent objects are a problem and will have to be treated separately. The texture format for this intermediate buffer is either a single component 32 bit float or a ARGB8 texture with a coding/decoding in the pixel shader.

Rendering of the sky


Unlike Far cry where the sky was painted into a skybox, in the next game the sky will be calculated in real time. Rather than calculating everything at a high resolution, some intermediate values are computed on the CPU and then the hw is used to interpolate and compute remaining values. The reason the CPU is used is because the model is rather complex and wouldn't be able to run on the minimum target platform (a shader model 2.0 machine). The d3d10 version will probably calculated entirely on the GPU (they said they expect it to perform well on a hw with a good dynamic branching performance).

Crysis atmospheric and sky rendering with god rays

The model that is used is a very simplified version of the one described by Nishita et al. The simplifications are that the sky is supposed to be at infinity and that the viewer is stuck on the ground. The fog and clouds are calculated separately, as the scattering model in the paper is considered way to complex for a real time result. The sun also is not included in the model. One of the problem was the low resolution the values were calculated that would provoke artifacts near the sun. It's much easier to add the solar disc later with some flare effect.


Global fog


Rather than use the hardware fog (that has disappeared anyway with shader model 3), the fog in Crysis will be added in a separate pass with a quad that covers the screen. The input of the pixel shader is the depth calculated during the first pass. With the X and Y from the screen and the depth retrieved from the texture it is so possible to find the original world coordinates that are under the current point. A rather simple formula taking into account distance to the eye and the height of the current point allows us to have a fog close to one that would exist in nature. The rendering of bed of rivers will benefit from an attenuation effect close to the one that is used for global fog.


Volumetric fog


The same way they draw the global fog, they can then add an arbitrary number of volumes of fog. Because everything is done in the shader, the only primitives that are allowed are mere boxes and ellipses (in order to simplify visibility calculation). This should be sufficient for a number of volumetric effect.


Clouds


The light of the sun that goes through a cloud generates a little bit of subsurface scattering. Rather than truly simulate that, the look is emulated with a map that contains the cloud thickness and the relative position to the solar disc is measured. The reference that was cited for the rendering of the clouds is Flight Simulator 2004 by Niniane Wang.


Soft particles


The smoke and the clouds are billboards as usual, but with a trick to avoid "hard edges" at intersection with the opaque objects.

They simply read the depth from the texture, substract that depth to the current depth of the sprite, then divide that value by a "thickness" property of each sprite. They clamp the result and this will give you "how much" of the current layer is visible given this particular thickness. This visibility factor between zero and one is modulated by alpha value and so the layer becomes thinner and more invisible when they come too close to an opaque object.


Problems


As there is no free lunch, their technique suffers from several problems. One of the problem of using a temporary texture to store depth and reading it back in screen space is that this doesn't work too well with antialiasing (as do all methods that rely on deferred shading currently). For example, if you have a strong fog, on the background and some light objects on the foreground, the border between the dark and light objects will look cut out as a badly done photoshop job. Maybe this will get better with D3D10 but it didn't sound like they had a solution for that.

Another problem is with translucent and semi transparent objects. Since the depth pass only stores one depth value per pixel, only opaque objects can be represented with this method. Objects that should be blended are then drawn separately with an estimation by object of the value of the fog at the current position. Of course that doesn't work too well if the object is too large and would covers a big range of different fog values. In practice they just ask the artists to collaborate and try to not place such objects in the levels.


High Dynamic Range


HDR rendering will be used on all platforms that support it. As a side note, one HDR video was encoded during Siggraph and played on the HDR display by Brightside on their booth. The HDR display was pretty impressive with very strong blacks and brighter highlights.

This was a summary from my notes of the Siggraph 2006. Note that the original presentation can now be downloaded from the AMD website here : Siggraph course PPT

Partner websites : LEGREG | GRAPHICS | GRAPHISME | PHOTOGRAPHY | OUT OF MY MIND | ANIMATION MENTOR | GREEN LIVING | VOXEL | RAY TRACING | GUENARDI