{"id":16113288,"url":"https://github.com/patryk27/sdf-playground","last_synced_at":"2025-03-18T09:31:17.275Z","repository":{"id":206694847,"uuid":"717490792","full_name":"Patryk27/sdf-playground","owner":"Patryk27","description":"Signed distance functions + Rust (CPU \u0026 GPU) = ❤️❤️","archived":false,"fork":false,"pushed_at":"2023-11-16T14:47:10.000Z","size":168,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-08T18:45:51.874Z","etag":null,"topics":["cpu","gpu","rust","sdf","shaders"],"latest_commit_sha":null,"homepage":"","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/Patryk27.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-11T16:27:59.000Z","updated_at":"2024-05-27T11:37:30.000Z","dependencies_parsed_at":"2023-11-16T09:26:40.745Z","dependency_job_id":"6702fddd-abaf-4096-805d-f8628a479536","html_url":"https://github.com/Patryk27/sdf-playground","commit_stats":null,"previous_names":["patryk27/sdf-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Fsdf-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Fsdf-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Fsdf-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Fsdf-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Patryk27","download_url":"https://codeload.github.com/Patryk27/sdf-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243911246,"owners_count":20367651,"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":["cpu","gpu","rust","sdf","shaders"],"created_at":"2024-10-09T20:10:49.621Z","updated_at":"2025-03-18T09:31:16.716Z","avatar_url":"https://github.com/Patryk27.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sdf-playground\n\nSigned distance functions + Rust (CPU \u0026 GPU) = ❤️❤️\n\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"512\" src=\"_readme/v3.jpg\" /\u003e\n\u003c/p\u003e\n\nPlatforms: Windows, Mac \u0026 Linux.\n\n## About\n\nsdf-playground is a demo showcasing how you can run Rust code on the GPU - it\nconsists of two parts:\n\n- the application (run on the CPU, inside `./app`),\n- the shader (run on the GPU, inside `./shader`).\n\nApplication is responsible for spawning the window and telling GPU to execute\nthe shader, while shader is the one which generates all the colors.\n\nShader here implements a ray-marcher for signed distance functions, but in\nprinciple it can be anything you want, e.g.:\n\n``` rust\n#[spirv(fragment)]\npub fn main_fs(out_color: \u0026mut Vec4) {\n    // out_color.x = R (0..1)\n    // out_color.y = G (0..1)\n    // out_color.z = B (0..1)\n    // out_color.w = alpha (technically 0..1, but actually unused here)\n\n    // Renders a yellow rectangle\n    *out_color = vec4(1.0, 1.0, 0.0, 1.0); \n}\n```\n\n## Usage\n\nAssuming you've got [Rust](https://rustup.rs/) installed:\n\n```\n$ git clone https://github.com/Patryk27/sdf-playground\n$ cargo run --release\n# (might take a few minutes the first time, but should be faster then)\n```\n\nNote that the code first builds the application, then starts it, and then builds\nthe shader - so for a few moments (until the shader is ready), the window will\nbe just pitch-black (you should be able to see the shader's compilation progress\nin the terminal, though).\n\nOn the upside, modifying the shader doesn't require restarting the application -\nsimply change `shader/src/lib.rs`, save it and wait a few seconds for the\napplication to refresh!\n\n## Caveat Emptor\n\nrust-gpu (the software that compiles your Rust code into a shader) doesn't \nsupport all features of the Rust language:\n\n- understandably, there's no standard library (no `std::fs`, no `vec![]` etc.),\n- there's no support for ADTs (no `enum Option\u003cT\u003e { Some(T), None }` etc.),\n- stick to `bool`, `u8`, `u32` and `f32` - other types (might) not work,\n- miscompilations are possible, though unlikely.\n\n## License\n\nMIT License\n\nCopyright (c) 2023 Patryk Wychowaniec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatryk27%2Fsdf-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatryk27%2Fsdf-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatryk27%2Fsdf-playground/lists"}