Port of the openGL spheres generation example.
| assets | ||
| shaders | ||
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| index.html | ||
| readme.md | ||
WGPU sandbox: Spheres
Type
Spheres as meshes come in different flavours, each trying to approch the unit sphere but subdivision can't and shouldn't be infinite.
Each have their own pros and cons:
- Isophere (UV sphere): generated from polar coordinates, easy baked-in resolution, rough precision
- TODO: Dual Isophere (UV sphere)
- TODO: Octahedral Sphere + dual
- TODO: Tetrahedreal Sphere + dual
- TODO: Ico: generated from an catmull-clark subdivided icosahedron, better coverage, vertex count increase fast, pentagon nodes
- TODO: Dual Icosphere
- TODO: Quad: best coverage, easy to generate
- TODO: Dual Quad
Files
- main.rs: entry point as app
- lib.rs: main winit/wasm loop, window/user events
- state.rs: gpu init: surface, config device, queue; update, render, react to input
- pipeline.rs: configure the pipeline "state": pipeline, buffers, bind groups
- vertex.rs: vertex struct, vertex buffer layout, examples
- texture.rs: texture utils: load, texture buffer descriptor, view, sampler
- world.rs: world: container for entities such camera or models
- camera.rs: simple orbital camera logic
- sphere.rs: spheres generation code, properties, buffers
- shaders
- assets
Desktop app is built in target directory, web app is built in pkg.
Usage
Input
- W/S: forward/backward
- A/D: rotate left/right
- 1: diffuse
2: blin phong- 3: difference to unit sphere
- 4: uv
- 5: normal
- 6: depth
- T: toggle wireframe (vulkan only)
Aim
- W/S: forward/backward
- A/D: strafe left/right
- Q/E: down / up
- 1: Isophere (UV)
- 2: Icosphere, Octahedral Sphere, Tetrahedreal Sphere
- 3: Quadsphere
- 5: Dual Isophere (UV)
- 6: Dual Icosphere
- 7: Dual Quadsphere
- Shift + 1: diffuse
- Shift + 2: blin phong
- Shift + 3: difference to unit sphere
- Shift + 4: normal
- Shift + 5: depth
- T: toggle wireframe (vulkan only)
Run on Dekstop
[RUST_LOG=<log_level>] cargo run
Run Web:
Compile wasm bindgen and pack wasm files:
wasm-pack build --target web
Host a local server to serve files (browsing locally isn't compatible with CORS rules)
python -m http.server -b 127.0.0.1