Skip to content
A Ray Tracer in openFrameworks
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example-cornell
img
src
.gitignore
NOTES.md
README.md

README.md

ofxRayTracer

A Ray Tracer in openFrameworks

current

This ray tracer implementation was written as exercise for this online course, course prepared by prof. Morgan McGuire.

It is intended for personal use. It provides a way to load an .obj file through the ofxAssimpModelLoader and render it.

Requirements.

You need to install tbb. On MacOS, follow this answer on SO

Usage

You need to set up a scene

shared_ptr<ofImage> image;
ofxAssimpModelLoader modelCornell;
vector<of3dPrimitive> primitives;
vector<ofLight>	lights;
ofNode centerOfTheScene;

modelCornell.loadModel("CornellBox-Original.obj", 20);
// set up a scene
centerOfTheScene.setPosition(0, 0, 0);
// set the lights
ofLight light;
light.setPointLight();
light.setPosition(0, +0.5, -3.0);
lights.push_back(light);

// read the models and fullfill the primitives vector
ofxRTMeshHelper::readModelAndGetPrimitives(modelCornell, primitives, centerOfTheScene);
// position the primitives
centerOfTheScene.move(0, -1, -3);

and this is how you launch the render

ofxRTPinholeCamera camera;
shared_ptr<ofImage> image;
image->allocate(800, 600, OF_IMAGE_COLOR);
ofxRayTracer rayTracer = ofxRayTracer(primitives, lights);
rayTracer.traceImage(camera, image);

Have a look at the example-cornellbox app. On this file there are my notes written while I was writing the renderer

TODO:

  • colors
  • multithread
  • indirect rays
  • colored shadows
  • antialiasing
You can’t perform that action at this time.