Commit Graph

61 Commits

Author SHA1 Message Date
e0ee0d6dff Change to using a dedicated affine transform type.
This lets certain operations, especially matrix inversion, be
quite a bit faster.  And we don't need anything beyond affine
transformations anyway.
2021-05-14 13:30:28 -07:00
022c913757 Split out memory arena into an external crate. 2019-12-27 10:43:03 +09:00
e23fe4bb36 Fix deprecation warnings from rustc. 2019-11-23 10:21:16 +09:00
152d265c82 Switched all uninitialized memory to use MaybeUninit. 2019-07-06 13:46:54 +09:00
646139efda Factor out ray computations that are shared for all triangles. 2019-07-06 09:19:53 +09:00
4b612e2d1a Leaf triangle intersection now loops over triangles per ray.
This is the inverse of what was being done before, which was to
loop over all of the rays for each triangle.  At the moment, this
actually appears to be a tiny bit slower, but it should allow
for future optimizations testing against multiple triangles at once.
2019-07-06 09:01:24 +09:00
4ef376dc89 Move multiple-object logic out of BVH4.
This allows each part of Psychopath tp handle the logic in the
best way, instead of a one-size-fits-all approach.
2019-06-29 08:28:41 +09:00
b09f9684d1 Remove non-SIMD BVH4, and keep more bool calculations in SIMD format. 2019-06-29 07:22:22 +09:00
2fddcae0fd Reduced the size of a hot return value.
Gives a small performance boost.
2019-06-28 22:22:41 +09:00
5dd8eb919b Changed ray batch data access to be through methods.
This is (potentially) just temporary.  It's to make it a bit easier
to play with data layout to see how that affects performance.
2019-06-25 17:31:51 +09:00
630a79aca5 Initial implementation of ORST traversal.
This is a "just get it working" implementation.  Performance
optimizations still need to be done.
2019-06-23 18:40:52 +09:00
112f94c127 Implemented a "Micropolygon Batch" type.
This is in prep for a shade-before-hit architecture.  The type is
currently unused and untested.
architecture.
2018-12-28 13:40:36 -08:00
8e109efed5 Fixed compiler warnings. 2018-12-28 11:09:17 -08:00
28a07de456 Improve module path usage and remove extern crate declarations where possible. 2018-12-16 13:02:49 -08:00
178c0bd6cb Third step transitioning to Rust 2018. 2018-12-16 12:17:21 -08:00
8deb1e87bb First step transitioning to Rust 2018. 2018-12-16 12:02:20 -08:00
c73db2edbe Fix/silence a bunch of clippy warnings in the main crate. 2018-12-15 23:26:12 -08:00
589a67caa4 Run latest rustfmt on code. No functional changes. 2018-12-08 13:23:44 -08:00
5c20fa3ea4 Moved more work out of the triangle mesh intersection inner loop.
This makes the code a bit spaghetti-like, but it provides noticable
speed-ups in the all the scenes I tested.
2018-07-01 17:30:58 -07:00
6d21a30840 Formatting with newer cargo fmt.
No meaningful code change, only formatting.
2018-06-24 21:18:10 -07:00
c990672dfe Fix compiler warnings. 2018-03-04 13:06:22 -08:00
97d3304149 Run new rustfmt on codebase. 2018-03-04 13:00:55 -08:00
b1bd419779 Factored out interpolating over a triangle's surface into its own function.
We'll be using this in the RectangleLight sampling code soon.
2017-08-17 11:23:47 -07:00
5c91aca002 WIP multiple importance sampling.
Added method for intersecting finite light sources, and implemented
the method for SphereLight.
2017-08-16 17:27:44 -07:00
e2a417884d Added time parameter to shader evaluation.
It's not used right now, but in the future I want shaders to be
able to vary over time and have motion blur.  This serves as a
nice little reminder by putting it in the API.
2017-08-08 14:48:22 -07:00
516803e78a Got basic material parsing and rendering working.
Currently only Lambert is supported.
2017-08-03 19:31:58 -07:00
f4d4152543 Some refactoring in preparation for a material system.
The main change is that SurfaceClosures now have the hero
wavelength baked into them.  Since surface closures come from
surface intersections, and intersections are always specific to
a ray or path, and rays/paths have a fixed wavelength, it doesn't
make sense for the surface closure to constantly be converting
from a more general color representation to spectral samples
whenever its used.

