Colors on the web are treated as perceptually linear. 50% gray appears half as bright as 100% white.
However, if you interleave white and black rows of pixels, it looks like ~70% gray, not 50%. This demonstrates that having only 50% of the photons still looks 70% as bright. Keep this in mind if you are resizing anything!
But the web deals in perceptual values, not physical photon counts.
The human eye is much better at seeing small differences between dark values, but not so much for small differences between bright values. In other words, going from 5% to 15% is obvious, whereas 85% to 95% is more subtle.
EXT_sRGB is for improving the fidelity of dark "low-tones", while sacrificing precision of bright "high-tones". About 70% of the shades representable by sRGB are darker than 50% gray. sRGB encoding is an 8-bit HDR compression, though still [0,1]
.
Generally in order to do math on colors, we want to operate in linear (preceptual) space again, so that's what your shader gets when you sample from an sRGB texture format. A texture value of 70% is decoded into a ~50% preceptual value as part of sampling.
WebGL 2 supports sRGB formats for textures and framebuffers. (in WebGL 1, you need EXT_sRGB) However, there's no way to explicitly ask for an sRGB backbuffer to preserve high-quality blacks.
To support sRGB-accurate output from WebGL, the browser compositor would also need to render into sRGB surfaces, and Firefox does not do this. (Safari might, Chrome might) It's likely easy to get WebXR to use sRGB backbuffers as well, since it uses a different presentation path.
Really really don't worry about this. It was to deal with the non-linearity of CRTs, but we're stuck with emulating it forever as a legacy to CRTs. It's largely a coincidence that monitor gamma is close to sRGB gamma.
sRGB texture formats are a storage format, not a different color space.
It's for squeezing more low-light precision into 8bit.
0.5f has the same value but different storage representations:
Always prefer sRGB encoded formats for 8bit color, but only if your whole presentation chain use sRGB encoded formats all the way to the display!
(live for now: https://repl.it/repls/ProfitableLovingBlock)