Commit Graph

214 Commits

Author SHA1 Message Date
Matthew Gordon 40d9bb0bb1 Add Array2D struct 2020-09-01 22:26:10 -04:00
Matthew Gordon 26fb50b39b Add partially-implemented Mat2 that should have been in last commit 2020-08-29 23:06:28 -04:00
Matthew Gordon 61d6f69d11 Implement various matrix operations and remove nalgebra 2020-08-29 23:02:23 -04:00
Matthew Gordon f5b0a35635 Replace nalgebra matrix and vector classes with own classes
Nalgebra only used to find matrix inverse now.
2020-08-28 23:08:44 -04:00
Matthew Gordon 99cf127c9f Change a bunch of generics that used with RealType to just use f64 2020-08-18 23:12:28 -04:00
Matthew Gordon a98c0c4bca Fix bug that shifted view one tile to the right 2020-08-18 22:05:14 -04:00
Matthew Gordon 5c2fbf995a Made some minor improvements suggested by clippy 2020-08-15 00:06:06 -04:00
Matthew Gordon 8be0c0a21b Add mat3 struct 2020-08-14 23:48:45 -04:00
Matthew Gordon 4f429ade85 Add Mat4 class 2020-08-14 23:30:54 -04:00
Matthew Gordon 8f0a7d0cfd Add Vec2, Vec3 and Vec4 structs 2020-08-14 22:41:36 -04:00
Matthew Gordon 9160251d10 Start adding custom matrix and vector types 2020-08-13 23:16:56 -04:00
Matthew Gordon 699c308782 Rewrite BoundingVolumeHierarchy
New BVH has much cleaner design and is also using a much better
heuristic for dividing the scene.

