{"id":16440183,"url":"https://github.com/soypat/gsdf","last_synced_at":"2025-03-23T08:31:54.668Z","repository":{"id":252709259,"uuid":"841207270","full_name":"soypat/gsdf","owner":"soypat","description":"3D/2D CAD design package written in Go. GPU accelerated.","archived":false,"fork":false,"pushed_at":"2025-02-27T20:16:21.000Z","size":388,"stargazers_count":26,"open_issues_count":2,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-18T19:05:01.695Z","etag":null,"topics":["3d-printing","autocad","boolean-operations","cad","finite-element-method","go","golang","gpu","implicit-geometry","implicit-surfaces","mesh","sdf","signed-distance-field","signed-distance-functions","solid","stl"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soypat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-11T23:23:05.000Z","updated_at":"2025-03-03T01:39:52.000Z","dependencies_parsed_at":"2024-08-23T02:24:16.755Z","dependency_job_id":"219df37f-d60b-4ff8-b316-4348a850252d","html_url":"https://github.com/soypat/gsdf","commit_stats":null,"previous_names":["soypat/gsdf"],"tags_count":0,"template":false,"template_full_name":"soypat/go-module-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgsdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgsdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgsdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgsdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soypat","download_url":"https://codeload.github.com/soypat/gsdf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078067,"owners_count":20557274,"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":["3d-printing","autocad","boolean-operations","cad","finite-element-method","go","golang","gpu","implicit-geometry","implicit-surfaces","mesh","sdf","signed-distance-field","signed-distance-functions","solid","stl"],"created_at":"2024-10-11T09:11:22.854Z","updated_at":"2025-03-23T08:31:54.651Z","avatar_url":"https://github.com/soypat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gsdf\n\n[![go.dev reference](https://pkg.go.dev/badge/github.com/soypat/gsdf)](https://pkg.go.dev/github.com/soypat/gsdf)\n[![Go Report Card](https://goreportcard.com/badge/github.com/soypat/gsdf)](https://goreportcard.com/report/github.com/soypat/gsdf)\n[![codecov](https://codecov.io/gh/soypat/gsdf/branch/main/graph/badge.svg)](https://codecov.io/gh/soypat/gsdf)\n[![Go](https://github.com/soypat/gsdf/actions/workflows/go.yml/badge.svg)](https://github.com/soypat/gsdf/actions/workflows/go.yml)\n[![sourcegraph](https://sourcegraph.com/github.com/soypat/gsdf/-/badge.svg)](https://sourcegraph.com/github.com/soypat/gsdf?badge)\n\n`gsdf` is a CAD 3D design library for Go that uses SDFs for shape definition. Rendering can be done on GPU or CPU\nfor visualization or 3D printing file outputs. Quick jump to usage: [bolt example](./examples/bolt/main.go).\n\nAll images and shapes in readme were generated using this library.\n\n![bolt-example](https://github.com/user-attachments/assets/8da50871-2415-423f-beb3-0d78ad67c79e)\n![circle](https://github.com/user-attachments/assets/91c99f47-0c52-4cb1-83e7-452b03b69dff)\n![text](https://github.com/user-attachments/assets/73a90941-9279-449d-9f4d-3f2746af5dd5)\n\n## Requirements\n\n- [Go](https://go.dev/)\n- **Optional**: See latest requirements on [go-glfw](https://github.com/go-gl/glfw) if using GPU\n\n## Features\n\n- High test coverage (when GPU available, not the case in CI)\n\n- Extremely coherent API design.\n\n- UI for visualizing parts, rendered directly from shaders. See [UI example](./examples/ui-mandala) by running `go run ./examples/ui-mandala`\n\n- Generate visualization for your parts as shaders.\n\n- GPU and CPU implementations for all shapes and operations. CPU implementations are actually faster for simple parts.\n\n- Include arbitrary buffers into GPU calculation. See [`Shader` interface](./glbuild/glbuild.go).\n\n- Heapless algorithms for everything. No usage of GC in happy path.\n\n- Heapless Octree triangle renderer. Is stupid fast.\n    - Design your part using one API, switch between CPU and GPU after design.\n\n- TinyGo supported for CPU evaluation :)\n\n## Package layout/structure\n\n- `gsdf`: Top level package defines exact SDFs primitives and operations for use on CPU or GPU workloads. Consumes `glbuild` interfaces and logic to build shaders.\n- `glbuild`: Automatic shader generation interfaces and logic.\n- `gleval`: SDF evaluation interfaces and facilities, both CPU and GPU bound.\n- `glrender`: Triangle rendering logic which consumes gleval. STL generation.\n- `forge`: Engineering applications. Composed of subpackages.\n    - `textsdf` package for text generation.\n    - `threads` package for generating screw threads.\n- `gsdfaux`: High level helper functions to get users started up with `gsdf`. See [examples](./examples).\n\n\n# Examples\nFind examples under [examples](./examples/) directory. Run on GPU with: `-gpu` flag.\n\nMost 3D examples output two files:\n- `example-name.glsl`: Visualization shader that can be copy pasted into [shadertoy](https://www.shadertoy.com/new) to visualize the part, or rendered within your editor with an extension such as the [Shader Toy Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=stevensona.shader-toy).\n- `example-name.stl`: Triangle model file used in 3D printing software such as [Cura](https://ultimaker.com/software/ultimaker-cura/). Can be visualized online in sites such as [View STL](https://www.viewstl.com/).\n\n\nOutput and timings for\n- CPU: 12th Gen Intel i5-12400F (12) @ 4.400GHz\n- GPU: AMD ATI Radeon RX 6800\n\n## npt-flange - 9× GPU speedup\nThis was converted from the [original sdf library example](https://github.com/soypat/sdf/blob/main/examples/npt-flange/flange.go).\n\n#### GPU rendering in 1 second. 0.4M triangles\n```sh\ntime go run ./examples/npt-flange -resdiv 400 -gpu\nusing GPU       ᵍᵒᵗᵗᵃ ᵍᵒ ᶠᵃˢᵗ\ncompute invocation size  1024\ninstantiating evaluation SDF took 115.587024ms\nwrote nptflange.glsl in 97.829µs\nevaluated SDF 46148621 times and rendered 423852 triangles in 1.103100086s with 95.7 percent evaluations omitted\nwrote nptflange.stl in 710.038498ms\nfinished npt-flange example\ngo run ./examples/npt-flange -resdiv 400 -gpu  1,01s user 1,10s system 95% cpu 2,217 total\n```\n\n#### CPU rendering in 9 seconds. 0.4M triangles\n```sh\ntime go run ./examples/npt-flange -resdiv 400 \nusing CPU\ninstantiating evaluation SDF took 14.173µs\nwrote nptflange.glsl in 73.155µs\nevaluated SDF 46147934 times and rendered 423852 triangles in 8.482344469s with 95.7 percent evaluations omitted\nwrote nptflange.stl in 703.931017ms\nfinished npt-flange example\ngo run ./examples/npt-flange -resdiv 400  9,01s user 0,82s system 103% cpu 9,481 total\n```\n\n![npt-flange-example](https://github.com/user-attachments/assets/32a00926-0a1e-47f0-8b6c-dda940240265)\n\n\n### fibonacci-showerhead - 40× GPU speedup\n\nNote that the amount of triangles is very similar to the NPT flange example, but the speedup is much more notable due to the complexity of the part.\n\n#### GPU rendering in 0.87 seconds. 0.3M triangles\n```sh\ntime go run ./examples/fibonacci-showerhead -resdiv 350 -gpu\nusing GPU       ᵍᵒᵗᵗᵃ ᵍᵒ ᶠᵃˢᵗ\ncompute invocation size  1024\ninstantiating evaluation SDF took 108.241558ms\nwrote showerhead.glsl in 581.351µs\nevaluated SDF 14646305 times and rendered 309872 triangles in 768.731027ms with 89.08 percent evaluations omitted\nwrote showerhead.stl in 509.470328ms\nshowerhead example done\ngo run ./examples/fibonacci-showerhead -resdiv 350 -gpu  0,87s user 0,69s system 94% cpu 1,646 total\n```\n\n#### CPU rendering in 36 seconds. 0.3M triangles\n```sh\ntime go run ./examples/fibonacci-showerhead -resdiv 350 \nusing CPU\ninstantiating evaluation SDF took 27.757µs\nwrote showerhead.glsl in 507.155µs\nevaluated SDF 14645989 times and rendered 309872 triangles in 35.794768353s with 89.08 percent evaluations omitted\nwrote showerhead.stl in 499.13903ms\nSDF caching omitted 21.62 percent of 14645989 SDF evaluations\nshowerhead example done\ngo run ./examples/fibonacci-showerhead -resdiv 350  36,16s user 0,76s system 100% cpu 36,591 total\n```\n\n![fibonacci-showerhead](https://github.com/user-attachments/assets/a72c366c-6ee0-43ba-9128-087a76524ff9)\n\n## More examples\n\n![iso-screw](https://github.com/user-attachments/assets/6bc987b9-d522-42a4-89df-71a20c3ae7ff)\n![array-triangles](https://github.com/user-attachments/assets/6a479889-2836-464c-b8ea-82109a5aad13)\n![geb-book-cover](https://github.com/user-attachments/assets/a6727481-07f3-4636-8e1c-9b1a02bb108f)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoypat%2Fgsdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoypat%2Fgsdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoypat%2Fgsdf/lists"}