I use the following code to reduce or increase the brightness of gl_FragColor
.
void main()
{
#ifdef SHADER_API_GLES3
vec2 uvTop = mix(_UvTopLeftRight.xy, _UvTopLeftRight.zw, gl_MultiTexCoord0.x);
vec2 uvBottom = mix(_UvBottomLeftRight.xy, _UvBottomLeftRight.zw, gl_MultiTexCoord0.x);
textureCoord = mix(uvTop, uvBottom, gl_MultiTexCoord0.y);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
#endif
}
But, How do I change the alpha property of gl_color?
I have tried changing it by gl_FragColor.a = 100
but for some reason it is just creating weird lines.
am I missing something?
The values of the color channels and the alpha channel are normalized floating point values in range [0.0, 1.0].
The alpha channel can be changed by setting gl_FragColor.a
. e.g:
(See also Swizzling)
gl_FragColor.a = 0.6;
or
gl_FragColor = vec4(pow(texture(_MainTex, textureCoord).rgb, vec3(2.2)), 0.6);
See further The OpenGL Shading Language specification:
5.5 Vector and Scalar Components and Length
The names of the components of a vector or scalar are denoted by a single letter. As a notational convenience, several letters are associated with each component based on common usage of position, color or texture coordinate vectors. The individual components can be selected by following the variable name with period ( . ) and then the component name.
The component names supported are:
{x, y, z, w}
Useful when accessing vectors that represent points or normals
{r, g, b, a}
Useful when accessing vectors that represent colors
{s, t, p, q}
Useful when accessing vectors that represent texture coordinates/>