Vuo
1.2.2
|
Major data types for working with graphics:
When performing calculations on colors in shaders and other graphics code, it's important to know if the RGB values are premultiplied. Vuo uses premultiplied colors in some situations and straight (non-premultiplied) colors in others.
A premultiplied RGBA color has had its RGB values multiplied by its A (alpha) value. For example, the straight representation of yellow with 50% opacity is (1.0, 1.0, 0.0, 0.5), and the premultiplied representation of the same color is (0.5, 0.5, 0.0, 0.5).
Notice that there's no way to tell just from looking at the RGBA values if the above color, (0.5, 0.5, 0.0, 0.5), is premultiplied or straight. If premultiplied, it would be a bright yellow. If straight, it would be a dark yellow.
In Vuo, you can tell if a color is premultiplied based on the situation. There are 3 rules to follow to make sure that your code correctly interprets and outputs colors as premultiplied or straight:
gl_FragColor
) should be premultiplied.VuoShader_setUniform_VuoColor
premultiplies the color before passing it to the shader.