GithubHelp home page GithubHelp logo

jaafersheriff / cpu-ray-tracer Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 2.0 20.23 MB

Fully parameterized ray tracer

C++ 99.55% CMake 0.37% Shell 0.08%
texture-mapping povray raytracer bilinear-interpolation

cpu-ray-tracer's Introduction

CPU-Ray-Tracer

Project Description

The goal of this project was to create an efficient ray tracer in C++ with many practical features. Implementation features include:

  • POV-Ray file parsing
  • Blinn-Phong BRDF
  • Cook Torrance BRDF
  • Refractions and reflections
  • Object transformations
  • Bounding Volume Hierarchy
  • Monte Carlo global illumination
  • Texture and Normal mapping
  • Bilinear Interpolation
  • Multithreading

Usage

Building

  • Install GLM under environment variable GLM_INCLUDE_DIR
  • Clone project
  • In project directory run mkdir buid; cd build; cmake ..; make or use CMake GUI to build

Running

Supported povray files can be found in /res/

Command line arguments:

  • sceneinfo <input_file.pov> - Prints out povray scene info without rendering
  • render <input_file.pov> <width> <height> - Renders the povray scene using defined width and height
  • out <filename> - Specify output image name - default is output.png
  • -fresnel - Render scene including Fresnel reflectance
  • -ss=N - Render scene with super sampling with NxN samples
  • -gi - Render scene using Monte Carlo global illumination
  • -gi_samples=N - Render scene using at most N bounces for Monte Carlo global illumination
  • -threads=N - Specify number of threads to be used for rendering
  • -percent - Print out per-thread percent completion

Output

Reflection

shiny

Refraction

fresnel

Object Transformations

valentine

Bounding Volume Hierarchy

balls

Monte Carlo global illumination and Multithreading

Single-threaded: 52h:34m:58s

Multi-threaded: 15h:02m:18s gi

Texture mapping

texture

Normal mapping

norm norm1

Bilinear Interpolation

bi

Final Project

For my final project I chose to do texture mapping. Texture mapping is a low-cost, high-reward feature in computer graphics that is conceptually straightforward, relatively simple to implement, and makes our project much more realistic.

Software Design

Adding textures to a ray tracer isn't terribly difficult, but doing it well from a software design standpoint requires some extra functionality.

The first thing I did was I implemented what I call a TextureBatch. The TextureBatch contains a list of all the unique textures that have been loaded thus far. When my POV-Ray parser finds a texture, it first communicates with the TextureBatch to make sure that texture hasn't already been loaded. If the texture already exists, we can reference the loaded texture rather than loading it again.

As of now each texture is individualized by only its file name. I would like to implement unique ID's per texture for added security.

The other thing I had to implement for my final project was different texture types. My implementation allows objects to reference color maps and normal maps. Looking ahead I may want to add bump maps or specular maps. I created a system that would allow objects to contain multiple texture types through the use of enums. This design allows me to add many different types of textures in the future.

Research

Realistic Ray Tracing by Peter Shirley and R. Keith Morley

Ray Tracing Tutorial by The CoderMind Team

opengameart.org for color and normal map pairs

Normal Map Online for creating my own normal maps

cpu-ray-tracer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

infiniteway

cpu-ray-tracer's Issues

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.