mirror of
https://git.stillkill.net/MinecraftLeak/Narration-NoGeneratedLevel-20170216.git
synced 2026-10-22 13:12:19 +01:00
116 lines
2.3 KiB
Plaintext
116 lines
2.3 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
|
|
|
|
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
|
#define _centroid centroid
|
|
#else
|
|
#define _centroid
|
|
#endif
|
|
|
|
// version 300 code
|
|
_centroid in vec2 uv;
|
|
|
|
#define varying in
|
|
#define texture2D texture
|
|
layout(location = 0) out vec4 FragColor;
|
|
#define gl_FragColor FragColor
|
|
layout(location = 1) out vec4 FragData;
|
|
#define gl_FragData FragData
|
|
|
|
#else
|
|
|
|
// version 100 code
|
|
varying vec2 uv;
|
|
|
|
#endif
|
|
|
|
uniform sampler2D TEXTURE_0;
|
|
uniform sampler2D TEXTURE_1;
|
|
uniform vec4 OVERLAY_COLOR;
|
|
|
|
#ifdef ENABLE_VERTEX_TINT_MASK
|
|
uniform vec4 CHANGE_COLOR;
|
|
#endif
|
|
|
|
#ifdef GLINT
|
|
uniform vec4 GLINT_COLOR;
|
|
#endif
|
|
|
|
varying vec4 color;
|
|
|
|
#ifdef ENABLE_FOG
|
|
varying vec4 fogColor;
|
|
#endif
|
|
|
|
#ifdef GLINT
|
|
varying vec2 layer1UV;
|
|
varying vec2 layer2UV;
|
|
|
|
vec4 glintBlend(vec4 dest, vec4 source) {
|
|
return vec4(source.rgb * source.rgb, 0.0) + dest;
|
|
}
|
|
#endif
|
|
|
|
void main()
|
|
{
|
|
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
|
|
|
#ifdef ALPHA_TEST
|
|
#ifdef ENABLE_VERTEX_TINT_MASK
|
|
if(diffuse.a <= 0.0)
|
|
#else
|
|
if(diffuse.a < 0.5)
|
|
#endif
|
|
discard;
|
|
#endif
|
|
|
|
#ifdef ENABLE_VERTEX_TINT_MASK
|
|
diffuse.rgb = mix(diffuse.rgb, diffuse.rgb*color.rgb, diffuse.a);
|
|
if (color.a > 0.0) {
|
|
diffuse.a = (diffuse.a > 0.0) ? 1.0 : 0.0;
|
|
}
|
|
#endif
|
|
|
|
#ifdef GLINT
|
|
vec4 layer1 = texture2D(TEXTURE_1, fract(layer1UV)).rgbr * GLINT_COLOR;
|
|
vec4 layer2 = texture2D(TEXTURE_1, fract(layer2UV)).rgbr * GLINT_COLOR;
|
|
vec4 glint = (layer1 + layer2);
|
|
|
|
#ifdef INVENTORY
|
|
diffuse.rgb = glint.rgb;
|
|
#else
|
|
diffuse.rgb = glintBlend(diffuse, glint).rgb;
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef USE_OVERLAY
|
|
//use either the diffuse or the OVERLAY_COLOR
|
|
diffuse.rgb = mix(diffuse, OVERLAY_COLOR, OVERLAY_COLOR.a).rgb;
|
|
#endif
|
|
|
|
#ifdef ENABLE_FOG
|
|
//apply fog
|
|
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
|
|
#endif
|
|
|
|
#ifdef ENABLE_VERTEX_TINT_MASK
|
|
gl_FragColor = diffuse;
|
|
#else
|
|
|
|
#if __VERSION__ >= 300
|
|
gl_FragColor = diffuse * color;
|
|
gl_FragData = diffuse * color;
|
|
#else
|
|
gl_FragColor = diffuse * color;
|
|
#endif
|
|
|
|
#endif
|
|
}
|