This is also nice because it keeps surface closures removed from
any particular representation of color.  All color space handling
etc. can be kept inside the shaders.
2017-08-03 16:16:36 -07:00
58a783b01e Silly mistake in calculating interpolated triangle normal.
The normal is in the local space of the model and needs to be
transformed to global space for lighting calculations.
2017-07-30 23:14:03 -07:00
05578a1240 Implemented smooth-shaded triangle meshes.
There are still some things to do to avoid light leakage and
other weird shading in some situations, but the basics are working!
2017-07-30 17:55:03 -07:00
e77d5b7576 Refactored triangle meshes in preparation for custom normals. 2017-07-30 16:56:28 -07:00
c0a26819c6 Bunch of code quality improvements based on running clippy.
None of them change behavior, just make the code cleaner.
2017-07-22 17:21:11 -07:00
2dcba3aca4 Speed up ray/mesh intersection for cases with no transform motion blur. 2017-07-12 01:32:44 -07:00
b315be0913 Fixed self-intersection bug for coordinates near zero.
This turned out to be a rather interesting one.  The water-tight
ray/triangle intersection algorithm, while very accurate for
finding if there is an intersection with a line segment, is
not as remarkably accurate for determining if that intersection
is within the interval of the ray.

This is because of the coordinate transformation it does
depending on ray direction: for triangles laying flat on one of
the axis planes near zero, that near-zero coordinate can get
transformed to a much less accurate space for testing.  In fact,
generally speaking, beause of the coordinate transform, you can
only rely on the test being as accurate as the least accurate
axis.

The ray-origin offset code was doing offsets based on the
assumption that the error on the major axes are independent, but
as this triangle intersection algorithm shows, you can't actually
depend on that being the case.  So rather than handling triangle
intersection as a special case, I've changed the intersection
position error to be a single float, representing the maximum
possible error on any axis.  This should be robust for any
geometry type added in the future, and also solves the immediate
issue in a correct way.
2017-07-10 00:52:28 -07:00
09daf617ef Implemented a non-SIMD BVH4. Perf appears to be identical to BVH. 2017-07-01 15:08:05 -07:00
011405e131 Implemented robust ray origin calculation for bounced rays.
We take a small performance hit for this, but given that it's
making things meaningfully more correct I feel like it's more
than worth it.
2017-06-19 22:28:44 -07:00
71bdf203aa Fixed bug in mesh intersection code.
Very small triangles were being missed because of the
not-so-robust ray-triangle intersection algorithm I was using.

Switched to the algorithm from the paper "Watertight
Ray/Triangle Intersection" by Woop et al.  Happily, the new
algorithm doesn't seem to measurably slow down renders at all.
2017-06-18 20:51:53 -07:00
f649bec585 Reformat code with rustfmt 0.9 2017-06-15 22:00:31 -07:00
922e33ec3f Reformat code with latest rustfmt and custom config. 2017-05-14 13:43:51 -07:00
c92a8c4da0 During BVH construction, merge BBox time samples based on a threshold.
If the average surface area of all the time samples is close enough
to the surface area of their union, just take the union and use that.
This both makes the BVH smaller in memory (time samples don't
propigate up the tree beyond their usefulness) and makes it
faster since traversal can avoid interpolating BBoxes when there's
only one BBox for a node.
2017-04-23 23:15:31 -07:00
b135e8beb8 Fixed bug in new BVH4 traversal code. 2017-04-22 22:32:36 -07:00
0296fd2d34 Fixed a bunch of problems that came up when running debug build.
The worst offender was an obvious and nasty bug in the bitstack
implementation.  Hooray for debug asserts!
2017-04-14 21:37:29 -07:00
573c5da5ab Got BVH4 working. Woo hoo! 2017-04-13 22:44:34 -07:00
c82c821b31 BVH and objects now use MemArena. 2017-04-09 23:33:36 -07:00
4a86c4122a Laying some groundwork for a simple shading system. 2017-03-14 00:27:25 -07:00
114f11c583 Fixed bug in GTRClosure that was resulting in all NaN outputs. 2017-03-12 00:33:36 -08:00
f4445417dc Reorganizing the module tree.
Enough things had accumulated that it seemed to make sense to
group some stuff together.  So here it is.
2017-02-14 00:14:08 -08:00
97b5ef77f8 Code cosmetics: organize and alphabetize crate/mod/use statements. 2016-08-20 18:10:55 -07:00
aff8d24f55 Fixed some bugs where instances without transforms would crash. 2016-07-07 23:32:19 -07:00
0880a0f19d Make renderer actually use the material system properly.
The intersection code still isn't using any kind of shading,
and materials aren't parsed by the parser, but the renderer
class itself is using them.
2016-07-07 19:51:19 -07:00
e56ac418da Beginnings of global illumination.
There are still some obvious bugs in it that I haven't tracked down,
so the renders aren't correct yet.
2016-07-03 01:18:50 -07:00