Coder Social home page Coder Social logo

chicio / ray-tracing Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 0.0 14.91 MB

:sunny: :zap: Ray tracer developed as final project for my computer graphics course at University Milano-Bicocca.

Home Page: http://fabrizioduroni.it/blog/

License: MIT License

Objective-C 99.53% C 0.47%
raytracer shadow-feeler-ray perlin-noise skybox computer-graphics cubemap phong-lighting

ray-tracing's Introduction

Ray-tracing

Build Status GitHub license Supported platform

Ray tracer for iPad developed as final project for my computer graphics course at University Milano-Bicocca.


Main features


Screenshot

These are some images rendered using the ray tracer. For each one there's a complete list of the setup used during rendering.

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

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

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

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

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

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


Description

The ray tracer is developed entirely in Objective-C as an iPad app. The interface let the user manage some of the options available:

  • change of scene to be rendered
  • turn on/off antialiasing
  • turn on/off softshadow
  • choose the camera position between 6 predefined option
  • Phong/Blinn-Phong lighting model

There 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:

  • the max number ray bounce (default 3 bounce)
  • the number of shadow feeler ray (default 16)
  • the light attenuation factors
  • dieletric simulation (default off/false)
    • the equation used for fresnel factor (used only if dieletric simulation is on - default Fresnel equation).

This is a screenshot of the application interface.

Application interface

The part of the image already calculated is shown to the user, so that it could have a feedback during rendering operation. This is done using an asynchronous block submitted to a new quality of service class available in iOS 8 and above.

To speed up the entire process of ray tracing some part of the ray tracer are splitted across multiple threads. Usually 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 Grand Central Dispatch 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).

Finally, 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.


Documentation

All 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.

Documentation


References

Main references:

Other link to the documentation and code examples used during development are referenced inside every method comment using sourcekit tag @see (see "Documentation" section).

ray-tracing's People

Contributors

chicio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.