{"id":20721687,"url":"https://github.com/chicio/ray-tracing","last_synced_at":"2026-04-02T02:54:15.245Z","repository":{"id":36875653,"uuid":"41182632","full_name":"chicio/Ray-tracing","owner":"chicio","description":":sunny: :zap: Ray tracer developed as final project for my computer graphics course at University Milano-Bicocca.","archived":false,"fork":false,"pushed_at":"2017-03-18T10:59:31.000Z","size":15271,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T15:14:53.026Z","etag":null,"topics":["computer-graphics","cubemap","perlin-noise","phong-lighting","raytracer","shadow-feeler-ray","skybox"],"latest_commit_sha":null,"homepage":"http://fabrizioduroni.it/blog/","language":"Objective-C","has_issues":true,"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/chicio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-21T23:59:34.000Z","updated_at":"2021-06-07T12:10:12.000Z","dependencies_parsed_at":"2022-09-25T03:51:28.200Z","dependency_job_id":null,"html_url":"https://github.com/chicio/Ray-tracing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicio%2FRay-tracing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicio%2FRay-tracing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicio%2FRay-tracing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicio%2FRay-tracing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chicio","download_url":"https://codeload.github.com/chicio/Ray-tracing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250457792,"owners_count":21433734,"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","cubemap","perlin-noise","phong-lighting","raytracer","shadow-feeler-ray","skybox"],"created_at":"2024-11-17T03:28:59.477Z","updated_at":"2026-04-02T02:54:15.195Z","avatar_url":"https://github.com/chicio.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ray-tracing\n\n[![Build Status](https://travis-ci.org/chicio/Ray-tracing.svg?branch=master)](https://travis-ci.org/chicio/Ray-tracing)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/chicio/Ray-Tracing/master/LICENSE.md)\n[![Supported platform](https://img.shields.io/badge/platforms-iOS-orange.svg)](https://img.shields.io/badge/platforms-iOS-orange.svg)\n\nRay tracer for iPad developed as final project for my \u003ca href=\"https://www.disco.unimib.it/upload/pag/1667904909074911183/f1/f1801q120informaticagrafica20132014engv2.pdf\"\u003ecomputer graphics course at University Milano-Bicocca.\u003c/a\u003e\n\n***\n\n### Main features\n- Support sphere and convex polygon\n- Phong and Blinn-Phong lighting model \n    * light attenuation factor\n- Reflection and Refraction\n    * Reflective objects\n    * Transparent objects\n    * \u003ca href=\"http://www.cs.cornell.edu/courses/cs465/2004fa/lectures/22advray/22advray.pdf\"\u003eRealistic transparency for dieletrics\u003c/a\u003e using:\n         * \u003ca href=\"https://en.wikipedia.org/wiki/Fresnel_equations\"\u003eFresnel equations\u003c/a\u003e\n         * \u003ca href=\"https://en.wikipedia.org/wiki/Schlick%27s_approximation\"\u003eSchlick's approximation\u003c/a\u003e\n    * Multiple reflective objects in the same scene.\n- Camera\n- \u003ca href=\"https://en.wikipedia.org/wiki/Umbra,_penumbra_and_antumbra\"\u003eSoft shadow\u003c/a\u003e\n- Antialiasing (Supersampling)\n- \u003ca href=\"https://en.wikipedia.org/wiki/Cube_mapping#Skyboxes\"\u003eCube mapping (used for skybox at infinite distance)\u003c/a\u003e\n- Procedural texture with \u003ca href=\"https://en.wikipedia.org/wiki/Perlin_noise\"\u003ePerlin Noise\u003c/a\u003e\n    * Marble\n    * Turbulence\n- \u003ca href=\"https://en.wikipedia.org/wiki/Bump_mapping\"\u003eBump mapping\u003c/a\u003e\n\n***\n\n### Screenshot\n\nThese are some images rendered using the ray tracer. For each one there's a complete list of the setup used during rendering.\n\n**Scene 1**: Antialisasing, soft shadow (128 shadow feeler ray), Phong lighting, cube mapping infinite skybox, bump mapping,  sphere dielectric (glass refractive index) using Fresnel equation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/scene1_antialiasing_softshadow128_phong_dieletricfresnel.png\"\u003e\n\u003c/p\u003e\n\n**Scene 1**: Antialisasing, soft shadow (128 shadow feeler ray), Blinn-Phong lighting, cube mapping infinite skybox, bump mapping, sphere dielectric (glass refractive index) using Fresnel equation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/scene1_antialiasing_softshadow128_blinnphong_dieletricfresnel.png\"\u003e\n\u003c/p\u003e\n\n**Scene 2a**: Antialisasing, soft shadow (128 shadow feeler ray), Phong lighting, polygon skybox, bump mapping, procedural texture with perlin noise, sphere dielectric (glass refractive index) using Fresnel equation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/scene2a_antialiasing_softshadow128_phong_dieletricfresnel.png\"\u003e\n\u003c/p\u003e\n\n**Scene 2a**:  Antialisasing, soft shadow (16 shadow feeler ray), Phong lighting, polygon skybox, bump mapping, procedural texture with perlin noise, sphere dielectric (glass refractive index) using Fresnel equation, quadratic light attenuation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/scene2a_antialiasing_softshadow16_phong_dieletricfresnel_quadratic.png\"\u003e\n\u003c/p\u003e\n\n**Scene 2b**: Antialisasing, soft shadow (16 shadow feeler ray), Blinn-Phong lighting, polygon skybox, procedural texture with perlin noise, camera on left side, sphere dielectric (glass refractive index) using Fresnel equation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/chicio/Ray-tracing/raw/master/Screenshots/scene2b_antialiasing_softshadow16_blinnphong_dieletricfresnel.png\"\u003e\n\u003c/p\u003e\n\n**Scene 2b**: Antialisasing, soft shadow (16 shadow feeler ray), Phong lighting, polygon skybox, procedural texture with perlin noise, camera on left side, sphere dielectric (glass refractive index) using Schlick's approximation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/scene2b_antialiasing_softshadow16_phong_dieletricschlick.png\"\u003e\n\u003c/p\u003e\n\n***\n\n### Description\n\nThe ray tracer is developed entirely in Objective-C as an iPad app.\nThe interface let the user manage some of the options available:\n- change of scene to be rendered\n- turn on/off antialiasing\n- turn on/off softshadow\n- choose the camera position between 6 predefined option\n- Phong/Blinn-Phong lighting model\n\nThere are other option defined as constant in the file Constants.h that affected the behaviour of the ray tracer. In particular it is possible to set/change:\n- the max number ray bounce (default 3 bounce)\n- the number of shadow feeler ray (default 16)\n- the light attenuation factors\n- dieletric simulation (default off/false) \n   * the equation used for fresnel factor (used only if dieletric simulation is on - default Fresnel equation).\n\nThis is a screenshot of the application interface.\n\n![Application interface](https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/application_interface_with_ipad.png)\n\nThe part of the image already calculated is shown to the user, so that it could have a feedback during rendering operation.\nThis is done using an asynchronous block submitted to a \u003ca href=\"https://developer.apple.com/library/prerelease/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html\"\u003enew quality of service class\u003c/a\u003e available in iOS 8 and above.\n\nTo speed up the entire process of ray tracing some part of the ray tracer are splitted across multiple threads. \nUsually the tecnique used is to divide in n pieces the image to be rendered, one for every core of the cpu on which you will execute the ray tracing operation in a thread and then sum up the the various result. In this case I used a different approch: the heavy part of the computation is releated to the soft shadows calculation, so I use \u003ca href=\"https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/\"\u003eGrand Central Dispatch\u003c/a\u003e to execute each shadow feeler ray calculation in a dedicated asynchronous block. In this way I can output the image rows already calculated using the technique describe above (my rasterizer need continuos block of image data to generate the piece of the image).\n\nFinally, most of the core implementation of the ray tracer are inspired by the course material and by studying/reading the book \"Ray tracing from the ground up\", Kevin Suffern 2007, used as main additional material to the course slides. See the list below for a complete reference to the main study documents.\n\n***\n\n### Documentation\n\nAll classes, methods and variables are documented with comments using sourcekit tags. Using XCode it is possible to access the documentation while reading the code using Alt + left mouse click.\n\n![Documentation](https://raw.githubusercontent.com/chicio/Ray-tracing/master/Screenshots/documentation.png)\n\n***\n\n### References\n\nMain references:\n* Course slides\n* [\"Ray tracing from the ground up\", Kevin Suffern 2007](http://www.raytracegroundup.com)\n* [Ray tracing Tutorial by Codermind team](http://www.ics.uci.edu/~gopi/CS211B/RayTracing%20tutorial.pdf)\n* [Ray Tracing: Graphics for the Masses](https://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html)\n\nOther link to the documentation and code examples used during development are referenced inside every method comment using sourcekit tag @see (see \"Documentation\" section).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchicio%2Fray-tracing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchicio%2Fray-tracing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchicio%2Fray-tracing/lists"}