ES-DE/resources/shaders/glsl/dim.glsl

41 lines
887 B
Plaintext
Raw Normal View History

// SPDX-License-Identifier: MIT
2020-09-12 10:14:48 +00:00
//
// EmulationStation Desktop Edition
// dim.glsl
2020-09-12 10:14:48 +00:00
//
// Dims textures.
// The uniform variable 'dimValue' sets the amount of dimming.
// Setting this to the value 0 results in a completely black screen.
2020-09-12 10:14:48 +00:00
//
#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 dimValue = 0.4;
uniform sampler2D myTexture;
varying vec2 vTexCoord;
void main()
{
vec4 dimColor = vec4(dimValue, dimValue, dimValue, 1.0);
vec4 color = texture2D(myTexture, vTexCoord);
// Alpha is handled differently depending on the graphics driver, so set it explicitly to 1.0.
color = vec4(color.rgb, 1.0) * dimColor;
2020-09-12 10:14:48 +00:00
gl_FragColor = color;
}
#endif