{"id":51428155,"url":"https://github.com/letv1nnn/ray-tracer","last_synced_at":"2026-07-05T02:30:28.912Z","repository":{"id":359112915,"uuid":"1188295406","full_name":"letv1nnn/ray-tracer","owner":"letv1nnn","description":"A small ray tracer implemented in C++.","archived":false,"fork":false,"pushed_at":"2026-05-20T12:03:01.000Z","size":1347,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-20T16:41:13.547Z","etag":null,"topics":["cpp","raytracer"],"latest_commit_sha":null,"homepage":"","language":"C++","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/letv1nnn.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-21T22:02:49.000Z","updated_at":"2026-05-20T12:03:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/letv1nnn/ray-tracer","commit_stats":null,"previous_names":["letv1nnn/ray-tracer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/letv1nnn/ray-tracer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letv1nnn%2Fray-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letv1nnn%2Fray-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letv1nnn%2Fray-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letv1nnn%2Fray-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letv1nnn","download_url":"https://codeload.github.com/letv1nnn/ray-tracer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letv1nnn%2Fray-tracer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35141966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp","raytracer"],"created_at":"2026-07-05T02:30:27.867Z","updated_at":"2026-07-05T02:30:28.901Z","avatar_url":"https://github.com/letv1nnn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ray Tracer\n\nA small ray tracer implemented in C++. I've used the following [article](https://raytracing.github.io/books/RayTracingInOneWeekend.html) as a reference.\n\n\n## build \u0026 run\n\n```sh\ncmake -S . -B build\ncmake --build build\n./build/ray-tracer \u003e output.ppm\n```\n\n```sh\nrm -rf build/ # remove generated directory\n```\n\n## examples and explanation\n\n### basic ppm gradient\n\n![how ppm works](./assets/image.jpg)\n\n### camera, background and viewport setup\n\n![set the background](./assets/background.jpg)\n\n![viewport and camera explanation](./assets/viewport_and_camera_explanation.jpg)\n\nHere is an overview of how our viewport (a virtual plane in 3D space) and camera are set up.\n\nThe camera is positioned at the default coordinates, the origin `(0, 0, 0)`. The viewport is placed at a distance of `1` unit in front of the camera along the negative z-axis. Therefore, the center of the viewport is located at `(0, 0, -1)`.\n\nSince we want the viewport origin to correspond to the top-left corner of the image, we first determine the location of pixel `(0, 0)` and then define a way to iterate across the viewport.\n\nTo achieve this, we define two vectors:\n\n- `Vu`, which spans the horizontal edge of the viewport\n- `Vv`, which spans the vertical edge of the viewport\n\nUsing these vectors, we compute the per-pixel delta vectors along both axes. These delta vectors represent the step size between neighboring pixels and allow us to calculate the center position of each pixel on the viewport plane.\n\n### sphere\n\n![sphere](./assets/sphere.jpg)\n\nusing the sphere definition to define whether the ray intersects with the sphere or not.\n\n![sphere explanation](./assets/sphere_explanation.jpg)\n\n### surface normals\n\n![sphere rendered regarding normals](./assets/shaded_sphere.jpg)\n\nI've calculated the normals(a direction pointing straight out of the surface at the hit point) of the sphere that goes from the center, outwards. Then I've ***colored*** the sphere with the corresponding to normals coordinates colors.\n\nAfter setting up the normals, the following question occured ***Which side of the surface did we hit?***. Hence, we need to manage the case when the ray hits from the inside, thus inverting the normal. In consequence, I mananged to flip the normals to always face the ray.\n\n![sphere with ground](./assets/sphere_with_ground.jpg)\n\nThe ground here is just a very large sphere with a center at ***(0, -100.5, -1)*** and with the radius of 100.\n\n### anitaliasing\n\n![default sphere](./assets/sphere_with_ground.jpg) ![sphere with antialiasing](./assets/antialiased_sphere.jpg)\n\nAntialiasing works by shooting multiple rays at different position inside the same pixel and averaging the \nreturned colors. This approximates how real cameras capture light over an area instead of from a single \npoint, producing smoother edges and reducing jagged artifacts.\n\n### diffuse materials\n\nThe diffuse rendering is implemented by repeatedly generating random bounce directions above the surface and averaging the resulting light contributions.\n\n![simple diffused sphere](./assets/simple_diffuse_sphere.jpg)\n\nAfter using gamma correction for accurate color intensity, I got the following rendered image.\n\n![gamma-corrected sphere](./assets/gamma_corrected_diffuse_sphere.jpg)\n\n### metal\n\nThe reflection direction for the metal material is computed by taking the incoming vector, removing its component along the surface normal (via the dot product), and flipping it outward, resulting in a mirror-like bounce, the result is on the first image below. Then, I've added a fuzzy reflection, the resulting rendered image is the second below.\n\n![metal material](./assets/shiny_metal.jpg) ![fuzzy metal](./assets/fuzzed_metal.jpg)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletv1nnn%2Fray-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletv1nnn%2Fray-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletv1nnn%2Fray-tracer/lists"}