top of page

Toybox

Graphics Programming - Tools Programming - Tech Art

Unity 2023.2

Personal Project

Toybox is a volumetric 3D modelling game inspired by Dreams. You can create a scene out of various types of shapes. You can chose whether each shape adds or subtracts from the scene, whether they affect the volume or color of the scene, and the order in which they are applied.

Download here

Source code here

Shape placement

The shapes available to you are cubes, cylinders, torus, sphere, and cone. You can place them, rotate them, and change various properties on them like their bounds, radius, etc.

You can chose whether a given shape affects the scene's surface, its color, or both.

Boolean Operation

You can control how shapes affect the rest of the scene.

Union operations will combine shapes together.

Subtraction will create a hole in the existing scene out of the shape you created.
Intersection will remove everything in the scene that is not inside of the shape.

All operations can be made to smoothly blend with the scene based on a given factor, allowing for more natural terrain, character shapes, etc.

Environment Settings

You can change various properties of the environment like the sun direction, color and intensity, ambient lighting color and intensity, shadow influence, etc.

How It Works

- A Toybox scene is defined as a list of objects each defined as a shape type, bool operation type, a set of bounds (which are generally interpreted as a scale and are sometimes unused) and a set of 2 custom values (often used for radius or length of round shapes).

- These shapes are then drawn as signed distance fields into a 256x256x256 voxel volume containing for each cell the distance to the closest surface to the scene, and the color of that cell.

- This volume is then drawn by a standard Unity shader using sphere tracing.

- This shader outputs all the standard unity shader passes usually used for geometry, like depth, normals, shadows, etc, allowing it to work with lights and post processing as any regular unity shader would.

- The shader uses unity's PBR shading functions, leaving open the possibility of giving PBR values to the shapes and making reflective surfaces (Currently unimplemented,  metallic is always 0 and roughness always 1)

bottom of page