Last week I released on github a new single-header file library for constructing and traversing BVHs on the CPU, with (short-term) plans to take traversal (not construction) to the GPU as well.
Features:
* No dependencies at all. Just add the header to your project and it works.
* Simple interface. Build using a flat array of triangle vertices.
* Builds state-of-the-art SAH binned BVH using AVX - 34ms for 260k triangles.
* Or, ~250ms for the same data without AVX, for cross-platform purposes.
* Builds wide BVHs: 4-wide and 8-wide, also in GPU-friendly format.
* BVH refitting.
* BVH optimizing: post-process your static scene BVH for ~15% more speed.
* Comparison against Embree is included (not winning yet but closing in).
Coming up:
* CWBVH for billions of rays/second on the GPU.
* OpenCL examples.
* TLAS/BLAS traversal.
The code is an implementation and continuation of my articles on BVH construction.
Third episode of the Voxel Ray Tracing in C++ tutorial. Describes ray tracing techniques using a fast CPU template / framework. Covered so far: lights, shadows, reflection, refraction. Third article covers stochastic techniques: anti-aliasing and soft shadows, using temporal accumulation.
You mean it looks funny in Safari without that setting? I am learning a ton about wordpress caching plugins, after last night's HN deluge... Perhaps I can do a tutorial on that next. ;)
Because the page doesn't specify a character encoding (ie with a <meta charset="windows-1252"> tag), the browser defaults to UTF-8, so any non-ascii character shows up as a big fat �.
This is gorgeous! You packed in not just a texture but even a scene description! And reflections! However, I have a couple of quibbles:
1. It is not C.
2. It is not 9 lines.
To elaborate on the first point, it's C++, using the functional cast syntax int(C*N), C++ includes, and a non-constant static initializer, none of which are legal in C.
To elaborate on the second point, it's not "9 lines" of C++ in the sense that My Very First Raytracer is "184 lines of C"; it's only 9 lines in the sense that it has two lines of #includes, and then you've chosen to insert six newlines into it at essentially arbitrary locations! Conventionally formatted, it's 45 lines of C++, which seems in keeping with my estimate that the basic raytracing algorithm is about 20 lines of code if you have linear algebra, while having to implement linear algebra adds another bit of code that's slightly larger than 20 lines.
I'm not sure how to define logical lines of code for K, but it seems relevant that one of those 7 lines defines two nested functions.
Here's the reformatted version of your Tinytrace, which I look forward to studying in more detail:
#include <cmath> // sqrt
#include <cstdio> // fopen
int i, p = 0, h[] = { 3 << 16, 8 << 24, 0, 41944064, 8 };
FILE *f = fopen ("o", "wb");
int main() {
fwrite (h, 2, 9, f);
for (; p < 9 << 17;) {
float x = 0,
T = .2,
Y = p % 1024 / 430. - 1,
R = p++ / 327680. - 1,
E = 3,
C = 1 / sqrt (Y * Y + R * R + 1),
I, t, N, A;
Y *= C;
I = 1 | -(Y < 0);
R *= C;
a:
t = x - I;
A = T - I;
N = Y * t + R * A - C * E;
A = N * N - t * t - A * A - E * E + 1;
N += sqrt (A);
if (N < 0) {
E += N * C;
x -= N * Y;
T -= N * R;
t = x - I;
A = T - I;
N = 2 * (Y * t + R * A - C * E);
I = -I;
Y -= N * t;
R -= N * A;
C += N * E;
goto a;
}
fputc (i, f);
if (R < 0) {
N = (3 - T) / R;
i = Y * N;
R *= .4 - (((i + int(C*N)) & 1) + .6);
}
i = R > 1 ? 255 : R * 255;
}
} // "TINY TRACE" edition - JB'22 (but reformatted)
For anyone else who wants to run it, you will probably want to rename the output file "o" to "o.tga", because it's a TARGA-style uncompressed image.
reply