Commit Graph

450 Commits

Author SHA1 Message Date
993ba719d7 Fixed bug that was causing spurious NaN pixels.
It was because sometimes the PDF's for a sample could be zero,
leading to a divide by zero.  PDF = 0.0 is now checked for.
2017-05-14 12:45:43 -07:00
567b658b6c Removed blue noise dithered sampling. 2017-05-14 12:37:01 -07:00
d71fd3b5c8 Implemented blue noise dithered sampling. Temporary.
After implementation, it does appear to make rendering slower
by a noticable bit compared to what I was doing before.  At very
low sampling rates it does provide a bit of visual improvement,
but by the time you get to even just 16 samples per pixel its
benefits seem to disappear.

Due to the slow down and the minimal gains, I'll be removing
this in the next commit.  But I want to commit it so I don't
lose the code, since it was an interesting experiment with
some promising results.
2017-05-14 12:25:01 -07:00
d8a33c7bfa Added a blue noise mask generator as a sub-crate. 2017-05-13 03:23:55 -07:00
172e2f19ef Removed BVH4 and the related bitstack from AccelRay.
I couldn't make the BVH4 faster than the BVH, and the bitstack
was bloating the AccelRay struct.  Removing the bitstack gives
a small but noticable speedup in rendering.
2017-05-12 21:07:40 -07:00
88578b9eae Moved Float4 and Matrix and Vector math into their own sub-crates. 2017-05-12 21:01:54 -07:00
5ab1a51f4c Avoid bounds checking in the Sobol code. 2017-05-12 00:34:03 -07:00
04e8a6ca73 Added a Rust port of Leonhard Grünschloß's Sobol sampler.
The Halton sampler appears to be better, but it was fun to add
this anyway!
2017-05-11 23:56:12 -07:00
b698a52f6c Split some more things out into sub-crates.
Also translated the Halton generator to rust and made it a crate
where the code is generated by a build.rs file.
2017-05-11 22:57:59 -07:00
96db00b10a Refactored some parts of Renderer to take up less memory and be faster.
Specifically, LightPath is now significantly smaller, and
resultingly faster to process.

