I am on the verge of going insane, I hope the gurus here can shed some light on what I’m experiencing. I’m trying to output precise RGB values to a canvas, and I noticed that the RGB values I’m getting in the output are different from what I specify in gl_FragColor.
Here is a simple Codepen that demonstrates this: https://codepen.io/gugray/pen/QWxEWoB
Specifically, with the line below:
gl_FragColor.rgb = vec3(1.0, 1.0, 1.0);
I get white (255, 255, 255) as expected. Black also works.
Things make no sense whatsoever with any of the values in between:
gl_FragColor.rgb = vec3(1.0, 0.0, 0.0); // Yields 234, 51, 35. Expected: 255, 0, 0
gl_FragColor.rgb = vec3(0.5, 0.5, 1.0); // Yields 128, 128, 247. Expected: 128, 128, 255
gl_FragColor.rgb = vec3(0.5, 1.0, 1.0); // Yields 161, 252, 254. Expected: 128, 255, 255.
What is happening here? There must be something mind-bogglingly trivial that I’m missing, but I cannot for the life of me figure out what. Any help is life-saving at this point and appreciated as such!