Custom shader "squared" output

Tags: #<Tag:0x00007f703a70ef48>

Hello everybody, first of all thanks to the team, this is a wonderful tool.

I’m having a strange issue, I don’t know if it’s a but or a feature, but it is definitely annoying for what I’m trying to do :
When writing a custom shader, whatever value I write to the pixels seems to be squared before it’s output to a texture. Here’s a very simple example, look at the values in the resulting color array (I write 0.5 in glsl, and it becomes 0.25 in float, and 64 using 8bit unsigned int texture :

A simple and dirty workaround would be to use the sqrt() function just before the end of the fragment shader, but this prevents me from say, using negative values for example, and it’s also not very efficient.
As you might have guessed, I’m trying to do some “gpgpu” wizardry in cables, and it took me a while to understand where this strange behaviour was coming from.

This also leads me to a more general question about cables : I can only choose between “float” or “non-float” texture, I guess “non-float” corresponds to uint_8 since it goes from 0 to 255, but what pixel format is “float” then ? Are there more formats available somehow ? If not, is this a limitation of webGL in general, or is it just the way is made ?


I ended up figuring where this behaviour comes from, it’s because of alpha pre-multiplication. It would be nice this feature could be disabled manually, as it’s useful when doing alpha blending, but not in other cases such as gpgpu tinkering.