Giter Club home page Giter Club logo

raytracer's Introduction

raytracer

CS 775 Ray Tracer in C++


Team

110050012 - Mayank Meghwanshi (@mayank127)

110050041 - Shivam H Prasad (@shivamh71)


Instructions

To Compile use > Makefile

To Run > ./ray-tracer scene-file


Code Description

  1. Main File
  • It contains parser for input scene file.
  • It first takes the light parameters and makes a list of light objeect with specified color.
  • It then takes camera parameters and transform pixel points from image plane to view coordinate system then using postioon of eye, up vector and look at vector converts to World coordinate system.
  • Now for each such point a ray is shot from camera to pixel and recursive ray tracing is done.
  • For ray tracing we find out nearest intersection.
  • Now if specular object then send refracted and reflected rays, and calculate color.
  • If diffused object or recursion depth reached then check with shadow ray if light is visible to the point of intersection and calculate color according to phong model.
  1. Objects
  • For each object we find out intersection with a ray from a given origin and direction.
  • We also have a transformation matrix which is used to transform ray to object coordinate system and then use that to find out the intersection.
  • We also have a function which returns normal of the object, which takes as input a point on surface and trasnforms it to object coordinate system and after finding normal at that point transform back to world coordinate space.
  • Different objects made -
    • Sphere
    • Cylinder
    • Cone
    • Triangle
  1. Lights
  • This contain only position and color of light used for phong model calculation.
  1. Vec3
  • This contains function needed for a vector with 3 coordinates x,y,z.
  • It contains functions like dot product, length, cross product, normalize, project, *,/,+,- etc.
  1. Matrix
  • This contains 4x4 matrix used for transformation in 3-d Space.
  • It has different constructors which can make rotation, scale, shear and translate matrices.
  • Also it has usefull functions like inverse, transpose, multiply, transform etc.

Sample Images Sample 1

Sample 2

Sample 3

Sample 4

Sample 5


Sources

raytracer's People

Contributors

mayank127 avatar shivamh71 avatar

Stargazers

Davide Prati avatar Sergey Yablokov avatar Canyu Chen avatar wfhao avatar Matthew Duffin avatar Kazunori Yamada avatar Tao Hu avatar Amit Ahire avatar

Watchers

James Cloos 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.