Follow

Made a #timer as an #OpenGL #GLSL fragment #shader (function from (x, y, t) to colour).

Oriented box signed distance function from Inigo Quilez:

https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm

Segments activated by a load of conditionals on each digit's value.

Digits found by repeated divmod 10 stuff, after multiplying by 10000 (sets maximum number of digits after the point).

Leading zeros stripped with a simple loop (that stops at the point). I have code to strip trailing zeros too, but changing values are seldom affected.

Anti-aliasing of the decimal point seems to be a bit off, looks a bit too blurry. Want to add an option to move it to the baseline too.

Currently there are controls for glyph size, point size, segment length, segment thickness, foreground and background colours.

Eventual aim is to port the number rendering to the zoom video assembler I've been working on, to display zoom depth. Will need some extra fiddling, as that needs to be in log-domain and expanded to scientific notation without overflow.

Need to add motion blur to the zoom assembler first, otherwise the least significant digits will be too stroboscopic.

@mh8 thanks! https://github.com/claudeha/fragm-examples/blob/55b2daac0913e100c1bbfd7fe5e738e36510fad1/00-ScientificNotation.frag#L27 is the relevant part of the code.

I suppose the motion blur will smear out the rings thicker eventually to uniform grey (possibly speckled due to limited sample count). Then it will probably go all black or all white when it overflows to infinity - single precision float only goes to 1e38 or so...

Actually, even before infinity there may be problems, when `r -= floor(r)` becomes always 0 due to limited precision, at 2^24, with gradual degradation on the way there...

I may try it later and report back!

claude@mathr@post.lurk.orgGot (base 10) #ScientificNotation numeric display working with log-domain (base 2) input (so that exponent is not limited by single precision floating point). I just need to finish up adding minus sign support for the exponent (it can go negative)...

#OpenGL #GLSL #shader #zoom