Car Demo

Hero graphic for Car Demo Live demo at aaserver.net/projects/cardemo3/

Overview

Vehicle dynamics simulation

Technical breakdown

Terrain rendering

The terrain is rendered using a technique called geometry clipmap. The terrain is split into nested rings of increasing size around the camera. Each ring has the same number of triangles meaning distant terrain is rendered using very few triangles per square meter compared to the terrain near the camera. The rings are displaced based on a high-resolution heightmap that spans the entire map (~1km²). World-normals are stored in a texture instead of being computed in the shader.
Aerial shot of the map Aerial shot of the map with level of detail highlighted
Rings of increasing size around the camera. Each ring is color a different color.

Grass and flowers

Foliage is prepared on the CPU as a uniformly spaced grid of instanced grass meshes (two planes in a cross formation). Each instance is displayed based on the same heightmap as the terrain. The instances are also randomly displaced in the xz-plane to hide the uniformity. The grid of instanced grass meshes follow the camera and are scaled down in the distance to smoothly fade out the grass.
Grass and flowers fade out in the distance
Grass and flowers.

Trees with LOD

Each tree model has two LODs (level of detail); a low-poly mesh for nearby trees and a billboard mesh for far-away trees. Bleding between LODs are achieved by using alpha dithering to cross fade between two levels. To reduce CPU time, only tree instances that need to be updated are iterated and updated each frame. This is achieved by storing the trees in a octree and querying the octree for trees inside a hollow cube (with inner and outer side length based on the cross fade distance).
Trees with two levels of details
Two different trees with two LODs each.

Water rendering

Everything in the scene is rendered to a color and depth texture. The water is rendered last and blends between blue and the scene color based on the scene depth. Foam is rendered where the depth is shallow enough and on the surface based on voronoi noise.
Car on beach with water
Water with waves and foam at the shoreline.

Screenshots

Screenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of projectScreenshot of project

Try it out for yourself!

Live demo at aaserver.net/projects/cardemo3/