Skip to content

Implementation of a Monte-Carlo raytracer for the course TNCG15 at LiU, ITN during the fall of 2020.

Notifications You must be signed in to change notification settings

frans-johansson/craytrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRaytrace 🔭

Implementation of a Monte-Carlo raytracer in C++. This project was done for the course TNCG15 at LiU, ITN during the fall of 2020.

Issues:

  • [Should be resolved] RGB values might not be normalized to [0, 255] in some cases
  • Möller-Trumbore check might fail sometimes due to doubleing point errors
  • Area light source appears gray-ish when it should be white
  • Cosine term from rendering equation as lightAmount cause shadow-acne for some reason

TODO:

  • Ignore rays that end on light sources, use penultimate ray as final ray.
  • Figure out why rays seem to get trapped inside of boxes and tetrahedra.
  • Refactor code base
    • Separate code into more files
    • Collect forward-declarations in one header file, which is included first
    • Replace Color with glm::dvec3
    • Use either snake_case or camelCase for variables/methods (PascalCase for classes)
    • Color convenience methods and constants
  • Oren Nayar surfaces
  • Transparent surfaces
  • Set const rendering parameters
    • Lightning sample amount
    • Importance reduction
    • Russian roulette cutoff

DONE:

  • Walls
  • Möller-Trumbore algorithm for triangle intersections
  • Set up CMake for building the project
  • Handle dependencies with CMake
    • Set up GLM library as dependency
    • Set up PNG++ library as dependency
  • Implement (simple) rendering loop
    • Iterate over all pixels
    • Send rays through each pixel and set the color of the pixel to the color of the first intersected triangle
  • Move class/struct definitions into header files
  • Create implementation file for class memeber functions
  • Make triangle verticies public/add getter functions
  • Get XYZ components from a glm::DVec4
  • Changed dvec to vec
  • Camera should have separate render and create_image functions
    • Render: Cast all the rays and calculate the doubleing point color values of each pixel
    • Create image: Convert the doubleing point RGB values to png::byte
  • Save render results to an image
    • Convert from double-valued colors to 8 bit unsigned integer values
    • Find a way to push pixel values into some kind of an image format in C++
  • Simple local lighting model
    • Implement lights in the scene
    • Check that the triangle normals make sense
  • Implement scene objects
    • Tetrahedron
    • Sphere (implicitly with radius) MOA
    • Handle mutliple ray intersections, using the nearest intersection
  • Shadow rays on "local light check"
    • Is there an intersection for the ray going from the object to the light source?
  • Handle "ray trees"
    • Spawn more rays when intersecting something reflective/refractive
    • Calculate intensity values for the ray by working from the ends to the original ray

How to terminal (Guide for Dummies cough Moa)

  • Go up one directory: cd ..
  • List the items in a directory: ls
  • List all the items: la
  • Make a new directory: mkdir [name] (e.g. mkdir build)

Building and running

From the root directory of the project (e.g. craytrace)

  1. cd build
  2. cmake .. (sometimes you need to rm -rf build/* from craytrace first to restore build)
  3. cmake --build .
  4. ./CRaytracer (or whatever the binary is called. tip: tab is your friend)

Developed by:

  • Frans Johansson
  • Moa Gutenwik

About

Implementation of a Monte-Carlo raytracer for the course TNCG15 at LiU, ITN during the fall of 2020.

Topics

Resources

Stars

Watchers

Forks