Skip to content

Glavin001/Raytracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raytracer

Raytracer for CSCI 4471 Computer Graphics class project

See Features section below for a complete feature list.

Author

Downloads

Pre-Built Binary for Mac (188 KB) zip of in/ directory (32.6 MB) zip of out/ directory (4.22 MB) zip of img/ directory (2.79 MB)

Note: Some of the required files are ignored by Git to keep the repository's size at a minimum. The complete in/ directory can be downloaded and swapped in place after downloading this repository. This will allow you to test all of the files, including those with large .obj and texture files.

The out/ directory contains all of the rendered images as .bmp. The img/ directory contains all of the images converted into .png. You may prefer to download the resulting images in out/ and img/, and skip compiling and running the Raytracer entirely.

Compiling

Build the executable in bin/ directory.

make

Cleaning

make clean

Usage

After compiling (see above):

./bin/raytracer.o

Testing

Unit Testing

make test

Rendering Sample Scenes

make render

Then look into the out/ for all of the rendered images.

You can also copy and paste the commands that are printed out for each file render.

For instance, you may see:

cd in/ ; ../bin/raytracer.o -input test_noise_1.txt -size 200 200 -bounces 4 -output ../out/test_noise_1-no_back.bmp -normals ../out/test_noise_1_normals.bmp ; cd ../

You can easily copy and paste this command to re-render this case for input test_noise_1.txt with those arguments.

Rendering Arguments

You can change the default arguments for render task.

  • PATTERN - Defaults to *.txt - Globbing pattern to select input files from in/ directory
  • SIZE - Defaults to 200 - Size of rendered images
  • EXT - Defaults to bmp (bmp or tga supported) - File extension of rendered images
  • BOUNCES - Defaults to 4 - # of recursive bounces of a ray, used for reflections
  • SPECIALS - Defaults to on (on or off) - Render special cases of the input files, such as with depth mapping

Cleaning Rendered Images

After running make render and populating your out/ directory with images you may wish to clean / delete all of those images.

make clean-render

Rendering with a clean build

By default, make render will only compile any new / changed files. To force a make clean before building the binary and running the render task you can use the render-clean task.

# Exactly like using just `render` task
# Except it runs `clean` task before building
make render-clean
Examples

To render a single file, use full filename and force the pattern to only match one:

make render PATTERN=test_bunny_1k.txt

You can use Globbing / patterns to select input files:

make render PATTERN=test_colored_reflective_sphere_shadows_2*

You can also change the rendered image size:

# Render all images with output size of 1000
make render SIZE=1000
# Render specific pattern of images with output size of 1000
make render PATTERN=test_texture_mapping_sphere.txt SIZE=1000

You can also disable the special custom rendered images:

make render SPECIAL=off

Convert .bmp to .png images

First, install imagemagick:

brew install imagemagick

The following will convert the .bmp images to .png images and move them into the img/ directory.

make convert-render

You should run this after you're satisfied with your .bmp renders. It will render all of the .bmp images it can find in out/, and will take some time. Be patient and run only when you're ready.

make render # Render `.bmp` images to `out/`
make convert-render # Convert `.bmp` to `.png` and move to `img/`

Documentation

Source Code

Using Doxygen.

make docs

Features

Here is the complete feature list. Bolded list items are require features. Features marked with ✓ are implemented, while those without are not.

In addition to the 103 required marks there were 26 elective marks implemented, totalling to 129 marks out of the 125 marks for 100%.

Below is the complete list of features and details about each where applicable.

Electives (22 required marks)

Your choice of additional features beyond the specific required ones.

Implemented 26 elective marks:

  • Multiple light sources (4 marks)
  • Other debugging tools (2 marks)
  • Environment Mapping (5 marks)
  • Octree (6 marks)
  • Antialiasing (5 marks)
  • Source Control (4 marks)

Starting Out (5 required marks)

Implemented 5 out of 5 required marks.

Primitives and Modeling (29 required marks)

Implemented 29 out of 29 required marks.

image

image

render

scene2_09_bunny_200-shadows_shade_back

scene2_10_bunny_1k_normals scene2_10_bunny_1k-shadows_shade_back

scene12_vase_normals scene12_vase-shadows_shade_back

scene13_diamond_normals scene13_diamond-shadows_shade_back

test_bunny_1k_normals test_bunny_1k-shadows_shade_back

