Lecture 006

Creating the Atmospheric World of Red Dead Redemption 2: A Complete and Integrated Solution

Creating the Atmospheric World of Red Dead Redemption 2: A Complete and Integrated Solution

Terrains

Heigh Field

Hight field: apply material and normal map on a single mesh. It is still the dominant way to generate terrain.

Binary Tree Subdivision

Hight Field with Adaptive Mesh Tesselation. We can force the density of mesh fits the screen resolution.

Hight Field with Adaptive Mesh Tesselation. We can force the density of mesh fits the screen resolution.

To use Adaptive Mesh Tesselation, we edit the original mesh

Triangle-Based Subdivision: subdivide triangles by dividing triangle into two small ones. This will result to binary tree

Triangle-Based Subdivision: subdivide triangles by dividing triangle into two small ones. This will result to binary tree

T-Junction

T-Junction

However, when we sub-divide the above two triangle by adding line ED, observe that shape AEBC is no longer a triangle. To solve this problem, it is typical to split the shape into AEB and ABC as two triangle. The resulting graph is as follow:

T-junction Error

T-junction Error

Due to floating point error, the small triangle can be rendered in overlap with the bigger triangle, causing either pixel to be drawn twice or never drawn. This might not seem as bad, but it can cause problems with transparency or stencil operations.

The reason for floating point error to be significant: The triangle location (converted from floating point) on screen space is discrete as screen-space triangle is stored in (X, Y) integer pair. If floating points were used, triangle set-up can be inaccurate for long-thin triangles. For more, read stackoverflow

A popular method is to force split triangle in the following manner to avoid T-Junction:

Force Split Triangle to Avoid T-Junction

Force Split Triangle to Avoid T-Junction

The performance of binary tree subdivision is good. However, it is unintuitive to construct and hard for resource management. Therefore a more popular method is quad-tree based subdivision.

Quad Tree Subdivision

Quad Tree Subdivision

Quad Tree Subdivision

For Example:

Note that this method is not based on triangle, rather on squares as we can easily apply texture in this manner since textures are always stored in square, not triangles.

Resource Management in Quad Tree Subdivision

Resource Management in Quad Tree Subdivision

Similar to Binary Tree Subdivision, Quad Tree Subdivision will also generate T-Junction, we "stich" it by edit the topology of the graph:

Sticking Quad Tree to Avoid T-Junction

Sticking Quad Tree to Avoid T-Junction

In above example, we used a triangle of 0 size, this is commonly called degenerate triangle. The graphics pipeline will avoid drawing triangle of 0 size.

Mesh Simplification

GDC 2021: The terrain of Call of Duty

GDC 2021: The terrain of Call of Duty

Another method is to pre-process mesh to avoid drawing more triangles than needed on flat surfaces. This technique can only be used in very flat surfaces, and therefore every little game actually use it.

GPU-based Tesselation

GPU-based Tesselation

GPU-based Tesselation

GPU can dynamically calculate subdivision rules at rendering-time.

DirectX11 GPU Tesselation Pipeline

DirectX11 GPU Tesselation Pipeline

Hull Shader: transform input mesh into control points and tells tesselation how many subdivision is needed.

Tesselator: tesselate given mesh

Domain Shader: move vertex point based on height map

Geometry Shader Pipeline: Hull Shader, Tesselator, Domain Shader

Geometry Shader Pipeline: Hull Shader, Tesselator, Domain Shader

However, this hardware-based Geometry Shader is not ideal, new DirectX12 or above (Win10 or above) support Mesh Shader Pipeline

Mesh Shader Pipeline: software manipulate tesselation

Mesh Shader Pipeline: software manipulate tesselation

Since GPU-based rendering-time tesselation dirrect berried within redering pipeline allow us to transform geometry in real time.

Realtime deformable terrain

Realtime deformable terrain

Deformable terrain for snow ground is easier than, for example, big cannonball holes in war-related games because it does not interfere with physics. Cannonball holes require updates to physics.

Non-Heightfield Terrain

Traditionally, caves and other non-flat topology is accomplished by inserting mesh into heightfield terrain.

Tunnels in Heightfield Terrain

Creating Tunnel in Heightfield Terrain

Creating Tunnel in Heightfield Terrain

Other methods involving marking vertex position as NaN, in which the vertex will be disconnected from other vertex in tesselation step. Using this, we can create holes in heightfield terrain. Artists then use object to patch the hole for desired outcome.

Volumetric Representation

Volumetric Representation of Terrain

Volumetric Representation of Terrain

The volumetric representation is consists of a set of occupancy points in 3D space and then interpreted by marching cude.

Marching Cube: a popular algorithm in visualizing CT scans and 3D density field

Marching Cube: a popular algorithm in visualizing CT scans and 3D density field

Interestingly, marching cube is also used in reconstruction of Visible Human Project

There are also related solution to adjusting LOD of volumetric marching cube.

Transition Cell Lookup Table

Transition Cell Lookup Table

Texture of Terrain

Common Problem with Texture Blending

Common Problem with Texture Blending

The blend is too smooth and does not obey physics.

