Giter Site home page Giter Site logo

denismegerle / cxx-tracer Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 60.02 MB

Small educational RayTracing project in C++, featuring many texture types and mappings, soft shadows, realistic defocus and acceleration structures for fast inference.

License: MIT License

CMake 3.73% C++ 93.65% C 0.17% Makefile 0.46% Python 1.44% Batchfile 0.56%
raytracing sampling bvh omp-parallel doxygen sphinx-doc

cxx-tracer's Introduction

CXX-Tracer

This is a small, educational project in C++ to get familiar with the language on a deeper level.

Used concepts:

  • C++ (basics, object orientation specifics, templates, project setups, ...)
  • OMP/SIMD
  • CMake (setup, inclusion and generation of libraries, fetching, ...)
  • Doxygen, Sphinx
  • Advanced Computer Graphics

Implemented Features

This project implements a custom ray tracer providing many features, with a simple own maths/vector library.

Objects

Implemented are planes, spheres and triangles. Easily extensible by just defining the appropriate intersection test and an objects axis-aligned bounding box per object.

Textures & Mappings

Apart from reflexion and refraction, many texture types such as Diffuse, Normal, Ambient Occlusion are supported. Each texture can be mapped onto an object according to a mapping, similarly to OpenGL. Therefore CubeMaps, SphericalMaps, Equidistant Projections etc can be used for all objects. If rays hit nothing, the lighting value is read from an environment map instead.

Soft Shadow Lighting

Dimensionless point lights generate unreal shadows with abprupt edges. More realistic light sources have dimensions and create gradual shadows. In this case, many shadow rays are shot instead of just one, averaging over generated outputs.

Cameras & Sampling

For anti-aliasing, a simple implemented supersampling camera shoots multiple rays per pixel. One can generate different sampling patterns via sampling matrices (uniform, stochastic).

Apart from that, real cameras have imperfections such as non-infinite depth sharpness. In ray tracing, one can model a lense camera model and define a focus pane instead, the picture will then be created by randomly selecting multiple points (per pixel) on the lense that would also focus on the same pane point than the original ray (of that pixel):

Acceleration Structures

Ray tracing is based on intersection tests of rays against object primitives. These tests are cheap, but the sheer amount of possible tests is the main cause for long runtimes.

Therefore, reducing the amount of intersection tests is crucial. Bounded volume hierarchies are a standard way for reducing the amount of intersection tests, and this method is implemented here. For further info see Wikipedia.

Sample in Full Quality

Future Work

  • make transmission (in shadow rays) depth dependent instead of binary
  • additional acceleration structure (kd-trees for instance)
  • add trilinear filtering, anisotropic filtering and mip mapping
  • add environment map filtering
  • procedural textures, noise textures for cloud and mountain generation

References

cxx-tracer's People

Contributors

denismegerle avatar heyitsden avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.