Giter Club home page Giter Club logo

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

raytracer's People

Contributors

aromanro avatar codacy-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raytracer's Issues

Improve importance sampling

Currently importance sampling works only for simple objects (that is, not composite). For this project it's enough, it's just a proof of the concept and only simple ones are needed (as lights, mirrors), but it could be enhanced to work for more complex stuff as well.

Anisotropic Phong

Hi, I've been working through the Ray Tracing in One Weekend book. When trying to implement a Anisotropic Phong BRDF I had bugs in my code which I couldn't immediately fix until I saw your project and how you implemented it. I used a few lines from your project to get mine to work. As your project uses the GPL licence, I was wondering if I could have your permission to leave the lines of code in the Anisotropic Phong BRDF, where it looks similar to yours, in my project and release my project under the MIT licence? I've given you credit by linking to your github Ray Tracer project both in the ReadMe file and in the code itself. If you don't mind me releasing under the MIT licence, I'm happy to credit you in any way you like for example by also including a link to your website and your name, whatever you would be happy with. I haven't released it yet until I sort out the licence.

Some parts of some models are wrong

Parts of some models that are composed of triangles come out wrong (so it's not due of: #7).
I don't know yet why, might be combined with the texture mapping being wrong.

Avoid loading the same texture twice

Many obj files have set the same texture file for different parts of the object and/or the same one for both ambient and diffuse textures. Avoid loading them multiple times by using a 'cache', first check in there and if it's not already loaded, then load it.

Improve obj models displaying

I did a pretty basic implementation, just a proof of the concept, but it can be extended.
For example, specular maps and exponent maps are not used, using those should be easy to implement.

Resources

Can you, please, load your .obj model and sky image?

Obj models.

Hello, there!What you've done was so excellent!
I was wondering whether you could share obj models that you got?
Thank you so much.

Help

can you please teach me how to run it

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.