random shader/visualization tip: when you need to visualize a value that varies over a large range, its handy to remember x/(1+x) as a way to 'squash' it from 0->inf into 0->1. tanh is good for signed x, +-inf->+-1
Conversation
Replying to
(this is basically the reinhard tonemapping operator. there are many others! ones with a toe at the bottom can work better. but when livecoding/jamming/shadertoying, having a quick x/(1+x) and tanh(x) in your muscle memory is handy)
1
3
25
last variation: in glsl/hlsl, you can turn scalar x 0->inf into a kind of blackbody heatmap via x/(float3(1,2,4)+x); change the 1,2,4 to a colour of your choice. all much better than hard clip.
3
2
43
Replying to
I struggle to see the usefulness of this?
x=1 --> 0.5
x=100 --> 0.99
x=1000000 ->> 0.99
1
1
Replying to
over that range, you'll want to substitute a bigger constant then 1.
in the end, your output range is still only 0-1 so there's only so much you can do with a single map.
1
Show replies
Replying to
That's pretty cool! I tend to just fract and scale but this looks much smarter.
Replying to
I'm also a big fan of (-sign(x),sign(x),abs(x)). Exactly 0=black. Positive green-cyan. Negative red-magenta. Could throw a tonemap on the abs.
1
1
15







