u/Tima_Play_x

Voxel graphical calculator
▲ 16 r/bevy+1 crossposts

Voxel graphical calculator

I just released v0.1.0 of HyperVox, a voxel graphical calculator for N-dimensional mathematical expressions.

It takes one or more mathematical expressions and renders them as 3D voxel graphics. Expressions are evaluated over an N-dimensional space, so shapes can be defined in more than three dimensions.

Each expression is parsed and evaluated into a sign grid. All sign grids are composited front-to-back into one voxel grid, where each voxel takes the color of the first expression that fills it. A single mesh with per-corner ambient occlusion is built from that composite.

With more than three dimensions, only the three dimensions mapped to the X, Y, Z axes vary spatially; the rest are held at fixed values, so the render shows a 3D slice of the N-dimensional space.

AI Usage: At the start of this project, I used AI extensively to understand how to use Bevy and compile it to WASM (though AI didn't help much with the WASM compilation part). Since then, I've used AI to analyze the codebase and generate optimization ideas, which I then benchmark and verify. If an AI-suggested optimization gives a >10% speedup, I ask it a few questions about the implementation details and then write the final code myself, as AI often struggles to produce optimal, idiomatic Rust. I also use AI to review almost all of my commits/PRs to catch anything I might have missed or done unidiomatically.

Why I'm posting: I have run out of ideas for optimizations and would love your help finding other ways to speed up the regeneration time!

Current optimizations:

  • Using a custom expression evaluator (hypervox_expr) instead of evalexpr
  • "Compiling" expressions to Box<dyn Fn> instead of evaluating with a large match block
  • Constant folding and algebraic simplification
  • Common subexpression elimination (CSE) using let n = x in {expr}
  • Fused MulAdd
  • Multi-level invariant hoisting
  • unsafe set_len to skip zeroing memory (buffer is immediately overwritten)
  • Multi-threaded memory copying using split_at_mut and copy_from_slice
  • Ambient Occlusion (AO) caching
  • Multi-threaded grid/composite computation

Also, if you have ideas about new features or UI improvements, please share them with me!

u/Tima_Play_x — 16 hours ago