ExperimEngine is a personal side project made to experiment (hence the name) with various tech pieces in order to make a tiny C++ game engine.
Along the way, I aim to learn many things such as 3D graphics with Vulkan, some shader fun, and to embed a scripting/modding language.
- Investigation for a scripting language
- Integration of an old-school CPU renderer made by a friend, as an application to test texture rendering
- Integration of Dear ImGui docking/viewports branch in the native Vulkan Renderer.
- Web-support : WebGPU renderer implementation and integration of Dear ImGui in the WebGPU renderer.
ExperimEngine will include an API for a second language both for scripting and modding. A common way of doing this is to embed a language into the host language (here C++), see embeddable_languages. In adddition to modding, this allow for quick iteration while working a on a game by reloading scripts at run-time instead of a slow C++ compilation. Both modding and scripting have similar needs : there needs to be a fast, easy to use and powerful C++ API.
Lua is the language considered for now but this may still change.
Classic embedded language in game engines. Pros :
- Blazing fast perfomances, thanks to LuaJIT
- Awesome C++ interop (with sol, although others exist)
- Open-source and light-weight
- Easy to embed
Cons :
- LuaJIT is not maintained (and quite complex) and is 32-bit only
- Lua's best performances come from the JIT but JIT compiling seems to be forbidden on apple devices
- Weird syntax, 1-indexed arrays, feels quite different from usual languages nowadays.
Wren is described as "Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax" Pros :
- Fast, without JIT
- Open-source and light-weight
- Easy to embed
- Modern syntax
Cons :
- C++ interop seems seems less advanced than sol in lua
- Quite a niche language (ecosystem, tooling, user-base)
I planned to :
- Host the .NET Core with the new 3.0 hosting API (see this document)
- Use Roslyn as a way to dynamically compile script files.
Scripting in C# could great but the main problem is to obtain a clean C#/C++(classes/objects) interop without resorting to Windows-only solutions. The C#/.NET ecosystem seems to be rapidly evolving with interop being taken into account.
Pros:
- I enjoy coding with C#
- Good tooling & ecosystem, huge user-base
- The C#/.NET ecosystem went open-source and seems to be rapidly evolving with interop being taken into account:
Cons :
- Not light-weight
- Hard to embed, hard to provide an egronomic & performant C++ interop
Mono is an open source implementation of Microsoft's .NET Framework, and provides a good embedding API but seems to be behind in terms of features and performances.
Elements to investigate :
- UnrealCLR for C++/C# in Unreal Engine.
- Compatibility with emscripten/webassembly ?
Embedding google's V8 and its C++ API or another JS engine (Mozilla's SpiderMonkey).
Pros :
- Gigantic eco-system, widespread language with good community support/tooling
- Good C++ interop (V8)
Cons :
- V8/SpiderMonkey are not light-weight
There are some lighter JS engine out there : Duktape, JerryScript and more, but I have yet to investigate the performance impact & C++ interop possibilities.
Libraries and languages are chosen with cross-platform as a focus point. As of today, there should be no major concern in targeting platforms such as Windows, Linux, MacOs, Android and more.
Right now, the build system is focused on Windows 64 bits only for practical reasons (read laziness, the current development environment is Wx64).
Idealy, an ExperimEngine app should be able to run on a web-browser.
Current state : Implementation of a separate WebGPU rendering backend
Technologies :
- Emscripten to compile C++ to WebAssembly.
- emscripten also provides support for the SLD2 API (already used as an OS abstraction in ExperimEngine).
- If OpenGL was a rendering target, emscripten could also be used to automatically convert it to WebGL.
- WebGPU, a modern API for GPU rendering on the web. It is pretty similar to (and relies on) APIs such as Metal, Vulkan and DirectX12, although a bit higher level, and with web safety in mind.
- As of today (06/12/2020) WebGPU is still in a really early stage and only available in experimentals features of some web-browsers, which does not seem like an issue : by the time I would be able to develop a back-end for it, it could be stabilized/mature enough.
- Supporting WebGPU and Vulkan would mean implementing/supporting 2 rendering backends in ExperimEngine (*)
(*) About supporting 2 backends :
As far as I understand, since WebGPU has Metal/Vulkan/DX12 implementations, it's in theory more portable than Vulkan. So I could get away with just a WebGPU backend and target pretty much the same platforms as Vulkan+WebGPU.
See projects like wgpu-rs (see also : wgpu & gfx-rs) for Rust or Dawn in C++.
I still intend to keep working on a separate Native Vulkan renderer for now. This may prove too heavy but I hope that WebGPU relying on Vulkan means that both backends would share a lot in term of workflow with WebGPU being the simplest.
Issues encountered :
- I was hoping to reuse the same glsl/spirv shaders used for Vulkan renderer in WebGPU. So far it is not the case since some Vulkan shaders use features not (yet?) available in WebGPU :
For now dependencies (windows 64bits) are packaged within the project in order to facilitate the environment setup on multiples machines.
Some of the dependencies may become git submodule.
Libraries are picked trying to respect as much as possible the following criterias :
- C/C++
- Cross-platform
- Light-weight & Performant
Vulkan:
- Vulkan - version
- Vulkan-Hpp (now included in Vulkan SDK). C++ API to Vulkan, and also used for dynamic dispatching.
- Vulkan Memory Allocator - version
Scripting:
Others:
- OpenGL Mathematics (GLM) - version
- Simple DirectMedia Layer (SDL2) - version
- Dear ImGui - Docking branch, version
- spdlog - version
- stb_image - version
- Bullet Physics
- Doxygen
- ENet, RakNet, GameNetworkingSockets (Valve)
- Sascha Willems Vulkan examples
- Vulkan tutorials
- Khronos Vulkan-Samples
- Awesome Vulkan
- Writing an efficient Vulkan renderer by Arseny Kapoulkine
- WebGPU cross platform demo by kainino0x
- ImGui WebGPU backend sample by bfierz
- GPU Gems, by NVIDIA
- LearnOpenGL
- Learning Modern 3D Graphics Programming, by Jason L.McKesson
- EDX course, Computer Graphics
MIT. See LICENSE