Skip to content

VestaKK/RayTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COMP30019 - Project 1 - Ray Tracer

This is your README.md... you should write anything relevant to your implementation here.

Please ensure your student details are specified below (exactly as on UniMelb records):

Name: Matthew Thao Dang Pham
Student Number: 1273607
Username: MATTHEWTP
Email: matthewtp@student.unimelb.edu.au

Completed stages

Tick the stages bellow that you have completed so we know what to mark (by editing README.md). At most 9 marks can be chosen in total for stage three. If you complete more than this many marks, pick your best one(s) to be marked!

Stage 1
  • Stage 1.1 - Familiarise yourself with the template
  • Stage 1.2 - Implement vector mathematics
  • Stage 1.3 - Fire a ray for each pixel
  • Stage 1.4 - Calculate ray-entity intersections
  • Stage 1.5 - Output primitives as solid colours
Stage 2
  • Stage 2.1 - Diffuse materials
  • Stage 2.2 - Shadow rays
  • Stage 2.3 - Reflective materials
  • Stage 2.4 - Refractive materials
  • Stage 2.5 - The Fresnel effect
  • Stage 2.6 - Anti-aliasing
Stage 3
  • Option A - Emissive materials (+6)
  • Option B - Ambient lighting/occlusion (+6)
  • Option C - OBJ models (+6)
  • Option D - Glossy materials (+3)
  • Option E - Custom camera orientation (+3)
  • Option F - Beer's law (+3)
  • Option G - Depth of field (+3)

Please summarise your approach(es) to stage 3 here.*

OBJ models:

  • Loaded in vertices, vertex normals and faces with simple string parsing
  • Faces are stored as an array of Triangle primitives
  • Triangles updated to store information about both vertexs and vertex normals, as well as whether or not the material is Refractive (speeds up triangle intersection calculations)
  • Triangles also store a Bool hasVertexNormals allows for conditional vertex normal interpolation for the sake of 'smoother' shading of obj surface (since obj can provide surface normals but a normal triangle primitive doesn't)
  • Optimised Obj ray collision detecting using AABB ray collision. Ray must collide with the AABB before going through each triangle and finding the closest triangle to the fired ray.
  • Using Multithreading to speed up obj triangle collision detection

Custom Camera orientation:

  • Used Rodrigues' Rotation Formula using left handed coordinate system
  • Rotate the basis vectors in world space first, before continuing the usual calculations to translate pixel coordinates to world space coordinates
  • Applied extra logic to allow rotations from -360 -> 360 degress, since Rodrigues' Formula only works from angles 0 -> 180 degrees (if you just use one formula).

Final scene render

My final render

This render took 49 minutes and 44 seconds on my PC.

I used the Release Configuration to render this, but the sample scenes should still render fine on Debug.

I used the following command to render the image exactly as shown:

dotnet run --configuration Release -- -f tests/final_scene.txt -o images/final_scene.png --cam-pos -1.2,-0.4,2.7 --cam-axis 0,1,0 --cam-angle 134 -w 1650 -h 1350 -x 4

Sample outputs

We have provided you with some sample tests located at /tests/*. So you have some point of comparison, here are the outputs our ray tracer solution produces for given command line inputs (for the first two stages, left and right respectively):

Sample 1
dotnet run -- -f tests/sample_scene_1.txt -o images/sample_scene_1.png -x 4

Sample 2
dotnet run -- -f tests/sample_scene_2.txt -o images/sample_scene_2.png -x 4

References

Primitives Collision

Normal interpolation

Reflection, Refraction and Fresnel

AABB ray collision

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages