{"id":16956185,"url":"https://github.com/novara754/raytracer","last_synced_at":"2025-03-21T12:47:55.783Z","repository":{"id":217137321,"uuid":"743164400","full_name":"novara754/raytracer","owner":"novara754","description":"A multi-threaded CPU raytracer.","archived":false,"fork":false,"pushed_at":"2024-11-11T15:48:31.000Z","size":10691,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T09:13:02.495Z","etag":null,"topics":["computer-graphics","graphics","graphics-programming","multithreading","raytracer","raytracing","rendering","rust","rust-lang","simulation"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novara754.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-01-14T14:29:14.000Z","updated_at":"2024-11-11T15:48:35.000Z","dependencies_parsed_at":"2024-11-11T16:39:13.659Z","dependency_job_id":null,"html_url":"https://github.com/novara754/raytracer","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"3ca37cb0c8044ea423d00e4011110995eb4f5eec"},"previous_names":["novara754/raytracer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novara754%2Fraytracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novara754%2Fraytracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novara754%2Fraytracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novara754%2Fraytracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novara754","download_url":"https://codeload.github.com/novara754/raytracer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244801281,"owners_count":20512637,"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":["computer-graphics","graphics","graphics-programming","multithreading","raytracer","raytracing","rendering","rust","rust-lang","simulation"],"created_at":"2024-10-13T22:14:24.314Z","updated_at":"2025-03-21T12:47:55.762Z","avatar_url":"https://github.com/novara754.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raytracer\n\nMulti-threaded CPU raytracer implemented in Rust following\n[_Ray Tracing in One Weekend_](https://raytracing.github.io/books/RayTracingInOneWeekend.html).\n\n![Sample image of many different spheres with different materials rendered in HD](./sample.png)\n\n![Render of the Cornell box scene with an emissive quad as light source](./cornell.png)\n\n## Features\n - Multiple primitives\n   - Spheres\n   - Quads\n - Different materials\n   - Diffuse (Lambertion)\n   - Metal\n   - Glass (reflection \u0026 refraction)\n   - Emissive\n - Textures\n   - Solid colors\n   - Sampled by UV or world coordinates\n - Multisampling / Antialiasing\n - Defocus blur (depth of field)\n - Motion blur\n - Bounding Volume Hierarchies\n - Multithreading\n\n## Details\n\nThe scene in the above image rendered at 1920x1080 resolution in roughly 80 seconds on my machine\n(Ryzen R5 5600X CPU).\nEach pixel is the result of 200 samples, meaning 200 rays were sent into the scene and averaged\nto get the pixel color. Each ray got reflected and refracted a maximum of 50 times.\n\nThe scene contains many randomly generated spheres of different materials: diffuse, metal and glass.\n - The diffuse materials have a rather soft, non-reflective surface with given colours.\n - The metal sphere also have their own base colours but reflect light depending on their fuzziness.\n - The glass balls either reflect or refract the rays that hit them depending on the angle and random chance, however they do not have any intrinsic color.\n\nAdditionally there is a depth of field effect generated by randomly, slightly offsetting the\norigin of each ray slightly from the origin of the camera so that objects outside of the focal plane receive some blur. \n\nThe scene to be rendered is turned into a Bounding Volume Hierarchy to reduce the necessary computations.\nTo do that, the set of objects gets split in half over and over again based on their X, Y or Z\ncoordinate. This way when a ray gets sent into the world and needs to check if it hits any objects\nit can very quickly reduce the number of candidates.\nAt the highest level the set of objects is split into two groups. If the ray doesn't intersect\nthe bounding box of the first group that means that entire half of the set of objects can be discarded.\nIf one of the bounding volumes is intersected by the ray the children of that volume are considered.\nOnce again this means two groups are considered, each containing half of their parents set of objects.\nThis way the set of objects that need to be checked get halved at very step, allowing for very efficient\nintersection checks, as opposed to having to linearly search through a list for every single ray.\n\nBy default the raytracer will create a threadpool with on thread per CPU core. The pixels to be rendered\nare essentially submitted to this threadpool in a queue. This means N pixels can be calculated in parallel,\nwhere N is the number of CPU cores.\nThe number of threads can be changed by setting the `RAYON_NUM_THREADS` environment variable\nbefore running the program.\n\n## Usage\n\n\u003e [!TIP]\n\u003e A pre-built binary for 64-bit Windows can be found in the releases section on the GitHub page.\n\n\u003e [!NOTE]  \n\u003e To compile this project please install the [Rust compiler](https://rust-lang.org/).\n\nFor a debug build run `cargo build` in the project directory. For an optimized release\nbuild please run `cargo build --release`.\nThe resulting binaries will be located in `./target/debug` and `./target/release` respectively.\n\nIt is also possible to use `cargo run` or `cargo run --release` to compile and run the program in one step.\n\nIt is recommended to use the release build since it significantly speeds up the execution.\n\nThe raytracer accepts a few command line arguments to change the behaviour and to select the scene to render.\nThe following help output can be produced with `./raytracer_rs --help`:\n```\nUsage: raytracer_rs.exe [OPTIONS]\n\nOptions:\n  -o, --output-filename \u003cOUTPUT_FILENAME\u003e\n          Name of the output image [default: out.png]\n      --width \u003cWIDTH\u003e\n          Width of the output image [default: 1280]\n      --height \u003cHEIGHT\u003e\n          Height of the output image [default: 720]\n      --fov \u003cFOV\u003e\n          Vertical field of view [default: 20]\n      --focus-distance \u003cFOCUS_DISTANCE\u003e\n          Distance of the focal point from the camera [default: 10]\n      --defocus-angle \u003cDEFOCUS_ANGLE\u003e\n          Determines the strength of the depth of field effect [default: 0.6]\n      --samples \u003cSAMPLES\u003e\n          Number of samples (rays) per pixel [default: 100]\n      --max-bounces \u003cMAX_BOUNCES\u003e\n          Maximum amount of times a ray can get hit and bounce from objects [default: 50]\n      --scene \u003cSCENE\u003e\n          Selects which scenes to render [default: bouncing-spheres] [possible values: bouncing-spheres, checkered-spheres, earth, quads, simple-light, bouncing-spheres-with-light, empty-cornell-box, cornell-box]\n  -h, --help\n          Print help\n  -V, --version\n          Print version\n```\n\nTo replicate the sample image the following command was used:\n```\n.\\raytracer_rs -o sample.png -width 1920 -height 1080 --samples 200\n```\n\n## License\n\nLicensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovara754%2Fraytracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovara754%2Fraytracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovara754%2Fraytracer/lists"}