Also finally fixed the bug where without light sources the light
from the sky wouldn't affect surfaces.
2017-05-11 20:23:19 -07:00
a3a19e53ef Some misc small optimizations. 2017-05-11 01:22:37 -07:00
dcf25b92af Fiddled with BVHNode to make it 32 bytes instead of 40 bytes.
This helps reduce the total size of BVHs since both BBoxes and
and BVHNodes are now 32 bytes and can be properly packed together.
2017-05-08 19:47:10 -07:00
d8e31750a8 Small optimization in BVH traversal. 2017-04-26 01:03:16 -07:00
8b0c422630 Small optimization in BBox intersection and bugfix in BBox4 intersection. 2017-04-26 00:28:43 -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
55c64a3392 Added missing *_with_alignment allocation variants. 2017-04-23 10:10:10 -07:00
b135e8beb8 Fixed bug in new BVH4 traversal code. 2017-04-22 22:32:36 -07:00
a940630a27 Reduced max bvh tree depth.
Reduced from 64 to 42.  This still allows each BVH to hold 4.4
trillion elements, but it guarantees that the accel ray's
traversal bitstack can accommodate at least two nested max-depth
trees.
2017-04-22 12:51:35 -07:00
0cbf851451 Fixed a commandline argument that was broken.
Also removed a redundant statistics printout.
2017-04-22 12:50:28 -07:00
fdf2b4babf Print stats for BVH and BVH4 traversal, and working on speeding up BVH4 traversal. 2017-04-22 11:18:29 -07:00
597bcf0518 Sped up splitting rays by direction.
Turns out the is_sign_positive() method is slower than a simple
comparison.
2017-04-22 11:15:17 -07:00
8b14e46bc1 Added more detailed render stats. 2017-04-22 10:31:27 -07:00
7884cff604 Added unit tests for BitStack128. 2017-04-16 23:13:34 -07:00
725bbca6a1 Eliminated some unnecessary left drift in BVH4 code.
IMO this is much easier to read.
2017-04-16 17:27:29 -07:00
92fd83a766 Actually using the None match arm in BVH4 traversal now.
It seems to maybe be just a hair faster.  But, also, it sets the
code up to try some more optimizations.
2017-04-16 17:22:51 -07:00
f93dde1810 Changed the BBox4 data layout to give a small speed boost. 2017-04-16 15:54:02 -07:00
2c4f103db5 Factored some calculations into the outer loop of BVH4 traversal.
Provides a small but noticable speed boost.
2017-04-16 00:51:13 -07:00
7d5bda2a3b Print newline before exit.
Makes it easier to scan commandline history for multiple renders.
2017-04-14 23:22:38 -07:00
a6d8de43d7 Make BVH4 calculate and store its node count.
Useful for debugging.
2017-04-14 22:14:52 -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
44e3ee8b4b Fixed nasty bug in BVH4 building.
In practice it worked fine, but only by accident.  NaN's were
being passed to the lerp_slice function, which led to the
correct result in this case but is icky and dependant
on how lerp_slice is implemented.
2017-04-14 20:25:12 -07:00
f8d47dc24a Fixed some things for building with SIMD support. 2017-04-13 23:28:26 -07:00
7f761a9489 Added custom aligned allocations to MemArena.
Used in BVH4.
2017-04-13 23:06:56 -07:00
8b1e3a3cdb Added some dev printing info. 2017-04-13 22:50:47 -07:00
573c5da5ab Got BVH4 working. Woo hoo! 2017-04-13 22:44:34 -07:00
53a14996c9 Completed first attempt at implementing BVH4.
Completely untested, so almost certainly non-functional.  But it
compiles!
2017-04-12 23:33:34 -07:00
e0c6dfbd76 Beginnings of BVH4 implementation.
- Created a traversal-order table.
- Created a function to help index into that table.
2017-04-11 23:10:54 -07:00
a2d7f9e149 Added BBox4 and BVH4 types.
BVH4 is just a skeleton (duplicated BVH) right now.  But BBox4
is complete (pending testing).
2017-04-11 14:22:11 -07:00
c05bae2636 Created a BitStack128 type and added it to Ray.
This will be used for BVH4 traversal.
2017-04-11 11:13:23 -07:00
f5ba119562 Switched to clap for command line argument parsing. 2017-04-11 10:15:32 -07:00
d9564bc005 Refactor and rework of BVH.
The BVH building code is now largely split out into a separate
type, BVHBase.  The intent is that this will also be used by
the BVH4 when I get around to it.

The BVH itself now uses references instead of indexes, allocating
and pointing directly into the MemArena.  This allows the nodes
to all be right next to their bounding boxes in memory.
2017-04-10 23:41:38 -07:00
db3e4ad129 MemArena now slowly increases the size of each subsequent block.
This seems to work more nicely than a fixed block size, because
it adapts to how much memory is being requested over-all.  For
example, a small scene won't allocate large amounts of RAM,
but a large scene with large data won't be penalized with a
lot of tiny allocations.
2017-04-10 20:49:55 -07:00
70f715ec2d MemArena now collects statistics about its usage.
You can print out statistics about the main arena used in
Psychopath by passing the new --stats flag.
2017-04-10 18:34:08 -07:00
9df864664e Fixed bug in Psychoblend. 2017-04-10 16:35:57 -07:00
6623443e2e Improved .psy file parsing error messages.
Biggest improvement: it gives you line numbers.  But also progress
on better descriptions.
2017-04-10 14:03:01 -07:00
f46e72b0ca Forgot to remove extraneous println's from MemArena.
Also updated MemArena documentation.
2017-04-10 00:50:51 -07:00
0672db3a46 Fixed some typos and formatting in mem_arena. 2017-04-10 00:32:34 -07:00
66eb01947f Improve MemArena to only do a large alloc if it doesn't fit in the current block. 2017-04-10 00:25:10 -07:00
d3b3a50a4d LightTree and Assemblies use MemArena now. 2017-04-10 00:03:49 -07:00
c82c821b31 BVH and objects now use MemArena. 2017-04-09 23:33:36 -07:00