Commit Graph

114 Commits

Author SHA1 Message Date
c5965ec874 Replace some custom math functions with stdlib functions.
Some of these didn't exist in stable Rust before, and some of them
used to be slower than the custom ones.
2022-05-15 23:00:49 -07:00
89fc80b99b Update to the latest version of sobol_burley. 2021-05-14 11:30:48 -07:00
63d661f8ce Update sobol_burley dependency. 2021-05-11 20:17:51 -07:00
706902dc8e Move sobol crate outside of Psychopath into its own repo. 2021-05-11 13:35:17 -07:00
45241784fb Code tidying on the Sobol sampler.
Also swapped the sample index and dimension paramater in the function
signature.  This feels more intuitive.
2020-04-30 22:46:47 +09:00
0dfe916523 Preparing for SIMD accelerated Sobol sampling.
This implements the 4-wide API, and moves the renderer over to it.
But the actual implementation is still scalar.
2020-04-24 21:05:29 +09:00
2c68e18bd6 Use golden ratio sampling for wavelength again.
Now that the Sobol sequence can be decorrelated, this doesn't
introduce sampling correlation problems anymore, so it's mostly
just a win.
2020-04-23 14:46:21 +09:00
29fcc69ae1 Move seed hashing into the lk_scramble function. 2020-04-23 13:36:04 +09:00
c0a8c955c4 Make LightPath::new() harder to mis-use. 2020-04-23 08:32:44 +09:00
22b7151919 Use independent Sobol sequences for different sets of dimensions.
This reduces correlation artifacts, while preserving good convergence
for the most part.
2020-04-22 18:48:12 +09:00
085d1d655e A single unified Sobol implementation.
This version of Sobol implements both Owen scrambling and index
permutation, allowing for multiple statistically independent
Sobol sequences.
2020-04-19 01:11:43 +09:00
b74a58cb72 Improvement for sampling at low sample counts. 2020-04-17 11:04:33 +09:00
8deb305850 Use a much better approximation of the probit function.
For 32-bit floating point, it can essentially be considered exact.
2020-03-27 21:19:24 +09:00
3916043f33 Removed golden ratio sampling.
Turns out it causes interference with the Sobol sampler.

Also tweaked some other things about sampling after removing
golden ratio sampling, to make things better.
2020-03-19 19:49:45 +09:00
9e14e164e7 More improvements to Sobol sampling.
- Added an additional scramble round to the Owen scrambling, with
  new optimized constants.
- Reordered the dimensions of the direction numbers to improve 2d
  projections between adjecent dimensions.  Only did this for
  dimensions under ~40.
2020-03-18 12:05:42 +09:00
de5a643a2a Implement Sobol sampler that does both Owen and Cranley-Patterson.
This seems to work well in practice, and only takes one more addition
operation.
2020-03-17 20:00:09 +09:00
e3152e6f9c Add alternative Sobol direction numbers to the repo.
Also switching to one of the alternates, as it seems to give
better results than the one I was using before.
2020-03-17 16:49:19 +09:00
04a5dbff43 Generate sobol direction numbers from text file.
This way the numbers aren't cluttering up the source file, and
this also makes it easier to play with other direction numbers.
2020-03-17 15:21:15 +09:00
d49a1c4921 Clean up the sampling code a little.
All of the samplers were using the same scramble value, so I
factored it out and documented its intent.
2020-03-16 10:14:09 +09:00
5114d428da Use the seed value in random value generation.
I forgot to add this in.  It wasn't noticable, since the QMC
sequences did use the seed, and we probably don't ever get to
the random values for 15+ light bounces.  But it seems worth
fixing anyway!
2020-03-16 09:57:01 +09:00
047e66d9aa Reworked Sobol sampler implementation.
This produces identical results, but generates the direction
vectors from the original sources at build time.  This makes
the source code quite a bit leaner, and will also make it easier
to play with other direction vectors in the future if the
opportunity arises.
2020-03-15 22:01:06 +09:00
42a6c1e9cd Use proper wrapping arithmetic in the golden ratio sampler. 2020-03-15 18:10:03 +09:00
9b4781c81d Multiple improvements to sampling.
1. Use better constants for the hash-based Owen scrambling.
2. Use golden ratio sampling for the wavelength dimension.

