A naive raytracer written in C
Go to file
2023-10-02 19:12:29 -04: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 Add cylinder, use nicer api in test 2023-04-07 20:17:59 -04: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 Add some return NULLs in case a Throw happens outside of a Try block 2021-01-16 21:21:47 -05:00
module_math move swig to its own module, somewhat useful interface 2023-02-11 01:13:32 -05:00
module_patterns Add a blend pattern that maps to two individual patterns 2020-11-11 23:49:31 -05:00
module_raytracer Fix wavefront obj normalization and do some (slightly) better error checking 2022-07-24 04:19:45 -04:00
module_shapes Minor cleanup to make OpenMP work on MacOS (with gcc). Properly declare shape vtables & world default reflection ttl 2022-07-08 01:29:53 -04:00
module_swig working python module 2023-10-02 19:12:29 -04:00
module_utilities example tuple working 2023-02-08 19:56:22 -05:00
scenes Add plane so we can render the shadow glamour shot 2020-12-20 19:09:52 -05:00
test Parse yaml with materials (but not patterns) 2020-12-20 18:56:00 -05:00
.clang-format Begin clang-format 2020-10-23 23:16:52 -04:00
.gitignore wildcard build directories in .gitignore 2020-10-24 18:40:17 -04:00
.gitmodules Bare-bones structure 2020-07-31 22:55:20 -04:00
CMakeLists.txt working python module 2023-10-02 19:12:29 -04: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
test.py Add cylinder, use nicer api in test 2023-04-07 20:17:59 -04: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.