$ show jinleili/learn-wgpu-zh
This repository is a Chinese-language translation and expansion of the Learn wgpu tutorial series, teaching the wgpu Rust implementation of the WebGPU graphics API through a Cargo workspace of ~25 runnable example crates. The curriculum progresses from window/surface setup (tutorial1-2), render pipelines and buffers (tutorial3-4), textures/uniforms/instancing/depth (tutorial5-8), through OBJ model loading, Blinn-Phong lighting, normal mapping, camera control, compute-shader terrain generation, HDR rendering, and particle systems. Each example is a small but complete winit application that runs natively and as WebAssembly via wasm-bindgen, sharing a common utils crate that provides the WgpuAppAction lifecycle trait, node-based render abstractions (ViewNode, ComputeNode, BufferlessFullscreenNode), and buffer/bind-group helpers. A VitePress documentation site embeds live WASM demos of the examples, and showcase crates demonstrate a Pong game, offscreen GIF encoding, multithreaded model loading, and compute-shader tangent generation. Although primarily a tutorial codebase, it is genuinely hybrid: it doubles as a deployable documentation site and a reference implementation of modern wgpu patterns.
The LLM identified 6 files worth highlighting for reuse:
Defines the WgpuAppAction trait and a winit event-loop driver (WgpuAppHandler) that normalizes async init, resize handling (including the wasm startup sizing quirk where no resize event fires), input events, and render dispatch across every example. A clean, self-contained app harness that can seed a new wgpu project for both native and wasm targets with minimal modification.
Encapsulates a GPU buffer pre-filled with per-frame animation data and a dynamic-uniform-offset bind group, a memory-efficient pattern for passing per-object or per-frame data without recreating or rebinding buffers. Extraction requires only the wgpu crate and is directly applicable to particle systems, skeletal animation, or per-instance time-varying uniforms.
A render-node abstraction that draws a fullscreen triangle strip without any vertex buffer by generating positions in the vertex shader. Reusable as-is for tone mapping, HDR presentation blits, Gaussian blur, and any post-processing pass; the pattern is decoupled from scene logic and demonstrates a non-obvious wgpu optimization.
Implements a complete HDR pipeline: offscreen 16F color target, ACES-style tone mapping in WGSL, and a final presentation pass, plus equirectangular-to-cubemap environment conversion for skyboxes and image-based reflections. A strong reference implementation that can be lifted into any wgpu renderer needing HDR output.
Generates heightfield terrain entirely on the GPU with a compute shader using FBM simplex noise, writing vertex/index data directly to storage buffers within a chunk-based abstraction. A reusable template for GPU-driven procedural mesh generation that avoids CPU round-trips and demonstrates storage-buffer vertex feeding.
Renders frames to an offscreen surface and reads the completed framebuffer back to CPU memory using the map/poll/copy sequence, then encodes the frames as a GIF. Demonstrates the GPU-to-CPU readback pattern required for screenshots, video capture, or extracting analytical data from a wgpu context.