This is more a theoretical question. I'm wondering what happens when I write float values into an empty RGBA texture of type gl.UNSIGNED_BYTE
in WebGL 1.0. Obviously, every channel then has 8 bits. But that wouldn't be enough to represent floating point values, would it? Nevertheless it somehow works, more or less. See part of a fragment shader code here:
precision highp float;
uniform vec2 u_Resolution;
void main(void){
gl_FragColor = vec4(gl_FragCoord.xy / u_Resolution, 0.0, 1.0);
}
When I specify the texture to be of type gl.FLOAT
(using the OES_texture_float extension), the results of course look better. But I want to know exactly why they do.
In addition: does the specified precision have an effect on the texture (to be written)?