Massive speedup (~28x!), presumable from having a heuristic that
actually works. This is still a simple heuristic (sort by
bounding box centres along largest dimension, and then divide into
equal halves) which can definitely be improved.
2020-08-11 23:59:03 -04:00
Matthew Gordon 3ca8bc14e4 Add AxisAlignedBoundingBox::largest_dimension() 2020-08-11 23:58:16 -04:00
Matthew Gordon c322981486 Make BHV contain a BinaryTree instead of being one 2020-07-20 21:46:36 -04:00
Matthew Gordon 4933993187 Use bunny model in test scene again 2020-07-20 21:22:54 -04:00
Matthew Gordon b39c7e89b1 Some cleanup of BVH and BinaryTree 2020-07-04 23:16:22 -04:00
Matthew Gordon 231be6a1a5 Add generic BinaryTree struct and use in BoundingVolumeHierarchy
No change in runtime, as expected.
2020-07-04 22:09:44 -04:00
Matthew Gordon ea311408ba Add time parameter to allow animation 2020-06-20 19:28:40 -04:00
Matthew Gordon d96942cd78 Replace bunny with dodecahedron on test image 2020-06-20 14:57:56 -04:00
Matthew Gordon 9785e3b451 Remove some dead code. 2020-06-20 14:55:25 -04:00
Matthew Gordon 4451d1d71f Add option to save image to PNG file 2020-06-20 14:53:17 -04:00
Matthew Gordon b8dddd7498 Pass image size as command line parameter
Instead of being hard-coded
2020-06-20 12:04:44 -04:00
Matthew Gordon 4464a9fae6 Add utility function to generate dodecahedron 2020-06-20 11:26:17 -04:00
Matthew Gordon e1c91919b8 Add RgbSamplesBsdfMaterial (not working yet) 2020-06-19 00:04:01 -04:00
Matthew Gordon aa942a2a3c Make sure normals or imported meshes are unit length. 2020-06-19 00:01:12 -04:00
Matthew Gordon 29dc3b6a37 Fix a typo that caused artifacts with ReflectiveMaterial 2020-06-19 00:00:12 -04:00
Matthew Gordon cb67362ad4 Break material module up into multiple files 2020-06-11 22:28:53 -04:00
Matthew Gordon 90bb7d84af Big rijiggering of types 2020-06-11 22:13:51 -04:00
Matthew Gordon 8bc2c4b229 Upgrade to nalgebra 0.21 2020-05-22 21:05:30 -04:00
Matthew Gordon ec1ee394a9 Add documentation for BoundingVolumeHierarchy 2020-04-24 00:32:16 -04:00
Matthew Gordon 1d9baf1f05 Add some documentation for mesh module 2020-04-24 00:31:15 -04:00
Matthew Gordon 8ee1f3a004 Add a bunch of documentation to the raycasting module 2020-04-23 23:58:35 -04:00
Matthew Gordon c1d8044eb8 Add documentation for partial_render_scene() 2020-04-23 23:19:21 -04:00
Matthew Gordon 63afdfa36e Make the camera module private and just re-export partial_render_scene() 2020-04-23 23:16:50 -04:00
Matthew Gordon 2a77bac0cc Add a proper description to the README.md and include it in lib.rs 2020-04-23 21:44:01 -04:00
Matthew Gordon 1b66995bdd Replace Vec references with slices in a few places. 2020-04-03 23:34:44 -04:00
Matthew Gordon c063ff22a4 Replace anonymous tuple with tuple struct to improve readability 2020-04-03 23:33:06 -04:00
Matthew Gordon 5fbed4a17f Some minor cleanup recommended by clippy 2020-04-03 23:21:38 -04:00
Matthew Gordon 34232bb7d3 Refactor Bsdf to not store references to material struct members
This complicated the Material trait with explicit lifetimes and
had no real benefit.
2020-04-03 23:12:40 -04:00
Matthew Gordon 8570e08923 Implement Transform trait for Triangle
Still needs more unit tests.
2020-04-03 22:58:00 -04:00
Matthew Gordon 5df3f81359 Implement Transform trait for Plane
Still needs unit tests.
2020-04-03 22:57:28 -04:00
Matthew Gordon a856fcbc21 Make Transform triat use Affine3 instead of the more general Tramsform3 2020-04-03 22:56:28 -04:00
Matthew Gordon 36a4c6f951 Add "stanford bunny" model to repository (for testing) 2020-04-03 21:18:16 -04:00
Matthew Gordon cf8f5e646b Use Box instead of Arc in BoundingVolumeHierarchy 2020-03-27 21:18:47 -04:00
Matthew Gordon bbeb39ba5d Replace unnecessary Arcs with Boxes. 2020-03-27 20:34:19 -04:00
Matthew Gordon 3afbc600e6 Switch to Criterion for benchmarks 2020-03-19 22:40:17 -04:00
Matthew Gordon 4042b266ae Update benchmark 2020-03-19 22:40:17 -04:00
Matthew Gordon b13cbe316d Add Transform trait and implement for Sphere 2020-03-12 21:26:22 -04:00
Matthew Gordon fa43552c6f Remove stray debug print 2020-02-28 23:27:32 -05:00
Matthew Gordon ad2b9247b8 Use BoundingVolumeHierarchy to accelerate rendering 2020-02-28 23:26:56 -05:00
Matthew Gordon 2b8794c884 Add recursion limit to ray tracing 2020-02-28 23:25:51 -05:00
Matthew Gordon 0574dff685 Threads pass back small images instead of sharing large image 2020-02-28 21:42:19 -05:00
Matthew Gordon a04f51998c Make main rendering loop multithreaded again. 2020-02-28 20:53:24 -05:00
Matthew Gordon bdd05f3527 Refactor main rendering loop to use TileIterator
This removes the old multithreading code, but will be using rayon
soon.
2020-02-20 16:47:15 -05:00
Matthew Gordon d21d288013 Add TileIterator struct 2020-02-19 08:04:41 -05:00
Matthew Gordon e52c0772b4 Remove unused import 2020-02-19 08:03:16 -05:00
Matthew Gordon 87b2f2835a Rename morton_order_value() to morton_order_value_3d() 2020-02-19 08:02:36 -05:00
Matthew Gordon 3c813c4526 More work on BoundingVolumeHierarchy 2020-02-13 20:24:35 -05:00
Matthew Gordon 7bd45c8ad2 First pass at bounding volume hierarchy 2020-02-10 22:23:38 -05:00
Matthew Gordon e411f4abb4 Start working on morton (z-order sorting) 2020-02-10 17:45:12 -05:00
Matthew Gordon 8508ac1072 Add trait for converting real type tu u32 2020-02-10 17:15:02 -05:00
Matthew Gordon 079e02e059 Remove some dbg!s 2020-02-10 16:54:42 -05:00
Matthew Gordon d6b5c87759 Create Real trait to replace nalgebra::RealField
Real inherits RealField, but I want to add more to it.
2020-02-10 16:52:09 -05:00
Matthew Gordon a15eeccdfb Fix code formatting. No change of functionality. 2020-02-07 17:05:07 -05:00
Matthew Gordon 23e8a878c5 Move algebra_utils.rs into util module 2020-02-07 17:04:42 -05:00
Matthew Gordon 49bef6f0f4 Add Point3Normalizer 2020-02-07 17:00:46 -05:00
Matthew Gordon 259505e93f Add RealFieldNormalizer 2020-02-06 17:36:36 -05:00
Matthew Gordon c3f3fffc0e Move axis_aligned_bounding_box to util module 2020-02-06 17:06:46 -05:00
Matthew Gordon 65b5e3c45d Create util module and move Interval struct to it 2020-02-06 16:49:11 -05:00
Matthew Gordon 8c527d34fc Add Primitive trait 2020-01-30 17:22:53 -05:00
Matthew Gordon a0de9c18ba Implement HasBoundingBox trait for Plane 2020-01-30 16:43:48 -05:00
Matthew Gordon 89aed89b85 Add derive(Debug) for BoundingBox 2020-01-30 16:43:21 -05:00
Matthew Gordon 1044fc3986 Implement HasBoundingBox for Tirangle 2020-01-29 16:50:26 -05:00
Matthew Gordon e67204b96e Make BoundingBox::from_points accept any IntoIterator<Point3<T>>
...instead of only Vec<Point3<T>>
2020-01-29 16:49:30 -05:00
Matthew Gordon e5d7a1098d Add more methods for constructing BoundingBoxes 2020-01-29 08:09:58 -05:00
Matthew Gordon 30a5a9dd0f Add Interval::expand_to_value(); other minor changes 2020-01-12 12:13:31 -05:00
Matthew Gordon 25ac0bad7f Fixed bug with empty intervals 2020-01-12 10:45:39 -05:00
Matthew Gordon 75611d47d3 Add HasBoundingBox trait with implementation for Sphere 2020-01-10 17:15:35 -05:00
Matthew Gordon abf71658b6 Add axis_aligned_bounding_box::BoundingBox::union() 2020-01-10 17:00:09 -05:00
Matthew Gordon da2208f3f8 Add Interval::union() 2020-01-10 16:46:17 -05:00
Matthew Gordon 5f6733fdb0 Move some declarations around within struct, no change in functionality 2020-01-10 16:21:38 -05:00
Matthew Gordon ffcfa0009c Move import that was only used in tests into test module 2020-01-10 16:21:28 -05:00
Matthew Gordon 5e0e2bad06 Make build and test work with stable rust (nightly needed for benchmarks) 2020-01-10 16:16:27 -05:00
Matthew Gordon 4ee7338711 Add axis_aligned_bounding_box module 2019-12-31 22:17:15 -05:00
Matthew Gordon 5c8903107a Add IntersectP trait
Like Intersect, but the intersect() function only returns a bool,
not a Optional<IntersectionInfo>.
2019-12-31 22:16:06 -05:00
Matthew Gordon 6639ed813b Remove some old code that was already commented out 2019-12-31 22:15:13 -05:00
Matthew Gordon a785eb796f Only enable benchmark when benchmarking, not as regular test 2019-12-31 22:14:24 -05:00
Matthew Gordon 1653174ef6 Make triangle a submodule of raycasting. 2019-12-21 15:29:52 -05:00
Matthew Gordon c35735f117 Move Plane into it's own submodule 2019-12-21 15:19:16 -05:00
Matthew Gordon 91579745cb Move Sphere to a submodule 2019-12-21 15:06:48 -05:00
Matthew Gordon 4e7565638a Move raycsating module into subdirectory 2019-12-21 10:50:59 -05:00
Matthew Gordon 08484306fd Move load_obj() into submudule 2019-12-21 10:43:39 -05:00
Matthew Gordon 12e26887c1 Make output image smaller. 2019-12-21 10:43:39 -05:00
Matthew Gordon 1b9cf2cbca Add benchmark 2019-12-21 10:43:33 -05:00
Matthew Gordon 7cdcdb145a Remove unused function. 2019-12-21 10:08:00 -05:00
Matthew Gordon e1de889d3a Quick-and-dirty multithreading
Not the best multithreading scheme and needs error handling, but
it works.
2019-12-21 10:07:53 -05:00
Matthew Gordon 3618636c42 First quick pass at loading OBJ files. 2019-12-21 09:11:30 -05:00
Matthew Gordon 199b33f944 Remove unused function 2019-12-12 13:01:02 -05:00
Matthew Gordon 777580be17 Fix triangle intersection passing when triangle is behind ray 2019-12-12 08:57:46 -05:00
Matthew Gordon 9096ff67b6 Remove some debug prints that I committed by accident 2019-12-12 08:56:31 -05:00