/wgpuEngine

WebGPU Engine

Primary LanguageC++MIT LicenseMIT

wgpuEngine

wgpuEngine is an open-source engine designed for creating desktop, XR (extended reality), and 3D web applications. Built on top of the newest graphics API WebGPU, it provides a cross-platform solution to render complex scenes, animations, and immersive experiences.

It uses Dawn, which provides WebGPU for desktop and web (via emscripten). We are still using a forked version until the official one adds XR support. For desktop XR it uses OpenXR.

Important

Web XR still not available until WebGPU and WebXR are integrated.

See Rooms for an example of how to use this engine.

Features

  • Web export (Still no XR enabled)
  • Flat screen + Desktop VR Rendering Supported
  • Supported platforms:
    • Windows
    • Web Chrome
    • Mac OS
  • Supported formats:
  • Rendering features:
    • XR Rendering
    • Physically Based Materials (PBR)
    • HDR + IBL Lighting
    • Instancing
    • Gaussian Splatting Renderer
  • Scene node management
  • Support for Rigid and Skeletal animations
  • UI Features:
    • 2D and 3D User Interface
    • 3D Text Rendering
    • 2D and 3D Gizmo (ImGuizmo for 2D)

Quick start

int main()
{
    Engine* engine = new Engine();

    Renderer* renderer = new Renderer();

    if (engine->initialize(renderer)) {
        return 1;
    }

    engine->start_loop();

    engine->clean();

    delete engine;

    delete renderer;

    return 0;
}

To start creating your application, override the Engine class! You can also override the Renderer class to customize the render passes:

  • custom_pre_opaque_pass, custom_post_opaque_pass
  • custom_pre_transparent_pass, custom_post_transparent_pass
  • custom_pre_2d_pass, custom_post_2d_pass

Engine configuration

Customize engine parameters using sEngineConfiguration when calling Engine::initialize:

sEngineConfiguration engine_config = {
    .window_title = "Application",
};

if (engine->initialize(renderer, engine_config)) {
    return 1;
}

Renderer configuration

Customize also renderer parameters using sRendererConfiguration when instancing your renderer to modify WebGPU context parameters. E.g. required limits or features:

sRendererConfiguration render_config;

render_config.required_limits.limits.maxStorageBuffersPerShaderStage = 8;
render_config.required_limits.limits.maxComputeInvocationsPerWorkgroup = 1024;

Renderer* renderer = new Renderer(render_config);

How to build

You will need to install the following tools:

and clone the Github repository, also initializing the submodules:

git clone https://github.com/upf-gti/rooms.git
git submodule update --init --recursive

Desktop

mkdir build
cd build
cmake ..

Web

Download emscripten and follow the installation guide.

On Windows you may need to download ninja and include the folder in your PATH environment variable, then:

mkdir build-web
cd build-web
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .