Giter Site home page Giter Site logo

aromanro / raytracer Goto Github PK

View Code? Open in Web Editor NEW
127.0 9.0 17.0 26.72 MB

A ray tracing program

License: GNU General Public License v3.0

C++ 100.00%
ray-tracing raytracer raytracing raytracing-one-weekend ray-tracer wxwidgets wxwidgets-applications optics raytracing-render 3d

raytracer's Introduction

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

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.