Skip to content

aromanro/RayTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RayTracer

A ray tracing program

Codacy Badge CodeFactor

Mainly based on 'Ray Tracing' books from Peter Shirley: http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-weekend.html I skipped the boring (for me) texture generation part and also the motion bluring, I preffered to go further enhancing the materials and loading obj files.

Some more info is on Computational Physics Blog: https://compphys.go.ro/ray-tracing/

Some papers that were used:

'An Anisotropic Phong BRDF Model' by Michael Ashikhmin and Peter Shirley https://www.cs.utah.edu/~shirley/papers/jgtbrdf.pdf

Osada et All, 'Shape Distributions' http://www.cs.princeton.edu/~funk/tog02.pdf

'Fast, minimum storage ray-triangle intersection' Tomas Möller and Ben Trumbore. Journal of Graphics Tools, 2(1):21--28, 1997. http://www.graphics.cornell.edu/pubs/1997/MT97.pdf

The project has some known issues, for example loading an object from an obj file does not split correctly concave polygons, they must be convex (unless you are lucky). See the code for how that could be fixed. Also importance sampling with composite objects has some issues. I know why they occur and how it could be solved, but I don't have enough patience for those changes right now :)

Obj loader is very basic, it seems to work for some cases.

An animation generated with the program:

Program video

Some images obtained while implementing it:

First, with more recent code, an obj that has specular mapping and a normal/bump map:

Screenshot

After the first book, 'Ray Tracing in one weekend':

Screenshot

With local illumination, depth of field and textures:

Screenshot

The Cornell box (during the 'next week' book):

Screenshot

Adding triangles, already beyond the 'rest of your life' book:

Screenshot

Adding Beer-Lambert law for transparent objects:

Screenshot

The first obj file loaded in the Cornell box:

Screenshot

Making it transparent:

Screenshot

Trying some other obj models:

Screenshot

Now together with colors/textures:

Screenshot

Implementing the Phong model:

Screenshot

Trying it on a model, exponents are too high:

Screenshot

More testing:

Screenshot

And some new model for testing the features:

Screenshot

Images generated while fixing some bugs in models loaded from obj files:

Screenshot

Screenshot

And one after some later changes, when I also added procedural textures:

Screenshot