Commit Graph

18 Commits

Author SHA1 Message Date
a4a389c10d feat: Job dispatcher hooked up*
The job dispatcher has been hooked up and four threads are rendering the
scene. There's a super important caveat, though: The job submission is
blocking and will prevent the main thread from continuing to the result
collection. The threads will be unable to contiinue without having
output space, though. Since the buffers are only size 1, this will cause
4 scanlines to be rendered, and then nothing else to be done. Deadlock.
Bumping the input buffer to 100 lets the submission loop fill up the
workload and then move on to collecting.

There's also no scanline sorting, so everything gets <<wiggly>>.
2023-06-24 20:56:28 -05:00
497ea94fbf feat: Thread job dispatching!
There are now two threads: The main thread (obv) and a single worker
thread to render lines. There's a render context struct to keep track of
the many, many arguments to the `render_line()` function. Jobs are
submitted through a channel to the thread, and results are returned
through another. Next up is to make a bunch of threads and collect
across them.
2023-06-24 16:24:28 -05:00
814a65859a Hittables as enum instead of trait objects
I hit an issue implementing the threading where the use of trait objects
got real angry about lifetimes. The variants of geometry could be
described as a runtime variable (thus requiring dynamic dispatch), but
I'm not gonna do that. Instead: Enums!
2023-06-24 11:36:23 -05:00
d97b4ced83 Feat: Single-line rendering function
Laying the groundwork for setting up threading. Gotta be able to run
parts of the render to get multiple things working on the whole.
2023-06-23 19:52:43 -05:00
6dd6befed0 chore: Turn down the image resolution for testing
For some reason I feel it necessary to make this its own commit. I might
be for real losing my mind.
2023-06-23 19:52:36 -05:00
0b31f66bbf fix: Corrected the distributions
I had been carrying the distributions around with the SmallRng object so
that I can provide whatever bounds needed. It turns out that the book
only takes advantage of this a couple of times.

The functions accepting a Uniform struct no longer do. They instead
construct their own temporary one -- hopefully the optimizer can see
through the loops and construct it just once. :l

The change exposed all the uses of the distributions (duh!) and now they
are correct. The effect is most pronounced on the dielectric spheres.
2023-06-06 20:47:32 -05:00
0c9949bbb8 Feat: (Pseudo) Random world generation
Final render! The world is pseudorandomly generated. The glass ball in
the middle doens't come out quite right, though. I think there are bad
random ranges being passed around. Things are using (-1,1) when they
should be [0,1). Bug fix incoming.
2023-06-06 20:16:28 -05:00
b6ec544b3e Feat: Simulate depth-of-field
And with that, I'm on to the final render. Chapter 12 closed!
2023-06-06 19:14:17 -05:00
b7ec69dc7f Feat: Camera positioning
The camera can now be fully described in 3D space. Close of Chapter 11.
2023-06-06 18:37:26 -05:00
b0efc9a248 Feat: Wide-angle camera 2023-06-06 18:17:39 -05:00
7ee6da0234 Feat: Total internal reflection, Schlick's approx.
Completion of Chapter 10: Dielectrics.
2023-06-06 18:06:59 -05:00
0822096a3a chore: Unit convertor by value, clean stale code
The Vec3::as_unit() function accepts input by reference. It passes back
out a copy, however, and some inputs are even temporaries. I bet the
optimizer can see through this game and will do the right thing if I
give it a value instead. It should perform copy elision as appropriate,
even if I'm missing out on Rust's move semantics here.

Remove some old, unused, and unuseable functions.
2023-06-06 17:43:29 -05:00
4ea2208208 Feat: Rudimentary dielectric... but broken
Dielectric material matching Raytracing in a Weekend book chapter 10.2.
But it isn't right. The spheres turn into solid black holes.

As I'm making the commit, I've found the problem. I'm separating it out
so I can tag it and explore the code a bit more. See the step-by-step
changes, and such.
2023-06-06 17:39:09 -05:00
2a40258737 chore: Unused imports, use good bounds. 2023-06-04 18:33:23 -05:00
16762906a7 fix: Remaining scanlines, not completed
I forgot I reversed the range. Didn't notice until I tried out a
1920x1080 render and realized it was counting *up* when it said
"remainding."
2023-06-04 16:28:58 -05:00
7926cd2b13 Feat: Materials!
Got the enums to work. This match block is going to be absolutely
massive, but whatever. Current materials are Lambertian and Metal.
2023-06-04 10:31:59 -05:00
d1bde8a1a8 Spurious crashes - Switching to enums
Segfaults and stack overflows. I get overflows when running in either
debug or release. Segmentation faults when hooked up to GDB. I think it
may be related to the copying of uninitialized trait objects, but I
don't know.

I've decided the trait-based interface just isn't worth this. I'll
rearrange the materials into an Enum and a big match block.
2023-06-04 09:19:25 -05:00
5cc0b49cd9 Mid-Material save point
I get lazy with commits when following guided material. There's a design
challenge to approach, now. I'm saving here so I can revert changes in
case it goes sideways.

Materials are proving to be a little complicated in Rust semantics. The
Ray Tracing in a Weekend book uses shared_ptr's, but Rust doesn't really
like that. I'm doing references with lifetime annotations. Hopefully I
can get that the right way around to work out.

The materials themselves look like reasonable candidates for describing
as Enums. This takes away the ability to add new ones by simply impl'ing
a trait, but that was never gonna happen anyway. The code would be
modified and recompiled. There's no difference in maintenance cost if
that's a new struct impl'ing a trait, or adding enum members.
2023-06-03 09:48:54 -05:00