{"id":17250649,"url":"https://github.com/statusfailed/wgpu-voxel-terrain","last_synced_at":"2025-06-11T23:34:47.218Z","repository":{"id":204901773,"uuid":"712903661","full_name":"statusfailed/wgpu-voxel-terrain","owner":"statusfailed","description":"A WebGPU demo for rendering voxels","archived":false,"fork":false,"pushed_at":"2023-11-01T12:52:18.000Z","size":2961,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T08:18:51.509Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statusfailed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-01T12:51:43.000Z","updated_at":"2023-11-01T12:53:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1bc5e79-e79e-4f03-a477-b8700a42473c","html_url":"https://github.com/statusfailed/wgpu-voxel-terrain","commit_stats":null,"previous_names":["statusfailed/wgpu-voxel-terrain"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fwgpu-voxel-terrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fwgpu-voxel-terrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fwgpu-voxel-terrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fwgpu-voxel-terrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statusfailed","download_url":"https://codeload.github.com/statusfailed/wgpu-voxel-terrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245605709,"owners_count":20643030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:49:14.673Z","updated_at":"2025-03-26T06:42:59.456Z","avatar_url":"https://github.com/statusfailed.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WGPU Voxel Terrain\n\nVoxel terrain generated by a compute shader \u0026 then rendered with ambient\nocclusion on the GPU.\nRun with `cargo run` and use the WASD keys to zoom and rotate the camera:\n\n![demo](./render.webp)\n\nThis is just a project to learn WGPU; it's not very useful, and the code could\ndo with a tidy!\n\n# Overview\n\nHere's roughly what this program does:\n\n- Every frame, a [compute shader](./src/compute.wgsl) generates terrain as a giant array of voxels\n- Voxels are culled by checking if they have all opaque neighbours\n- Voxel data is used as the vertex buffer in the [vertex shader](./src/shader.wgsl)\n- Render pass uses `DrawIndirect` to render voxels\n    - `vertex_count: 36` sets 36 vertices per voxel, corresponding to the\n      `6*2*3` vertices needed to make a cube from triangles\n    - The number of visible voxels changes dynamically after culling, so it gets\n      calculated and passed to the DrawIndirect call on each frame as\n      `instance_count`.\n- Fragment shader computes locations of each vertex by adding the triangle\n  vertex offsets (stored as a constant array `TRI_VERTICES`) to the base voxel\n  coords\n- Final shading and ambient occlusion is calculated in `vs_main` of the vertex\n  shader.\n\n# Acknowledgements\n\nVery helpful sources for learning:\n\n- the [learn WGPU tutorial](https://sotrh.github.io/learn-wgpu/)\n- gfx-rs [wgpu](https://github.com/gfx-rs/wgpu) (see examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fwgpu-voxel-terrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatusfailed%2Fwgpu-voxel-terrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fwgpu-voxel-terrain/lists"}