|
Untitled
|
Table of Contents
This is the documentation for an Untitled game engine.
This is large engine featuring many systems, and therefore it makes sense that we should outline an overview of how it all connects.
Untitled has a focus on optimized gpu-driven forward rendering. However, the things that make it stand out are likely not its renderer.
Some technology in Untitled has been developed from scratch in a unique way: the path traced AudioProbes, the src/physics system, and the Skeleton simulations.
Untitled tries to abstract very little when it is not necessary. Most systems are low level, fast, and are going to stay that way.
The intention was never to make a "commercial" engine, but one that reflects my peculiar sensibilities and interests as a programmer and artist.
For further information on this project: Youtube (Devlogs and Streams) | Github | Website (Blogs)
AudioProbes are baked offline into OBB ProbeVolumes. They are baked using a path tracer. These are saved to binary and streamed into slots based on player position, APVs. These store an IR, which is composed of early reflections and late reverb. Early reflections use the raw samples from the rays. To reduce noise, late reverb is estimated by computing an RT60 via Schroeder integration, generating a Synthetic IR. During runtime, a background thread interpolates nearby probes and then rotates and convolves their IR samples with an HRTF of a human head. Then, that is partitioned and sent to the audio thread which convolves it with the current audio stream. This simulates real space.
PhysicsComponents are assigned to Entities, initialized with dimensions and parameters, and then processed per frame. Depending on center of mass, mu, restitution, and mass, they behave differently. Each frame, these components are updated with gravity and their velocities are calculated and a position is proposed. That position is run through acceleration structures (BVH) to find possible collisions. The CollisionType indicates if triangles (MeshFaces), ConvexHulls, or a capsule is used for detection. If possible collisions are found, Manifolds are created that describe the penetration using CollisionPoints. Then, valid Manifolds are iterated through and impulses are resolved between the two bodies. Finally, position and velocity are integrated, and unnecessary CollisionPoints are removed if they separate.
When a Mesh is loaded into the engine, it is either a specified static or dynamic Mesh. If it is static, it must be prepared for possible lightmap baking. Therefore, it generates a triangle BVH and adjacency map over each triangle inside of it. If it is dynamic, incremental hull is run to create ConvexHulls out of it. Then, coplanar faces are combined to create HullFaces that are used during Manifold clipping.
Real-time lighting in Untitled is standard clustered forward shading with Lights that behave differently based on LightType. Baked lighting in Untitled is handled through the path-traced UV lightmap, path-traced ProbeVolumes, and ReflectionProbes. Before baking lighting, a LightBVH must be built over all Lights and emissive triangles in a scene (which become AREA_LIGHTS). This is used for importance sampling during the bake, so we know what lights to sample from which position. To bake a UV lightmap, we must generate an atlas of texels that we will render to, which means we also need to UV unwrap each static face that will appear on that atlas. Once we do that, we rasterize IDs and positions to a texture based on those dimensions. Then, we run compute passes over each texel and path trace through the scene over and over again until we process a certain amount of samples. Then, the lightmap is dilated and denoised. To bake a ProbeVolume, the OBB is set up to a certain position and each individual probe within it (set to a standard LPV_COUNT) is baked similarly to a texel, but with a uniform ray distribution. ReflectionProbes are baked in a cubemap and uses the same rendering loop as the standard renderer, defined as render_to_cubemap_face().
While Untitled uses Nuklear for the majority of its Editor UI, it has the capability to create its own UIElements and render its own TextBoxes. Both are initialized inside of UIMenus, which also store UIContainers that are tied to UIElements and can hold references to other UIElements and TextBoxes. These links are used for scrolling and can mask when UIElements or TextBoxes scroll out of a UIContainer. On interaction, uninteraction, hover, or unhover, UIElements can trigger functions that are held in a registry. To render the UIElements and TextBoxes, they are pushed into SSBOs and instanced. Currently, UIElements are SDF only and TextBoxes are MSDF.
In Untitled, the player has a Skeleton, but other Skeletons can be created as well. A Skeleton has two LegIKs, a pelvis Spring, and a neck Spring. Each frame, leg positions are updated based on where the leg target is intended based on input direction and world geometry. Then, the pelvis Spring is solved based on the leg positions. The neck Spring is solved based on the new position of that pelvis Spring. Then, the neck position is used for the camera. This simulates real movement and feels human-like.
The editor UI in Untitled was created to modify almost every parameter and structure. Its most notable feature is the Undo system that makes nearly every action undo-able and redo-able. This uses byte offsets and byte buffers that are copied into structures specified by IDs that are pushed with the Undo, and exists inside of a doubly linked list with a modifiable memory cap.
Most of the folders should be self-explanatory. However, specific important files should be noted.