mirror of
https://git.stillkill.net/MinecraftLeak/Narration-NoGeneratedLevel-20170216.git
synced 2026-10-22 13:12:19 +01:00
122 lines
2.5 KiB
Plaintext
122 lines
2.5 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
|
|
|
|
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
|
_centroid in highp vec2 uv0;
|
|
_centroid in highp vec2 uv1;
|
|
#else
|
|
_centroid in vec2 uv0;
|
|
_centroid in vec2 uv1;
|
|
#endif
|
|
|
|
#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 uv0;
|
|
varying vec2 uv1;
|
|
|
|
#endif
|
|
|
|
|
|
varying vec4 color;
|
|
|
|
#ifdef FOG
|
|
varying vec4 fogColor;
|
|
#endif
|
|
|
|
#ifdef NEAR_WATER
|
|
varying float cameraDist;
|
|
#endif
|
|
|
|
#include "shaders/util.h"
|
|
|
|
varying vec4 bloomControl;
|
|
|
|
uniform sampler2D TEXTURE_0;
|
|
uniform sampler2D TEXTURE_1;
|
|
uniform sampler2D TEXTURE_2;
|
|
|
|
void main()
|
|
{
|
|
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
|
vec4 diffuse = texture2D( TEXTURE_0, uv0 );
|
|
#else
|
|
vec4 diffuse = texture2D_AA(TEXTURE_0, uv0 );
|
|
#endif
|
|
|
|
vec4 inColor = color;
|
|
|
|
#ifdef SEASONS_FAR
|
|
diffuse.a = 1.0;
|
|
inColor.b = 1.0;
|
|
#endif
|
|
|
|
#ifdef ALPHA_TEST
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
float alphaThreshold = .05;
|
|
#else
|
|
float alphaThreshold = .5;
|
|
#endif
|
|
if(diffuse.a < alphaThreshold)
|
|
discard;
|
|
#endif
|
|
|
|
vec4 lightTex = texture2D( TEXTURE_1, uv1 );
|
|
diffuse = diffuse * lightTex;
|
|
|
|
#ifndef SEASONS
|
|
|
|
#if !defined(ALPHA_TEST) && !defined(BLEND)
|
|
diffuse.a = inColor.a;
|
|
#elif defined(BLEND)
|
|
diffuse.a *= inColor.a;
|
|
#ifdef NEAR_WATER
|
|
float alphaFadeOut = clamp(cameraDist, 0.0, 1.0);
|
|
diffuse.a = mix(diffuse.a, 1.0, alphaFadeOut);
|
|
#endif
|
|
#endif
|
|
|
|
diffuse.rgb *= inColor.rgb;
|
|
#else
|
|
vec2 uv = inColor.xy;
|
|
diffuse.rgb *= mix(vec3(1.0,1.0,1.0), texture2D( TEXTURE_2, uv).rgb*2.0, inColor.b);
|
|
diffuse.rgb *= inColor.aaa;
|
|
diffuse.a = 1.0;
|
|
#endif
|
|
|
|
#ifdef FOG
|
|
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
|
|
#endif
|
|
|
|
#if __VERSION__ >= 300
|
|
gl_FragColor = diffuse;
|
|
vec3 lightCol = pow(mix(lightTex.rgb, lightTex.rgb * diffuse.rgb, 0.8), vec3(bloomControl.x)) * bloomControl.y;
|
|
gl_FragData = vec4(lightCol, 1.0);
|
|
#else
|
|
gl_FragColor = diffuse;
|
|
#endif
|
|
|
|
}
|