A naive raytracer written in C
Go to file
2023-12-10 02:10:20 -05:00
.github/workflows Create codeql-analysis.yml 2020-11-06 19:40:44 -05:00
benchmark Prototype some benchmark runs 2022-07-24 04:20:21 -04:00
demo Convert to pthreads from OpenMP 2023-12-10 02:10:20 -05:00
external Bump CExeption & Unity 2022-07-24 04:18:32 -04:00
images add Constructive Solid Geometry support 2020-10-04 20:33:41 -04:00
main Rendering working from yaml file. Only cubes are supported & no material definitions yet either... 2020-12-11 23:37:06 -05:00
module_datastructures Genericize lists, makes it easy to switch between linked list to array backed list 2023-10-08 00:24:33 -04:00
module_math Refactor Fn_apply->UTILITIES_fn_apply 2023-10-07 19:55:56 -04:00
module_patterns Refactor Fn_apply->UTILITIES_fn_apply 2023-10-07 19:55:56 -04:00
module_raytracer Convert to pthreads from OpenMP 2023-12-10 02:10:20 -05:00
module_shapes Genericize lists, makes it easy to switch between linked list to array backed list 2023-10-08 00:24:33 -04:00
module_utilities Convert to pthreads from OpenMP 2023-12-10 02:10:20 -05:00
scenes Add plane so we can render the shadow glamour shot 2020-12-20 19:09:52 -05:00
test Beginning of metrics, working registry, counter and gauge 2023-12-10 00:02:45 -05:00
.clang-format Begin clang-format 2020-10-23 23:16:52 -04:00
.gitignore Update CMakeLists to put cmake_minimum_required first, update gitignore to ignore goofy mac desktop files 2023-10-02 19:18:54 -04:00
.gitmodules Bare-bones structure 2020-07-31 22:55:20 -04:00
CMakeLists.txt Convert to pthreads from OpenMP 2023-12-10 02:10:20 -05:00
codecov.yml Move main dir -> demo 2020-10-10 09:44:50 -04:00
LICENSE Added triangle support, added obj support. added render_obj binary to load and scale an obj file and render it 2020-09-28 00:35:46 -04:00
README.md minor readme updates 2020-11-06 19:17:39 -05:00

raytracer-c

Badges for CI build, static analysis, and code test coverage

CI codecov Language grade: C/C++

Current interesting features

  • (commit, commit, commit) Accelerated (algorithmically) using Bounded Volume Hierarchies (no kd trees yet)
  • (commit) Multithreaded using OpenMP (can be disabled via CMake option)
  • (commit) Certain hot spots (only 1 so far that made sense) optimized using AVX2 intrinsics (again can be disabled via CMake)
  • (commit) Doxygen doc is generated if doxygen is found by CMake (need to find an easy way to host this)
  • Load Wavefront OBJ files (no MTL support yet though), with triangle smoothing via normal interpolation
  • Texture mapping now supported! (uncompressed PPM only)

Geometry

  • Spheres, Pleanes, Cylinders, Cubes, & Cones
  • Triangles (and loading them from OBJ) files
  • Constructive Solid Geometry (CSG) allows composing complex shapes from the above primitives with three operations: Union, Intersection, and Difference
  • Groups to allow operations and materials to be applied to many primitives (or complex objects) at once

Limitations/Future

  • Only single point light supported (lights with surface area now supported)
  • Need to make so sort of Render executable that would support a simple (yaml?) scene syntax
  • Textures!
  • Various cleanup & documentation (see issues)

Demo Executables

demo/sphere_spin

Simple spin of a camera around a sphere on a parametric path of the form

x(t) = 5*cos(t) - 2.5
y(t) = 5sin(2t)

Watch the video

demo/texture_map

This is to demonstrate a "skybox" or giant cube with a texture map on its surface. The camera then rotates around a small reflective sphere at the center of the scene (both inside the cube).

Watch the video

demo/parabola

simple demonstration of tuple implementation, shooting a projectile with gravity & wind vectors...

demo/sphere_shadow

Matrix implementation allow us to cast rays...and intersect them with a sphere

demo/phong_render_sphere

Phone shading!

demo/phong_render_three_spheres

Multiple objects, but they are all spheres...Some are simply scaled to look flat.

demo/phong_render_three_spheres (with shadows)

Same executable but now shadows are added...

demo/phone_render_three_sphere_and_plane

Slightly newer executable but now with a plane instead of "squashed spheres"

demo/phong_render_three_spheres_and_striped_plane

Very similar but now the plane has stripes.

demo/reflection

Now the central sphere has a reflection...

demo/refraction

Added a sphere with some refraction. Need to make a better demo image.

demo/refraction_cube

Added support for cubes, also allowing an object to opt out of shadow calculation.

demo/refraction_cylinder

Added support for cylinders...

demo/render_obj

Added support for triangles, loading obj files...

Command takes two parameters, the first is the file to load, the second is optional and allows you to scale loaded object.

demo/render_obj

Now with normal interpolation...starting to slow down with lots of triangles/reflection/refraction...

An obvious performance improvement would be to add some group bounding, so we don't have to check all triangles for intersections when we aren't even close.

In any event, flamegraphs are a fun way to see what is going on.

demo/csg

Add some constructive solid geometry - aka CSG...this is a sphere with a cubice bite taken out of it.