Diorama

Diorama is a game prototype made with Unity. Currently the prototype is in its infancy, and the primary focus is on the world visuals. An import mechanic of the game revolves around environmental variables such as humidity, temperature, and pollution. A great way to show these things to the user is through beautiful volumetric atmospherics.

The volumetric atmospherics are based on work by Bart Wronski and Sebastien Hillaire. I use compute shaders to generate and accumulate in scattered light within a 3D texture, and a post-processing shaders to accumulate out scattered light to the camera and merge the atmosphere with the rasterized terrain. 

Volumetric Rendering Technical Details

The majority of the volumetric rendering is very similar the Wronski’s work. Unlike Wronski and Hillaire’s work however, Diorama uses worldspace voxels to represent fog. Since the simulation is intended to run in a fixed size grid, this doesn’t cause a lot of the performance issues that screen space fog volumes fix. It also means that we don’t have to use any tricks to ensure fog is stable under movement.

I have currently restricted myself to using only the primary directional light for the complex volumetric lighting. With this in mind, I have developed a method of calculating in-scattered light for very low cost. Stealing a technique from computational fluid dynamics, I advect the light through the volume each frame, doing only one sample per volume voxel. This means light takes a few frames to propagate through the volume. Ultimately with a slow-moving volumetrics, the delay is unnoticeable, and the performance gains are well worth it.

The simulation is art direction based rather than physically based as this is both simpler, and leads to more flexible results. With art based direction we can get some very funky effects by messing around with the phase function, extinction coefficients, and ambient colors.

In order to get the fog running at a respectable FPS, texture sampling is heavily reduced and augmented with jittered sampling. Each frame, the initial raymarching point is offset by a random amount along the ray’s heading. This allows us to do up to 1/10th of the normal sampling per frame, while still maintaining decent visual quality. Temporal reprojection is used to smooth the result and provide a fairly stable visual.

Voxel Mesh Generation and Editor Tools

To make my life easier, I created a set of tools for creating and modifying our voxel diorama. The first image is a tool for creating new voxel blueprints, and the second is the editor for generating the voxel mesh.

 

The voxel generation creates a mesh per material. These materials come from the set of blocks specified in the second image above. The mesh generation culls internal faces, but is non greedy, i.e., it wont combine smaller coplanar quads into larger ones.

Below is a demonstration of the world editor.

This editor provides a basic visual interface for modifying the diorama. It includes various edit modes including a horizontal fill mode and a brush with a radius slider. The user can choose which voxel to place by pushing the image buttons. These buttons are automatically generated from the voxel grid settings (see previous image).

Additional Notes and References

The water shader seen in the above videos was created by me. It includes refraction, reflection, depth foam, ripples, and faked caustics.

Sebastien Hillaire’s presentation on unified volumetric can be found here:
https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite

Bart Wronski’s presentation can be found here:
https://bartwronski.com/publications/

Thanks to Alan Zucconi for his intro to raymarching:
https://www.alanzucconi.com/tutorials/

Textures from:
https://www.planetminecraft.com/texture_pack/256x-lokicraft-purecartoonpack-by-_loki_-010-mc18/