HTTPS SSH

Ray Tracing

In computer graphics, ray tracing is a technique for generating an image by bouncing a pixel ray around in a scene, and simulating effects of its encounters with objects in that scene. Ray-traced scenes can be highly realistic but implementing algorithms involve considerable computation time. This makes ray tracing best suited for applications where the image can be rendered slowly ahead of time, such as in still images and film and television visual effects.

This application implements basic ray tracing algorithm. For each pixel, a ray is shot from a camera position out into the world. A ray can hit any object and get reflected, refracted, etc. An intersection of a ray with an object's surface that is closest to a screen is calculated. Lighting model, such as Phong lighting model, is then performed to get a color of a surface at this point of intersection. In this way, a color of each pixel is determined. This simulates the opposite of what happens in real life: Light rays reach our eyes from the world.

alt tag

How do I get set up?

  • This program is written in C++ and OpenGL. Make sure you have OpenGL library installed.
  • Compilation process
    • Windows: compile and run in IDE
    • Mac:
      g++ -Wall -o yourfile yourfile.cpp -framework OpenGL - framework GLUT
    • Linux:
      g++ -g -o yourfile -I/usr/include/GL yourfile.cpp -lGL -lglut -lm -lGLU

Viet Trinh © 2013
vqtrinh@ucsc.edu