On the use of golden ratio sampling:
Since hero wavelength sampling uses multiple equally-spaced
wavelengths, and most samplers only consider the spacing of
individual samples, those samplers weren't actually doing a
good job of distributing all the wavelengths evenly.  Golden
ratio sampling, on the other hand, does this effortlessly by
its nature, and the resulting reduction of color noise is huge.
2020-03-15 14:47:40 +09:00
e0cb436209 Minor sampling refactoring. 2020-03-13 14:51:14 +09:00
a3ea90afdc Fixed broken Owen scrambling.
The previous implementation was fundamentally broken because it
was mixing the bits in the wrong direction.  This fixes that.

The constants have also been updated.  I created a (temporary)
implementation of slow but full owen scrambling to test against,
and these constants appear to give results consistent with that
on all the test scenes I rendered on.  It is still, of course,
possible that my full implementation was flawed, so more validation
in the future would be a good idea.
2020-03-12 20:20:56 +09:00
b081424ba6 Implemented Owen scrambling for the Sobol sampler.
This gives better variance than random digit scrambling, at a
very tiny runtime cost (so tiny it's lost in the noise of the
rest of the rendering process).
2020-03-11 18:29:46 +09:00
8d16719cd2 Use a different function for giving pixels unique ids. 2020-02-22 11:59:08 +09:00
4a6284be40 Switch to sobol sampler.
The important thing here is that I figured out how to use the
scrambling parameter properly to decorrelate pixels.  Using the
same approach as with halton (just adding an offset into the sequence)
is very slow with sobol, since moving into the higher samples is
more computationally expensive.  So using the scrambling parameter
instead was important.
2020-02-22 09:18:45 +09:00
3d9eb23e1c Run rustfmt. 2020-02-22 07:36:44 +09:00
0b493b09ca Handle LDS permutation a little differently.
This produces identical results, but makes it easier to play
with other types of sequences.
2020-02-22 07:34:51 +09:00
88e7365bc4 Switched from in-tree float4 lib to glam. 2019-07-22 22:30:37 +09:00
c4b8971805 Clean up compiler warnings. 2019-06-29 12:43:24 +09:00
5a53d7f6f6 Added some additional ray tracing stats. 2019-06-29 09:20:04 +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
caa4ea3e44 Replaced SurfaceClosure trait with a SurfaceClosure enum.
Also moved surface closures to using Color internally for color
specification.
2018-12-27 22:57:44 -08:00
28a07de456 Improve module path usage and remove extern crate declarations where possible. 2018-12-16 13:02:49 -08:00
8deb1e87bb First step transitioning to Rust 2018. 2018-12-16 12:02:20 -08:00
e3a9cbef84 Silenced/fixed the last of the clippy warnings. 2018-12-16 11:48:01 -08:00
c73db2edbe Fix/silence a bunch of clippy warnings in the main crate. 2018-12-15 23:26:12 -08:00
498c1ea8d9 Running latest rustfmt. No functional change. 2018-10-30 22:31:25 -07:00
caeb1d9c67 Added GGX glossy material, and simplified surface closure API. 2018-08-09 00:42:17 -07:00
6d21a30840 Formatting with newer cargo fmt.
No meaningful code change, only formatting.
2018-06-24 21:18:10 -07:00
97d3304149 Run new rustfmt on codebase. 2018-03-04 13:00:55 -08:00
072d366892 Changed SurfaceLight API to return the sample point on the light.
More specifically: prior to this, SurfaceLights returned the
shadow ray direction vector to use.  That was fine, but it
kept the responsibility of generating proper offsets (to account
for floating point error) inside the lights.

Now the SurfaceLights return the world-space point on the light
to sample, along with its surface normal and error magnitude.
This allows the robust shadow ray generation code to be in one
place inside the renderer code.
2017-08-17 13:09:48 -07:00
5a03a46ac7 Multiple importance sampling is now basically working.
Intersecting rectangular lights still isn't implemented, and there
are likely bugs in the MIS implementation, but it's more-or-less
working!
2017-08-16 20:04:06 -07:00
6f5984a379 Implemented proper handling of Emit surface closure. 2017-08-08 14:31:31 -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
0481d931b9 Surface closures and light sampling now take both shading and geometric normals.
This will allow them to appropriately handle weirdness that comes
from the shading normal and geometric normal being different.
2017-07-30 19:17:32 -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