scene2_11_squashed_sphere_normals scene2_11_squashed_sphere-shadows_shade_back

scene2_13_rotated_squashed_sphere_normals scene2_13_rotated_squashed_sphere-shadows_shade_back

scene2_14_axes_cube_normals scene2_14_axes_cube-shadows_shade_back

scene2_15_crazy_transforms_normals scene2_15_crazy_transforms-shadows_shade_back

  • Constructive Solid Geometry (10 marks)

  • Additional Primitives (3 or more marks)

  • 3-D Iterated Function System (8 marks)

Light Simulation and Illumination (36 required marks)

Implemented 36 out of 36 required marks and 4 elective marks.

image

scene_shininess_variations-shadows_shade_back

scene4_03_mirrored_floor_normals scene4_03_mirrored_floor-shadows_shade_back

scene4_04_reflective_sphere_normals scene4_04_reflective_sphere-shadows_shade_back

scene_reflective_sphere_normals scene_reflective_sphere_bounces_0 scene_reflective_sphere_bounces_1 scene_reflective_sphere_bounces_2 scene_reflective_sphere_bounces_3 scene_reflective_sphere-shadows_shade_back

scene_reflective_shininess_variations_normals scene_reflective_shininess_variations-shade_back scene_reflective_shininess_variations-shadows_shade_back

  • [✓] Basic Shadows (6 marks)

    image image

  • [✓] Refraction (10 marks)

    • See RayTracer.cpp

      scene4_06_transparent_bars.txt | scene4_07_transparent_sphere_1.txt --- | --- | --- | --- scene4_06_transparent_bars-shadows_shade_back | scene4_07_transparent_sphere_1-shadows_shade_back scene4_06_transparent_bars-shadows_shade_back.bmp | scene4_07_transparent_sphere_1-shadows_shade_back

      scene4_08_transparent_sphere_1.txt | scene4_09_transparent_sphere_2.txt --- | --- | --- | --- scene4_08_transparent_sphere_1-shadows_shade_back | scene4_09_transparent_sphere_2-shadows_shade_back scene4_08_transparent_sphere_1-shadows_shade_back.bmp | scene4_09_transparent_sphere_2-shadows_shade_back.bmp

  • Soft Shadows (6 marks)

  • [✓] Multiple light sources (4 marks)

scene2_03_colored_lights-shadows_shade_back scene4_02_colored_shadows-shadows_shade_back

  • Spotlights (4 marks)

  • Glossy reflections (7 marks)

  • Simple Fog (4 marks)

  • Volumetric fog (8 marks)

  • Photon Mapping (15 marks)

Camera and Lens Model (11 required marks)

Implemented 11 out of 11 required marks.

  • [✓] Camera (2 marks)

  • [✓] Orthographic Camera (4 marks)

  • [✓] Perspective Camera (5 marks)

  • Bloom (4 marks)

  • Depth-of-field (8 marks)

  • Fisheye appearance (2 marks)

  • Oblique Cameras (2 marks)

  • Other Non-Linear Cameras (4+ marks)

Debugging Tools (12 required marks)

Implemented 12 out of 12 required marks and 2 elective marks.

  • [✓] Depth Visualization (4 marks)

scene1_01_depth scene1_02_depth scene1_03_depth scene1_04_depth scene1_05_depth scene1_06_depth scene1_07_depth scene2_04_perspective_depth scene2_05_depth scene2_06_depth scene2_07_depth

  • [✓] Back face shading / no shading (4 marks)

scene2_07_depth scene2_07_sphere_triangles_normals scene2_07_sphere_triangles-no_back scene2_07_sphere_triangles-shade_back

scene2_05_depth scene2_05_inside_sphere_normals scene2_05_inside_sphere-no_back scene2_05_inside_sphere-shade_back

  • [✓] Normal Visualization (4 marks)

