Files
MinecraftDungeons/data/shaders/color_grayscale.fragment
2026-03-08 15:30:46 -05:00

51 lines
1.1 KiB
Plaintext

// __multiversion__
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
// attribute to in
// varying to out when in vertex shaders or in when in fragment shaders
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
// texture2D to texture
#if __VERSION__ >= 300
// version 300 code
#ifdef MSAA_FRAMEBUFFER_ENABLED
#define _centroid centroid
#else
#define _centroid
#endif
_centroid in vec2 uv;
#define varying in
#define texture2D texture
out vec4 FragColor;
#define gl_FragColor FragColor
#else
// version 100 code
varying vec2 uv;
#endif
uniform vec4 CURRENT_COLOR;
uniform sampler2D TEXTURE_0;
void main()
{
vec4 diffuse = texture2D( TEXTURE_0, uv );
#ifdef ALPHA_TEST
if(diffuse.a < 0.5)
discard;
#endif
float grayscale = (CURRENT_COLOR.r * diffuse.r * 0.3 + CURRENT_COLOR.g * diffuse.g * 0.59 + CURRENT_COLOR.b * diffuse.b * 0.11);
vec4 gray_color = vec4(grayscale, grayscale, grayscale, CURRENT_COLOR.a * diffuse.a);
gl_FragColor = gray_color;
}