47c2bf4ed9
Almost have configurable arity for light tree building.
...
Just need to fill in a couple of functions with non-temp code.
2017-06-29 00:29:23 -07:00
b891cc943b
Light tree can now be traversed with arbitrary arity.
...
Next up is building with configurable arity.
2017-06-28 23:20:03 -07:00
27c635982e
Adjusting light tree implementation in prep for configurable arity.
2017-06-28 22:51:20 -07:00
4e9bfd6e79
Fix for ray origin offsets when intersection point is at 0.0.
...
For some reason the ulp incrementing is unreliable when starting
at zero. It creates subnormal numbers, and that seems to be an
issue somewhere in the pipeline, ultimately leading to weird
render artifacts. Not entirely sure why.
This fixes it by avoiding subnormal numbers in the final offset
ray origin. Left a note suggesting investigating in more detail
at some point.
2017-06-21 01:36:08 -07:00
927a86c1fc
Update LightArray to work with current code.
...
It's useful for checking correctness.
2017-06-20 23:28:49 -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
2c0e57341c
XYZ color curve functions need more accurate exp function.
2017-06-15 22:50:27 -07:00
f649bec585
Reformat code with rustfmt 0.9
2017-06-15 22:00:31 -07:00
Guillaume Gomez
ae11be1397
Improve messages for imge creation
2017-06-14 10:46:28 +02:00
851989f6a6
Added a license and licensing notes.
...
Also replaced some code I'm not sure where it came from or what
the license was.
2017-06-11 21:29:51 -07:00
b8321beaad
Split colorspace transform functions out into their own crate.
...
They are now generated by a build.rs script from nothing but the
colorspace's primaries, which makes it super easy to add more
colorspaces. So easy that I added three more: ACES AP0, ACES AP1
and Rec.2020.
This lays the foundation for supporting output to different
colorspaces.
2017-06-11 03:03:23 -07:00
2a66485595
Supress information output when doing serialized ouput for PsychoBlend.
2017-06-10 22:34:14 -07:00
71c320d87c
Added command-line argument to render an image cropped.
2017-06-06 21:11:35 -07:00
59555f67f9
PsychoBlend: use stdin/out to transfer scene data by default.
...
This eliminates writing temp files to disk for any part of the
Blender/Psychopath integration.
The option to export to a file still exists, however, by
specifying an export output path.
2017-06-04 23:24:45 -07:00
a3332d4f6a
Fixed a PsychoBlend bug that resulted in render not being fully displayed.
...
Getting the interplay between the reading the process output and
polling to see if it's finished is a tad tricky. I think I got
it right this time.
2017-06-03 01:12:21 -07:00
f84d093f66
PsychoBlend now updates render in realtime within Blender.
...
Also, cancelling renders is much more responsive now, especially
during long exports.
2017-06-03 00:00:19 -07:00
3beffab507
Update to latest openexr-rs, and switch to pure Rust PNG output crate.
2017-05-28 17:51:01 -07:00
f0604a69ae
Updated to latest openexr crate, and switched to 16-bit float EXR's.
2017-05-20 23:48:01 -07:00
4e2d3e64c0
Switched to using the openexr crate on crates.io.
2017-05-17 00:36:35 -07:00
edb71864e8
LDS sampling falls back on random sampling at higher dimensions.
...
This is more a piece-of-mind thing than anything else. But it
also lets us make the number of LDS dimensions lower without
worrying, which in turn makes the code smaller.
2017-05-14 16:06:54 -07:00
322627641a
Broke render job out into its own method.
...
The left-drift of having it inline was getting cumbersome.
2017-05-14 14:51:55 -07:00
922e33ec3f
Reformat code with latest rustfmt and custom config.
2017-05-14 13:43:51 -07:00
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
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
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
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
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
e9e202933f
Assembly type now partially uses MemArena.
2017-04-09 18:27:01 -07:00
fc15fa9192
World type uses memory arena now.
2017-04-09 17:56:06 -07:00
57aa9be496
First steps towards using the memory arena allocator.
...
Changed Camera to us the memory arena allocator, and worked out a
bunch of stuff through doing that.
2017-04-09 17:31:17 -07:00
f6ffd8d30b
Fixed a typo in a comment.
2017-03-29 13:20:58 -07:00
7223f69151
Implemented a more efficient orthonormal basis function.
...
Algorithm taken from the paper "Building an Orthonormal
Basis, Revisited" by Duff et al.
2017-03-29 13:19:51 -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
0b05d364e4
Added GTR surface closure.
...
Not tested yet, just a straightforward conversion from the C++
Psychopath codebase. So there are probably bugs in it from the
conversion. But it compiles!
2017-03-07 08:31:57 -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
d504ca5e6a
Got DistantDiscLights working! Yay!
...
This involved fixing a bug in PsychoBlend. It was including
translation in how it was transforming the sun lights' direction
vector.
2017-02-13 00:03:34 -08:00
3cbb816d4b
Added DistantDiskLight (a.k.a. sun light) parsing and data structures.
...
Also created a proper World struct in the process, to store all
infinite-extent type stuff.
Note that I goofed and did a new rustfmt pass but forgot to
commit before making these changes, so there's a lot of
formatting changes in this too. *sigh*
2017-02-12 20:29:08 -08:00
746b3b0c1f
Replaced try!() macros with new ? operator.
2017-02-06 16:20:58 -08:00
0e8d708ff0
Made samples per bucket configurable.
2016-10-16 14:55:00 -07:00
bb4e57795f
Added support for OpenEXR output.
2016-10-09 20:34:58 -07:00
0d189f763d
Changed LightTree traversal to be a bit better in its choices.
...
After some experimentation, it's pretty clear that the LightTree
performs a lot better with a model of spherical _volume_ light
sources. This makes sense considering that generally they
represent a distribution of other lights in space.
This is a quick hack to make it behave a bit more like that. But
the long-term solution will be to adjust how
estimate_eval_over_solid_angle() of surface closures is implemented.
2016-08-21 15:27:15 -07:00
7f1ab59c5e
Implemented alternative SAH split that uses off-axis split planes.
...
It doesn't seem to actually perform better, generally, but I'm
leaving it in for future reference for other things.
2016-08-21 15:26:47 -07:00
c71b00ca31
LightTree now works with lights in hierarchical instancing.
2016-08-21 00:19:43 -07:00
97b5ef77f8
Code cosmetics: organize and alphabetize crate/mod/use statements.
2016-08-20 18:10:55 -07:00
f75c0c78fe
Moved TransformStack into its own module.
...
It's clear at this point that it will be useful outside of Tracer.
2016-08-20 17:43:26 -07:00
c997c55739
Separate timing of rendering and image writing in print out.
2016-08-20 16:25:12 -07:00
cf49cdbb02
Moved int hash functions into own file, and use in quick_select().
2016-08-14 16:03:17 -07:00
fbeadfce29
Use quick select for balanced BVH building.
...
This gets rid of a crate dependency, and also is faster.
2016-08-14 00:51:21 -07:00
024ca560af
Minor optimization in the transform stack.
...
Got rid of the scratch space by writing directly into the main
stack vector when merging transforms. Involves a small bit of
unsafe code.
2016-08-06 01:51:20 -07:00
08576b9934
Cleaned up console output.
2016-07-31 12:27:06 -07:00
c6f6266a38
Added timer output so you can see how long things take.
2016-07-31 12:05:28 -07:00
d12b76a933
Minor tweak to horizontal add and multiply for Float4.
...
In theory this should make it more pipeline-able.
2016-07-31 11:49:01 -07:00
b4939f88c8
Silence some warnings.
2016-07-31 11:19:30 -07:00
3e7b142cd8
Implemented light tree sampling, for better sampling of many lights.
2016-07-31 11:14:33 -07:00
1f94791b6b
Moved SAH splitting code into its own function.
...
This is in prep for the light tree, where we'll want to use that
code.
2016-07-30 21:20:01 -07:00
7ef5846c89
Got rid of indexing into Float4 and 3d vector elements.
...
This assures correct semantics for SIMD usage.
2016-07-30 19:36:54 -07:00
e4c94d0c58
Optional use of SIMD intrinsics, via feature in cargo.
...
This is disabled by default right now, because it only builds on
nightly.
2016-07-16 19:58:39 -07:00
4db96bc758
Use simple if-statement-based min/max functions in hot code.
...
Again, for whatever reason this is notably faster than the stdlib
min/max functions.
2016-07-16 17:55:18 -07:00
7401c6fb99
Use fast approximate exp functions for XYZ color curves.
...
This brings a significant performance improvement, and doesn't
appear to have any visual impact.
2016-07-16 17:53:50 -07:00
177bb95eff
Got rid of UnsafeCell in Tracer.
...
To do this, I moved the accel rays into an outer struct, which
then calls the main tracing code as an inner struct.
2016-07-16 16:26:34 -07:00
1571c1634e
Sped up min and max functions in Float4.
...
Turns out that the standard min/max functions were slow for
some reason, and simple if statements are much faster. This
simple change improves render times by over 30%. Crazy.
2016-07-16 15:56:14 -07:00
76f074f866
Added a TODO comment.
2016-07-16 15:10:07 -07:00
ec75f11206
Render buckets in hilbert curve order.
...
Provides a slight speed-up.
2016-07-16 14:53:03 -07:00
5bc97f69b8
Actually use the background color from the scene file.
2016-07-16 13:54:41 -07:00
8cd445813a
Removed some dead code.
2016-07-16 13:36:34 -07:00
9d47dfdeb2
Forgot one place where bounds need to be merged for motion blur.
2016-07-16 12:28:08 -07:00
2e3851837d
Implemented SAH splitting for the BVH. Also fixed crash bug.
...
The bug was in the previous commit, where I thought I was
preventing out-of-bounds access during traversal by limiting
the tree depth. While the idea was correct, I forgot that the
traversal stack needs _2_ extra slots on top of the tree depth,
not just 1. Fixed.
2016-07-16 03:21:57 -07:00
35ef58b09c
Special case BVH building when we get too close to max depth.
...
This avoids exceeding max BVH depth even in pathological cases.
Still need improve non-worst case building, but this at least
prevents crashes in worst case.
2016-07-16 00:05:23 -07:00
e2ef44f666
Finished implementing motion blur.
2016-07-10 19:20:37 -07:00
c2eb421fd8
Actually use seed in renders.
...
This is important for animations, where you don't want the same
noise pattern every frame.
2016-07-10 17:56:42 -07:00
e4f9a54e48
Leave console output on a newline.
2016-07-10 17:47:28 -07:00
c466e46138
Make BVH traversal stack bigger.
...
This is a stop-gap for a less-than ideal BVH construction. It
should be reduced again once the BVH building is made less stupid.
2016-07-10 17:45:10 -07:00
5b461220a5
PsychoBlend now exports meshes as meshes, and Psychopath renders to PNGs.
2016-07-10 17:42:28 -07:00
e8ee371423
Silence some warnings.
2016-07-10 16:46:14 -07:00
da46878243
Print render progress and auto-determine bucket size.
...
The bucket size is automatically determined based on a target
number of samples per bucket.
2016-07-10 16:40:30 -07:00
5df583c2d0
Multiple light sources are now handled.
2016-07-10 00:10:49 -07:00
9c8797ffd8
Forgot to do top-level ray splitting.
2016-07-07 23:47:44 -07:00
aff8d24f55
Fixed some bugs where instances without transforms would crash.
2016-07-07 23:32:19 -07:00
3ef84f9f5f
Split rays by direction so they can follow their ideal traversal order.
2016-07-07 21:50:03 -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
543f2719e4
Fixed bugs in global illumination.
...
It was a stupid thing in the Lambert closure. It was returning
the wrong direction vector.
2016-07-04 11:54:46 -07:00
a8324669cc
Fixed possible out-of-bounds panic in XYZ -> Spectrum code.
2016-07-04 01:26:28 -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
6e8f0894fd
Image struct can now dole out buckets in a thread-safe way.
...
This avoids the whole-image locking that was being done before,
which was causing a lot of thread contention.
2016-07-02 16:27:19 -07:00
02a0740cac
More proper use of light sources.
2016-07-01 00:00:38 -07:00
24cbdb5ab9
Fixed bug in ray/triangle intersection code.
...
It was counting intersections behind the ray.
2016-06-30 19:33:44 -07:00
f927dd0d46
Silencing a bunch of compiler warnings.
2016-06-29 15:23:07 -07:00
f1df7a3b1a
Slight tweak to how ray offsets are done.
2016-06-29 15:00:44 -07:00
52acee33af
Implemented rectangular area lights.
...
Also added Cornell Box test scene.
2016-06-29 14:30:42 -07:00
fd195576d1
First renders with lighting. Yay!
...
The lighting is super crappy, and pretty much hacked in. Will
need to redo this properly soon. However, this verifies that
certain other parts of the code are (mostly) working properly.
2016-06-27 23:16:39 -07:00
3b85b60a62
Implemented occlusion rays.
...
This is prep for lighting support: occlusion rays are useful for
speedier shadow tests.
2016-06-27 21:01:18 -07:00
6f6807009b
Prepping for adding lighting.
...
The part of the renderer responsible for light transport has been
split out into a LightPath struct. Also moving over to spectral
rendering, although it's a bit silly at the moment.
2016-06-26 23:08:24 -07:00
f7e57f2aee
Scenes with lights now get parsed correctly.
2016-06-25 22:49:40 -07:00
c2d36e0d14
Beginnings of parsing sphere lights.
2016-06-23 20:46:57 -07:00
1cbf20e67f
Beginnings of light sources. Yay!
2016-06-19 14:32:13 -07:00
d14e2c93b7
Converted Image over to store renders in XYZ colorspace.
2016-06-18 18:08:35 -07:00
18245b725c
All final intersections are now done in world space.
...
BVH traversal still happens in local space, but final actual
surface intersection calculations are done in world space by
transforming the triangle into world space. This is to improve
numerical consistency between intersections.
2016-06-09 01:04:12 -07:00
e2954ba5b0
Added more code for handling XYZ color and spectral samples.
2016-06-08 23:00:09 -07:00
61e3d47f56
Changed BBox/Ray intersection code to use more simd ops.
...
This, of course, depends on the simd ops being there, which
currently they are not. But in the future, hopefully this will
make things speedy. Will need to test, of course.
2016-06-08 22:57:22 -07:00
890c04c44a
Added XYZ color spectrum sampling code.
...
This will be critical for spectral rendering, whenever I get
around to it.
2016-06-07 08:14:19 -07:00
0b5a3de2dd
Added command line flag to set number of render threads.
2016-06-05 10:08:27 -07:00
5ec1f534cf
Implemented bucketed rendering.
2016-06-05 01:27:55 -07:00
a681ba461e
Implemented basic multi-threaded rendering.
...
It's a bit inefficient because a thread is spawned for each pixel.
Need to implement bucketing.
2016-06-03 21:03:04 -07:00
43c5a94ebb
Cleaned up command line options. Removed old procedural scene code.
2016-06-02 23:00:31 -07:00
039943e0cb
Auto-formatting code with new version of rustfmt.
2016-06-02 22:43:35 -07:00
c3d3145817
Fixed bug in ray intersection code.
...
The max_t was getting overwritten during transforms.
2016-06-02 22:36:02 -07:00
848d0afd40
Some minor code formatting cleanup and debug printing.
2016-05-28 14:35:37 -07:00
ef31093dcb
Split xform stack out into its own type.
...
This is mainly just to make the tracer code read more cleanly.
All of the pushing and popping logic obscured the big picture
and made things a bit confusing.
2016-05-28 14:15:05 -07:00
56b5267b7a
Fixed incorrect rendering angle.
...
The problem was in how the camera rays were generated.
2016-05-28 13:05:16 -07:00