dllu/chess-rtx

Vulkan hardware ray traced chess demo

1

stars

8

commits

Rust

primary language

Sep 4, 2026

updated

README

Chess RTX

image image

Chess RTX is a playable chess presentation built in Rust. The image is generated by a native Vulkan ray-tracing pipeline (VK_KHR_ray_tracing_pipeline); wgpu presents the image and egui provides the game and material controls.

The renderer uses the bundled high-detail, CC BY 4.0 Staunton meshes by Jeyhun1985 from Sketchfab and retains procedural pieces as an automatic fallback if those assets are unavailable. Piece and board shaders support ceramic, anisotropic metal, and frosted dielectric materials, with recursive reflections, refraction, soft ray-traced shadows, and a caustic contribution for transmissive pieces.

Requirements

  • Rust 1.88 or newer
  • Vulkan 1.2
  • VK_KHR_acceleration_structure and VK_KHR_ray_tracing_pipeline
  • A Vulkan ray-tracing GPU and current driver (the project defaults to the high-performance GPU)
  • CMake and a C++ compiler for the bundled shader compiler on the first build

Bundled Staunton assets

The repository includes all six optimized meshes in assets/staunton/; no separate download or Sketchfab account is required. Set CHESS_RTX_ASSET_DIR only if you want to use a different mesh directory.

The mesh adaptations remain licensed under CC BY 4.0 rather than the project's software license. See asset attribution for the artist, individual source links, license, and a description of the geometry adaptations.

2D board artwork

The interactive chess diagram uses Cburnett's standard 45×45 SVG chess-piece set from Wikimedia Commons. The vectors are rasterized at the display's native pixel size so they stay sharp on HiDPI screens. They are distributed under the BSD 3-Clause option offered by the original author; see 2D artwork attribution for sources, modifications, and the full license notice.

Run

cargo run --release

Click a piece and then a highlighted destination to move. Drag the render to orbit, use the wheel to zoom, and use the control panel to edit the light/dark pieces and board independently. The interactive renderer automatically selects 1–16 rays per pixel to keep each full-resolution pass near the display's measured refresh interval. Ray tracing and readback run on a background thread, so a long pass does not block input or the vsynced UI loop. Passes are accumulated in linear HDR space and tone-mapped only for display; adaptive sampling can be disabled in the Optics controls.

For an offscreen render that does not create a window:

cargo run --release -- --headless renders/opening.png \
  --width 1280 --height 800 --samples 4 --passes 256

Headless renders accept the same presets used by the UI, for example --light-style glass --dark-style ceramic --board-style metal. --passes averages independent progressive passes in linear HDR space for low-noise output.

Render an arbitrary position:

cargo run --release -- --headless position.png \
  --fen 'r1bq1rk1/ppp2ppp/2np1n2/8/2B1P3/2N2N2/PPPP1PPP/R1BQ1RK1 b - - 2 7'

Run the CPU-side tests with cargo test.

Controls

  • Left-drag the ray-traced view: orbit camera
  • Mouse wheel over the view: zoom
  • Chess diagram: select a piece, then a highlighted legal destination
  • New game: restore the standard position
  • Undo: restore the previous position
  • Save PNG: save the current frame in renders/
  • Adaptive sampling: target the display refresh interval with 1–16 full-resolution rays per pixel
  • Progressive accumulation: up to 65,536 passes, or continuous until paused
  • FEN field: paste a position and press Enter or Load FEN

Architecture

  • src/rt.rs: Vulkan device, BLAS/TLAS, shader binding table, ray dispatch, and readback
  • src/assets.rs: glTF import, mesh simplification, native asset format, and runtime asset loading
  • src/board_pieces.rs: embedded, resolution-independent artwork for the interactive 2D board
  • src/scene.rs: licensed-piece integration, procedural fallback meshes, and board scene
  • src/material.rs: editable GPU material and camera settings
  • src/chess_game.rs: legal move interaction backed by the chess move generator
  • src/app.rs: wgpu-backed egui application and refresh-rate sampling policy
  • src/render_worker.rs: coalescing background thread for Vulkan rendering and readback
  • shaders/: GLSL ray generation, closest-hit, and miss stages compiled to SPIR-V at build time

Contributors

dllu

8 commits

dllu/chess-rtx

