mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
37 lines
686 B
Plaintext
37 lines
686 B
Plaintext
|
//
|
||
|
// opacity.glsl
|
||
|
//
|
||
|
// Changes the opacity of textures.
|
||
|
// The uniform variable 'opacity' sets the opacity.
|
||
|
// Setting this to the value 0 results in an invisible texture.
|
||
|
//
|
||
|
|
||
|
#if defined(VERTEX)
|
||
|
// Vertex section of code:
|
||
|
|
||
|
uniform mat4 MVPMatrix;
|
||
|
varying vec2 vTexCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vTexCoord = gl_MultiTexCoord0.xy;
|
||
|
gl_Position = MVPMatrix * gl_Vertex;
|
||
|
}
|
||
|
|
||
|
#elif defined(FRAGMENT)
|
||
|
// Fragment section of code:
|
||
|
|
||
|
uniform float opacity = 1.0;
|
||
|
uniform sampler2D myTexture;
|
||
|
varying vec2 vTexCoord;
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
vec4 color = texture2D(myTexture, vTexCoord);
|
||
|
float alpha = clamp(color.a-(1-opacity), 0.0, 1.0);
|
||
|
|
||
|
gl_FragColor = vec4(color.rgb, alpha);
|
||
|
}
|
||
|
|
||
|
#endif
|