Open stephen-w-choo opened 9 months ago
The Float32 array approach seems to have paid off - it's pretty much made everything 5-6 times faster on the benchmarks.
It's still... not fast, but I'm not convinced TypeScript can be much faster than this.
Options for further gains at this point are:
Rendering is slow. I expected it to be slow given that it's a ray tracer that compiles down to an interpreted language (JavaScript), but even so, it's not ideal. Even with Bun running the native TypeScript, it's slower than I'd like.
I think that main bottleneck is the matrix calculations.
I've initially implemented the Matrix type as a plain 2d array of numbers.
I can turn it into a 1d Float32 array for efficiency, since I'm only ever using a 4x4 array of numbers. Using 32-bit floats should be more than precise enough - I don't need the default 64-bit numbers of JS