Vulkan hardware ray traced chess demo

1

stars

8

commits

Rust

primary language

Sep 4, 2026

updated

README

Chess RTX

image image

Chess RTX is a playable chess presentation built in Rust. The image is generated by a native Vulkan ray-tracing pipeline (VK_KHR_ray_tracing_pipeline); wgpu presents the image and egui provides the game and material controls.

The renderer uses the bundled high-detail, CC BY 4.0 Staunton meshes by Jeyhun1985 from Sketchfab and retains procedural pieces as an automatic fallback if those assets are unavailable. Piece and board shaders support ceramic, anisotropic metal, and frosted dielectric materials, with recursive reflections, refraction, soft ray-traced shadows, and a caustic contribution for transmissive pieces.

Requirements

  • Rust 1.88 or newer
  • Vulkan 1.2
  • VK_KHR_acceleration_structure and VK_KHR_ray_tracing_pipeline
  • A Vulkan ray-tracing GPU and current driver (the project defaults to the high-performance GPU)
  • CMake and a C++ compiler for the bundled shader compiler on the first build

Bundled Staunton assets

The repository includes all six optimized meshes in assets/staunton/; no separate download or Sketchfab account is required. Set CHESS_RTX_ASSET_DIR only if you want to use a different mesh directory.

The mesh adaptations remain licensed under CC BY 4.0 rather than the project's software license. See asset attribution for the artist, individual source links, license, and a description of the geometry adaptations.

2D board artwork

The interactive chess diagram uses Cburnett's standard 45×45 SVG chess-piece set from Wikimedia Commons. The vectors are rasterized at the display's native pixel size so they stay sharp on HiDPI screens. They are distributed under the BSD 3-Clause option offered by the original author; see 2D artwork attribution for sources, modifications, and the full license notice.

Run

cargo run --release

Click a piece and then a highlighted destination to move. Drag the render to orbit, use the wheel to zoom, and use the control panel to edit the light/dark pieces and board independently. The interactive renderer automatically selects 1–16 rays per pixel to keep each full-resolution pass near the display's measured refresh interval. Ray tracing and readback run on a background thread, so a long pass does not block input or the vsynced UI loop. Passes are accumulated in linear HDR space and tone-mapped only for display; adaptive sampling can be disabled in the Optics controls.

For an offscreen render that does not create a window:

cargo run --release -- --headless renders/opening.png \
  --width 1280 --height 800 --samples 4 --passes 256

Headless renders accept the same presets used by the UI, for example --light-style glass --dark-style ceramic --board-style metal. --passes averages independent progressive passes in linear HDR space for low-noise output.

Render an arbitrary position:

cargo run --release -- --headless position.png \
  --fen 'r1bq1rk1/ppp2ppp/2np1n2/8/2B1P3/2N2N2/PPPP1PPP/R1BQ1RK1 b - - 2 7'

Run the CPU-side tests with cargo test.

Controls

  • Left-drag the ray-traced view: orbit camera
  • Mouse wheel over the view: zoom
  • Chess diagram: select a piece, then a highlighted legal destination
  • New game: restore the standard position
  • Undo: restore the previous position
  • Save PNG: save the current frame in renders/
  • Adaptive sampling: target the display refresh interval with 1–16 full-resolution rays per pixel
  • Progressive accumulation: up to 65,536 passes, or continuous until paused
  • FEN field: paste a position and press Enter or Load FEN

Architecture

  • src/rt.rs: Vulkan device, BLAS/TLAS, shader binding table, ray dispatch, and readback
  • src/assets.rs: glTF import, mesh simplification, native asset format, and runtime asset loading
  • src/board_pieces.rs: embedded, resolution-independent artwork for the interactive 2D board
  • src/scene.rs: licensed-piece integration, procedural fallback meshes, and board scene
  • src/material.rs: editable GPU material and camera settings
  • src/chess_game.rs: legal move interaction backed by the chess move generator
  • src/app.rs: wgpu-backed egui application and refresh-rate sampling policy
  • src/render_worker.rs: coalescing background thread for Vulkan rendering and readback
  • shaders/: GLSL ray generation, closest-hit, and miss stages compiled to SPIR-V at build time

Contributors

dllu

8 commits

Languages

Rust

94.6%

GLSL

5.4%