Skip to content

jamesminardi/webgpu-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebGPU C++ Terrain Renderer

Warning

Work in Progress Building to web currently unsupported.

About

This is a WIP in-depth exploration of terrain generation that I am developing in C++ using the WebGPU graphics API.

Roadmap / Topics

  1. Camera Controller (zoom, click to drag, etc.) ✅
  2. Dev GUI ✅
  3. Generate plane meshes of configurable sizes ✅
  4. Adjust mesh using noise as a heightmap
  5. Explore Value, Perlin, Simplex, and Cubic noise varieties. ✅
  6. Sample multiple noises at once (Fractional Brownian Motion) ✅
  7. Adjust noises individually including scale, amplitude, etc.
  8. Color map the terrain based on height, steepness, etc.
  9. Dynamically load and unload chunks of terrain
  10. Dynamically adjust level of detail a quadtree, clip maps, etc.
  11. Cull the terrain using frustum and occlusionS
  12. Post-processing effects, atmosphere, lighting, skybox, etc.
  13. Vegetation
  14. Water

Dependencies

  • GLFW: Window creation
  • GLFW3 WebGPU: Wrapper for GLFW to support cross-platform WebGPU
  • WEBGPU: WebGPU distribution
    • WGPU-Native: Native interface to wgpu Rust library developed for Firefox
    • Dawn: Google's WebGPU implementation developed for Chrome in C++
  • WebGPU-Cpp: WebGPU C++ Wrapper
  • ImGui: Lightweight dev gui
  • GLM: Math library
  • STB: Lightweight image loading/saving (Included)

All of these are available through git submodules. Instructions are below.


Setup

Build Requirements

  • cmake: 3.20+
  • a modern C++20 compiler: todo update versions:(gcc-8, clang-6.0, MSVC 2017 or above)
  • Emscripten: (Required for building to web)

Note

On Windows I was unable to build and run using any build system except MSVC. MinGW and Cygwin could not track some specific Windows SDK headers (e.g. DirectX Compiler) among other issues. WSL is also unsupported as far as I can tell as well. YMMV


Build via Command-Line

  • Clone this project using git.

  • From the root of this project update all the submodules with git submodule update --init --recursive.

  • Follow the command-line instructions below:

    cmake . -B build ${OPTIONS}
    cmake --build build
    

${OPTIONS}

Use -G ${GENERATOR} to use a specific build system (e.g. "Unix Makefiles", "Visual Studio 17 2022", etc.).

Use -D WEBGPU_BACKEND=${BACKEND} to use a specific WebGPU platform (e.g. DAWN or WGPU). Defaults to WGPU.

Run

Execute either ./build/app (linux/macOS/MinGW) or build/Debug/app.exe (MSVC).


Build via CMake Compatible IDE (CLion)

  • Clone this project using git.
  • From the root of this project update all the submodules with git submodule update --init --recursive
  • Open the project in an editor that directly supports CMAKE files.

Within Build, Execution, Deployment -> Toolchains, drag Visual Studio to the top of the list to make it the default option.

readme_toolchains.png

Next, navigate to Build, Execution, Deployment -> CMake, selecting your corresponding toolchain and generator. Append to the CMake options: field: -D WEBGPU_BACKEND=${BACKEND} where ${BACKEND} is either WGPU or DAWN.

Tip

A second CMake profile may be created to build to both platforms.

readme_cmake.png

Reload your CMake project.


Project Structure

  • build: Generated build files and binary application.
  • data: Screenshots and other data.
  • docs: Personal notes,documentation, and examples.
  • external: External dependencies (e.g. git submodules).
  • resources: Project resources such as textures, sounds, music, etc.
  • src: Source code