4 ms·
It's true; a public npm module will probably not be as optimized as your hand-tuned and application-specific shader effects. But for most use cases, especially
by mattdesl 11y ago
It's true; a public npm module will probably not be as optimized as your hand-tuned and application-specific shader effects.
But for most use cases, especially quick prototyping, a fraction of a millisecond isn't going to make a difference when your game is already at 60 FPS, or when your bottlenecks don't lie in the shader.
In rare cases where it makes a difference, you can just require a local file that has been optimized for your use case, or a module that you control (for semantic versioning and better reusability).
#pragma glslify: optimizedHSL2RGB = require('./hsl2rgb')
P.S. If you link to the branchless HSL to RGB, I can update the module.
- yoklov 11y agoThis seems (http://www.chilliant.com/rgb2hsv.html http://www.chilliant.com/rgb2hsv.html) to have a few implementations of color space conversions (in HLSL but that shouldn't be a difficult translation). They're not perfect but they're a good starting point. With some inlining and algebraic simplification (the kind that, unfortunately, can't safely be done by a compiler most of the time) you can get even simpler than the ones linked. For example, I've used something similar to the following for hsl to rgb before. l + (1.0 - abs(2.0 * l - 1.0)) * s * (clamp(abs(mod(h + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0) - 0.5)