Previous Parts in This Series
Windowing & Pipeline Architecture
Loading Custom Geometry & WGSL Shaders
Implementing a 3D Camera System & Hot-Reloading Shaders
Implementing Depth Buffering and a Post-Processing Pass
HDRI Environment Lighting & Dynamic Shadows
Before jumping into the final pieces, a quick reflection on building this series: I leaned heavily on AI assistance to help write the Rust and WebGPU boilerplate across these seven parts, and the biggest lesson I learned is that AI only works if you strictly own the architecture. Without a clear hierarchy and decoupled modules, generated code quickly turns into a tangled mess you can no longer read or debug by hand. Keeping a clean structure is what lets me move fast with AI while still understanding every piece of how the engine works.
Almost all the core rendering features are finally ready to use. In this final part of the template phase, I want to add the last—and most important—piece that turns a rendering demo into an actual usable tool: a data-driven scene system and a lightweight editor UI.
[1]. Data-Driven Scenes with JSON
To make the engine truly reusable across different projects, the engine binary itself shouldn't hardcode meshes, lights, or camera positions.
My plan is straightforward: use a JSON file to describe the entire scene.
Decoupled Assets: Lights, camera parameters, object transforms, and material attributes live as lightweight JSON data. Heavy 3D geometry files (.glb / .gltf / .obj) are referenced purely by file path links rather than baked into the engine.
Engine as a Functional App: By separating scene data from engine code, the compiled Rust binary acts as a standalone functional tool that loads any scene file on demand.
[2]. Why We Need an Editor UI (winit + egui)
If you want to load a JSON scene, you also need an easy way to edit and export one without hand-typing transforms and light coordinates in a text editor.
The cleanest solution is integrating an immediate-mode UI using winit + egui. Of course, adding a UI layer immediately increases architectural complexity. Even when working with AI assistance, having a strict, clear hierarchy is essential—otherwise, the codebase grows fast and you lose control over how systems talk to each other.
To keep everything manageable, I enforce strict separation of concerns across three layers:
- Rendering Modules: Core GPU systems (lighting, materials, environment, post-processing) stay isolated in their own dedicated modules.
- Scene Layer: Handles serializing, loading, and exporting the JSON scene graph and asset references.
- UI Layer (egui): Lives in its own module and simply reads/modifies scene state.
Keeping the GUI Layout Simple
For the interface itself, I am sticking to a classic, minimal 3-panel layout:
- Top Bar: Global actions (Load Scene, Export JSON, Play/Reset, View modes).
- Left Panel (Outliner): Scene hierarchy showing cameras, lights, and loaded meshes.
- Right Panel (Inspector / Attributes): Properties for whichever object is currently selected.
You can always expand an editor UI endlessly, but keeping the layout simple makes it fast to build and easy to maintain.
[3]. Architecture Review: Everything in Our Template
Before moving on to a real project, here is a complete review of the core components now wired together inside the engine template:
1, Window & Event Loop (winit): Cross-platform window creation, input handling, and frame lifecycle management.
2, Core GPU State Container:
Hardware & Swapchain: Surface, Device, Queue, Window, and main RenderPipeline + layout.
Camera System: View/projection matrices, uniform buffers, and interactive controls.
Depth & Shadows: Depth texture/view, shadow maps (textures, views, faces/arrays), and the dedicated shadow pipeline/layout.
Post-Processing: Offscreen bind groups, layouts, uniform buffers, and the full-screen post-processing pipeline.
Controllers: Dedicated modules for analytical lights, HDRI environment baking, and the egui integration.
3, Shaders (WGSL): Vertex shaders for mesh geometry and PBR fragment shaders for physically based shading.
4, Asset Loaders: Support for loading .obj and .glb / .gltf meshes into GPU vertex and index buffers.
5, Unified Analytical Lighting: 16-byte aligned GPU uniform buffers supporting Directional, Point, and Spot lights.
6, HDRI / Image-Based Lighting (IBL): Equirectangular-to-cubemap conversion, diffuse irradiance, prefiltered specular maps, and BRDF LUTs.
7, Scene Serialization & GUI: JSON scene import/export paired with the egui outliner and attribute inspector.
[4]. What’s Missing (Future Roadmap)
A reusable template doesn't need every advanced AAA feature on day one—it just needs a clean foundation you can extend when a real project demands it. A few systems I plan to add later as the engine evolves:
- Temporal & Denoising Passes: Expanding the post-processing stack with temporal anti-aliasing (TAA) and denoising filters.
- Advanced Rendering Architecture: Evolving the render pass scheduler (such as deferred rendering / G-Buffer passes or render-graph abstractions) as scene complexity scales.
- Hierarchy & Rigging Support: Adding a parent-child transform hierarchy and basic skeletal/rig support for animated characters and mechanical assemblies.
Wrapping Up the Template — And Starting the Next Build
With JSON scene loading, asset linking, and an egui inspector in place, the template phase is officially complete. Instead of endlessly tweaking an empty engine in isolation, it is time to freeze the core architecture and use it to build an actual project.
Thanks for reading! Check out my industrial Rust projects available on the Microsoft Store:
Download on the Microsoft Store
Download from Gumroad