octahedron_2_normals octahedron_normals scene_reflective_shininess_variations_normals scene_reflective_sphere_normals scene_shininess_variations_normals scene1_01_normals scene1_02_normals scene1_03_normals scene1_04_normals scene1_05_normals scene1_06_normals scene1_07_normals scene1_08_normals scene01_plane_normals scene2_01_diffuse_normals scene2_02_ambient_normals scene2_03_colored_lights_normals scene2_04_perspective_normals scene2_05_inside_sphere_normals scene2_06_plane_normals scene2_07_sphere_triangles_normals scene2_08_cube_normals scene2_09_bunny_200_normals scene2_10_bunny_1k_normals scene2_11_squashed_sphere_normals scene2_12_rotated_sphere_normals scene2_13_rotated_squashed_sphere_normals scene2_14_axes_cube_normals scene2_15_crazy_transforms_normals scene2_16_t_scale_normals scene02_cube_normals scene4_01_sphere_shadow_normals scene4_02_colored_shadows_normals scene4_03_mirrored_floor_normals scene4_04_reflective_sphere_normals scene4_05_transparent_bar_angle_view_normals scene4_05_transparent_bar_normals scene4_06_transparent_bars_normals scene4_07_transparent_sphere_1_normals scene4_08_transparent_sphere_1_normals scene4_09_transparent_sphere_2_normals scene4_10_point_light_distance_normals scene4_11_point_light_circle_normals scene4_12_point_light_circle_d_attenuation_normals scene4_13_point_light_circle_d2_attenuation_normals scene4_14_faceted_gem_normals scene05_bunny_200_normals scene06_bunny_1k_normals scene10_sphere_normals scene11_cube_normals scene12_vase_normals scene13_diamond_normals test_bunny_1k_normals test_colored_reflective_sphere_shadows_2_normals test_colored_reflective_sphere_shadows_3_normals test_colored_reflective_sphere_shadows_4_normals test_colored_reflective_sphere_shadows_normals test_noise_1_normals test_ortho_cube_normals test_ortho_cube_refraction_normals test_perspective_1_normals test_plane_1_normals test_refraction_inside_sphere_normals test_texture_mapping_sphere_normals test_transparent_sphere_normals test_wine_glasses_normals tetrahedron_normals

  • OpenGL Previsualization Tool (6 marks)

  • [✓] Other Tools (2+ marks)

  • [✓] I developed RayCapture for the purpose of assisting me with quicker debugging and generating sample input scenes.

  • [✓] I have used Unit Testing to help me with my debugging. You can run make test to see the results. This has helped me in the initial development of this Raytracer for testing Camera's generateRay return values in comparison to the right values calculated "by hand". See test/unit/ directory for source code of the unit tests.

  • [✓] I developed a render.sh script that allows me to pass arguments in to customize which input files are rendered and how they are rendered, size of image, number of ray bounces, etc. See Rendering Arguments section above for more details.

Textures (10 required marks)

Implemented 10 out of 10 required marks and 5 elective marks.

  • [✓] Simple Procedural (4 marks)

  • [✓] Texture Mapping I (6 marks)

  • Texture Mapping II (up to 6 marks)

  • [✓] Environment Mapping (5 marks)

This could be sphere maps or cube maps. - [✓] Cube Map support - See CubeMap.h and CubeMap.cpp

	`scene10_sphere.txt` | `scene12_vase.txt`

--- | --- scene10_sphere-shadows_shade_back | scene12_vase-shadows_shade_back scene10_sphere-shadows_shade_back.bmp | scene12_vase-shadows_shade_back.bmp

  • Additional texture model loading (4 marks)

  • Bump mapping (6 marks)

Acceleration Techniques (0 required marks)

Implemented 6 elective marks.

  • Adaptive Ray Depth (5 marks)

  • Intersection Methods (4 marks)

  • BSP tree (6 marks)

  • Grid (6 marks)

  • Adaptive bounding boxes or bounding spheres (6 marks)

  • [✓] Octree (6 marks)

  • Some other technique of your choice (6 marks)

Distributed Raytracing (0 required marks)

Implemented 5 elective marks.

  • [✓] Antialiasing (5)

    • [✓] Jittering method for antialiasing

    Normal | Antialiasing with n=2 | Antialiasing with n=4 --- | --- | --- scene_reflective_shininess_variations-shadows_shade_back | scene_reflective_shininess_variations-jitter_2 | scene_reflective_shininess_variations-jitter_4

  • Adaptive Antialiasing (4 marks)

  • Motion Blur (4 marks)

Software Engineering (0 required marks)

Implement 4 elective marks.

  • [✓] Source Code Control (4 marks)

  • Parallelizing the Raytracer (5 marks)

About

Raytracer for CSCI 4471 Computer Graphics class project

Resources

Stars

Watchers

Forks

Packages

No packages published