haxiomic / vector-math

Shader-math in haxe: library for GLSL vector operations, complete with swizzles and all
MIT License
39 stars 7 forks source link

single precision types #2

Closed shakesoda closed 3 years ago

shakesoda commented 3 years ago

I can imagine this being out of scope since it's not available on all/generic targets, but it'd be useful to support Single (i.e. f32) type for perf/memory reasons on cs/cpp/java/hl when full f64 precision isn't required/desired.

haxiomic commented 3 years ago

This is a great idea, maybe behind a parameter -D vector-math-single? Although it might make sense for Single to be default, especially if these outputs are most likely used to set f32's in graphics APIs

shakesoda commented 3 years ago

a build flag would work great for me. it's a reasonable default for my usage but it might be better to leave it as f64 for consistency across targets, and maybe spare some people from running into unexpected precision (or runtime - hashlink jit has some rough edges here) bugs.

haxiomic commented 3 years ago

Added -D vector_math_f32 in https://github.com/haxiomic/vector-math/commit/ed5aee7d19e466f54bde85f0a66c30506513c752

When used generated C++ code simply has float for vector vars