{"id":13635027,"url":"https://github.com/dps/rust-raytracer","last_synced_at":"2025-07-21T10:08:00.688Z","repository":{"id":41962853,"uuid":"441230211","full_name":"dps/rust-raytracer","owner":"dps","description":"🔭 A simple ray tracer in Rust 🦀","archived":false,"fork":false,"pushed_at":"2022-01-05T04:12:50.000Z","size":74360,"stargazers_count":246,"open_issues_count":0,"forks_count":19,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T11:11:08.680Z","etag":null,"topics":["raytracing","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dps.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}},"created_at":"2021-12-23T16:01:33.000Z","updated_at":"2025-04-03T12:12:20.000Z","dependencies_parsed_at":"2022-07-07T21:44:22.882Z","dependency_job_id":null,"html_url":"https://github.com/dps/rust-raytracer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dps/rust-raytracer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dps%2Frust-raytracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dps%2Frust-raytracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dps%2Frust-raytracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dps%2Frust-raytracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dps","download_url":"https://codeload.github.com/dps/rust-raytracer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dps%2Frust-raytracer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266278418,"owners_count":23904045,"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":["raytracing","rust"],"created_at":"2024-08-02T00:00:39.317Z","updated_at":"2025-07-21T10:08:00.668Z","avatar_url":"https://github.com/dps.png","language":"Rust","readme":"# rust-raytracer\n\nAn implementation of a very simple raytracer based on [Ray Tracing in One Weekend\n by Peter Shirley](https://raytracing.github.io/books/RayTracingInOneWeekend.html) in Rust. I used this project to *learn* Rust from scratch - the code may not be perfectly idiomatic, or even good, but it does make pretty pictures.\n\nAdditional features beyond Shirley's course:\n* Texture mapping (e.g. earth and moon textures below)\n* Lighting\n* Parallel rendering - will use all CPU cores for best performance\n* Read scene data from JSON file\n* Render a sky texture\n\n## Example output\n![Latest output](raytracer/output/cover.png)\n\nhttps://user-images.githubusercontent.com/237355/147687883-4e9ca4fc-7c3b-4adb-85d7-6b08d1bc69f7.mp4\n\n## Example usage\n```\n$ cargo build --release\n   Compiling raytracer v0.1.0 (/Users/dps/proj/rust-raytracer/raytracer)\n    Finished release [optimized] target(s) in 2.57s\n\n$ ./target/release/raytracer data/test_scene.json out.png\n\nRendering out.png\nFrame time: 2840ms\n\n$ ./target/release/raytracer data/cover_scene.json cover.png\n\nRendering cover.png\nFrame time: 27146ms\n```\n\n### Texture mapping\n![cover_alt](https://user-images.githubusercontent.com/237355/147840674-38dd846f-1d4d-40a8-a573-e626a454f55a.png)\n\n### Lighting\n![lighting-recast-final](https://user-images.githubusercontent.com/237355/147840677-8e895fe5-1d25-428e-a847-6120af3ecfec.png)\n\n### Parallel rendering - will use all CPU cores for best performance\n\n#### Original\n```\n🚀 ./target/release/raytracer anim/frame\n   Compiling raytracer v0.1.0 (/Users/dps/proj/rust-raytracer/raytracer)\n    Finished release [optimized] target(s) in 2.21s\n\nRendering anim/frame_000.png\n............................................................\nFrame time: 21s\n```\n#### Using rayon\n```\nRendering anim/frame_000.png\nFrame time: 2573ms\n```\n### Render a sky texture\n![sky_textures](https://user-images.githubusercontent.com/237355/147840693-355a75da-a473-4c44-b712-842129450306.gif)\n\n### Read scene data from JSON file\n\n#### Example\n```\n{\n  \"width\": 800,\n  \"height\": 600,\n  \"samples_per_pixel\": 128,\n  \"max_depth\": 50,\n  \"sky\": {\n    \"texture\":\"data/beach.jpg\"\n  },\n  \"camera\": {\n    \"look_from\": { \"x\": -2.0, \"y\": 0.5, \"z\": 1.0 },\n    \"look_at\": { \"x\": 0.0, \"y\": 0.0, \"z\": -1.0 },\n    \"vup\": { \"x\": 0.0, \"y\": 1.0, \"z\": 0.0 },\n    \"vfov\": 50.0,\n    \"aspect\": 1.3333333333333333\n  },\n  \"objects\": [\n    {\n      \"center\": { \"x\": 0.0, \"y\": 0.0, \"z\": -1.0 },\n      \"radius\": 0.5,\n      \"material\": {\n        \"Texture\": {\n          \"albedo\": [\n            1.0,\n            1.0,\n            1.0\n          ],\n          \"pixels\": \"data/earth.jpg\",\n          \"width\": 2048,\n          \"height\": 1024,\n          \"h_offset\": 0.75\n        }\n      }\n    }\n  ]\n}\n```\n\n### Make animation\n```\n🚀 ffmpeg -f image2 -framerate 15 -i anim/frame_%03d.png -loop -0 anim.gif\n```\n\n### Credits\nEarth and moon textures from https://www.solarsystemscope.com/textures/\n\n### Extreme lighting example\n![147705264-c6f439df-f61b-4bcf-b5e6-c2c755b35b1c](https://user-images.githubusercontent.com/237355/147706272-7e35f213-914f-43dd-9b8b-4d3e7628cc19.png)\n\n### Progressive max_depth animation\n![max_depth_anim](https://user-images.githubusercontent.com/237355/148159509-aa492f3b-2805-45fe-94a6-3588fbf69bb2.gif)\n\n","funding_links":[],"categories":["Applications"],"sub_categories":["Graphics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdps%2Frust-raytracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdps%2Frust-raytracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdps%2Frust-raytracer/lists"}