The solution is to use height field.

Texture Blending with Height Field

Texture Blending with Height Field

The above solution generates high frequency signal that might cause problem. We add some transparency near the boundary.

Texture Blending with Height Field with Bias

Texture Blending with Height Field with Bias

In practice, textures are loaded in an array (of hundreds of elements) for fast sampling and alpha interpolation.

Parallax Mapping produces similar effect as Displacement Mapping

Parallax Mapping produces similar effect as Displacement Mapping

Virtual Texture

Sparse/Streaming Virtual Texture (SVT): store all baked texture map on drive. We load the texture of the whole world tile by tile of the same size.

Mipmap Streaming: store mipmap level and load level by level.

Procedural Virtual Texture (PVT): a balance between Procedural Splatting and SVT. It pre-calculate texture baking on the run.

Adaptive Virtual Texture (AVT): instead of loading tile by tile, we dynamically calculate the area we should load the texture based on view direction.

Camera Relative Rendering

Instead of rendering using world coordinate, it is suggested to use camera coordinate as the floating point precision near the camera is greatest. Therefore, only far-away object will have inaccuracy due to floating point precision error.

Dense Rendering

Speedtree: real geometry -> planes -> similar billboard

Speedtree: real geometry -> planes -> similar billboard

Decorator Rendering

Decorator Rendering

Road and Decal

Road and Decal

Road: provide artists with to to edit road and change heightfield accordingly Decal: decal baked onto virtual texture. Therefore such mix is happening at bake time, not run time.

Atmosphere

Analytical Solution to Atmosphere Rendering

Analytical Solution to Atmosphere Rendering

The above calculation is easy but it is not adjustable to different weathers and only restricted to ground-view.

Participating Media

Participating Media

In reality, light will bounce depending on the composition of different participating media.

Four Interaction with Participating Media

Four Interaction with Participating Media

Radiative Transfer Equation (RTE): a 3D function involving Laplace that incorporates 4 (or 3 if without emission) interactions

If we integrate above formula, we get the volume rendering equation:

Volume Rendering Equation (VRE)

Volume Rendering Equation (VRE)

Scattering

Rayleigh Scattering Distribution

Rayleigh Scattering Distribution

Rayleigh Scattering Equation: a close approximation (where klzzwxh:0038 is height and klzzwxh:0039 is wavelength)

Rayleigh Scattering Equation: a close approximation (where h is height and \lambda is wavelength)

Rayleigh Scattering: when light hit air particles (N_2, O_3, O_3) that is much smaller than the wavelength of radiation

Rayleigh Scattering Explains Why the Sky Is Blue

Rayleigh Scattering Explains Why the Sky Is Blue

Mie Scattering Distribution: a close approximation

Mie Scattering Distribution: a close approximation

Mie Scattering: when light hit aerosols (Dust, Sand) that is similar or larger than the wavelength of radiation

Mie Scattering explains fog and halo of the Sun.

Air Molecules Absorption:

Single Scattering vs Multi Scattering: the air particles isn't lit by nearby unseen particle in single scattering image

Single Scattering vs Multi Scattering: the air particles isn't lit by nearby unseen particle in single scattering image

Single Scattering: assuming particles are independent from each other

Multi Scattering: particles can light up each other

Pre-Compute Look Up Table

We pre-calculate atmospheric scattinging using ray marching and store it in a 2D map for fast look up.

A Transmittance Map parameterized by klzzwxh:0045 and klzzwxh:0046. We can calculate klzzwxh:0047 by looking up the table twice and do a division.

A Transmittance Map parameterized by \theta and X. We can calculate T by looking up the table twice and do a division.

Pre-compute Single Scattering LUT parameterized by 2 angles and 1 height

Pre-compute Single Scattering LUT parameterized by 2 angles and 1 height

And then we combine those to to do n-order scattering to generate a multi-scattering lookup table.

Multi-Scattering Lookup Table

Multi-Scattering Lookup Table

This produce the state-of-the-art effect.

Challenge:

Optimizing Lookup Cost

A Scalable and Production Ready Sky and Atmosphere Rendering Technique

Simplify Multi-scattering Assumption

Simplify Multi-scattering Assumption

Since scattering is homogeneous and uniform, we approximate scatting as percentage decay of the original light and sum them into a series to infinity.

We also reduce look up table by eliminating height h and the angle of the sun. What we get is a 2D map with 2 angles.

Simplify Scatting Look Up Table

Simplify Scatting Look Up Table

We generate a 3D LUT to evaluate aerial-perspective effects by ray marching

We generate a 3D LUT to evaluate aerial-perspective effects by ray marching

Clouds

Old way of doing clouds:

Now we do realtime volumetic rendering for clouds. We first generate a cloud map represent cloud coverage. We generate columns of cloud according to coverage and erose it using noise function to approximate fractals.

Procedural of Volumetic Cloud

Procedural of Volumetic Cloud

Raymarching Rendering

Raymarching Rendering

But then clouds not just receive light from the sun, but also from the sky.

For realtime, there is only two main methods: approximate and pre-compute.

Table of Content