unpacked and edited shaders

disabled fog mod in config (not man in the fog)

dimension.properties edited in shaders to shutoff unassigned dimensions.
This commit is contained in:
2025-05-18 16:19:09 -05:00
parent efff2ffd1a
commit c7994da726
363 changed files with 20618 additions and 6 deletions

View File

@ -0,0 +1,275 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
flat in vec3 upVec, sunVec;
#ifdef LIGHTSHAFTS_ACTIVE
flat in float vlFactor;
#endif
//Pipeline Constants//
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
vec2 view = vec2(viewWidth, viewHeight);
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#ifdef LIGHTSHAFTS_ACTIVE
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
float vlTime = min(abs(SdotU) - 0.05, 0.15) / 0.15;
#endif
//Common Functions//
//Includes//
#include "/lib/atmospherics/fog/waterFog.glsl"
#include "/lib/atmospherics/fog/caveFactor.glsl"
#ifdef BLOOM_FOG_COMPOSITE
#include "/lib/atmospherics/fog/bloomFog.glsl"
#endif
#ifdef LIGHTSHAFTS_ACTIVE
#ifdef END
#include "/lib/atmospherics/enderBeams.glsl"
#endif
#include "/lib/atmospherics/volumetricLight.glsl"
#endif
#if WATER_MAT_QUALITY >= 3 || defined NETHER_STORM || defined COLORED_LIGHT_FOG
#include "/lib/util/spaceConversion.glsl"
#endif
#if WATER_MAT_QUALITY >= 3
#include "/lib/materials/materialMethods/refraction.glsl"
#endif
#ifdef NETHER_STORM
#include "/lib/atmospherics/netherStorm.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
#if RAINBOWS > 0 && defined OVERWORLD
#include "/lib/atmospherics/rainbow.glsl"
#endif
#ifdef COLORED_LIGHT_FOG
#include "/lib/misc/voxelization.glsl"
#include "/lib/atmospherics/fog/coloredLightFog.glsl"
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex0, texelCoord, 0).rgb;
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
float z1 = texelFetch(depthtex1, texelCoord, 0).r;
vec4 screenPos = vec4(texCoord, z0, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
#if defined DISTANT_HORIZONS && !defined OVERWORLD
float z0DH = texelFetch(dhDepthTex, texelCoord, 0).r;
vec4 screenPosDH = vec4(texCoord, z0DH, 1.0);
vec4 viewPosDH = dhProjectionInverse * (screenPosDH * 2.0 - 1.0);
viewPosDH /= viewPosDH.w;
lViewPos = min(lViewPos, length(viewPosDH.xyz));
#endif
float dither = texture2D(noisetex, texCoord * view / 128.0).b;
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
/* TM5723: The "1.0 - translucentMult" trick is done because of the default color attachment
value being vec3(0.0). This makes it vec3(1.0) to avoid issues especially on improved glass */
vec3 translucentMult = 1.0 - texelFetch(colortex3, texelCoord, 0).rgb; //TM5723
vec4 volumetricEffect = vec4(0.0);
#if WATER_MAT_QUALITY >= 3
DoRefraction(color, z0, z1, viewPos.xyz, lViewPos);
#endif
vec4 screenPos1 = vec4(texCoord, z1, 1.0);
vec4 viewPos1 = gbufferProjectionInverse * (screenPos1 * 2.0 - 1.0);
viewPos1 /= viewPos1.w;
float lViewPos1 = length(viewPos1.xyz);
#if defined DISTANT_HORIZONS && !defined OVERWORLD
float z1DH = texelFetch(dhDepthTex1, texelCoord, 0).r;
vec4 screenPos1DH = vec4(texCoord, z1DH, 1.0);
vec4 viewPos1DH = dhProjectionInverse * (screenPos1DH * 2.0 - 1.0);
viewPos1DH /= viewPos1DH.w;
lViewPos1 = min(lViewPos1, length(viewPos1DH.xyz));
#endif
#if defined LIGHTSHAFTS_ACTIVE || RAINBOWS > 0 && defined OVERWORLD
vec3 nViewPos = normalize(viewPos1.xyz);
float VdotL = dot(nViewPos, lightVec);
#endif
#if defined NETHER_STORM || defined COLORED_LIGHT_FOG
vec3 playerPos = ViewToPlayer(viewPos1.xyz);
vec3 nPlayerPos = normalize(playerPos);
#endif
#if RAINBOWS > 0 && defined OVERWORLD
if (isEyeInWater == 0) color += GetRainbow(translucentMult, z0, z1, lViewPos, lViewPos1, VdotL, dither);
#endif
#ifdef LIGHTSHAFTS_ACTIVE
float vlFactorM = vlFactor;
float VdotU = dot(nViewPos, upVec);
volumetricEffect = GetVolumetricLight(color, vlFactorM, translucentMult, lViewPos, lViewPos1, nViewPos, VdotL, VdotU, texCoord, z0, z1, dither);
#endif
#ifdef NETHER_STORM
volumetricEffect = GetNetherStorm(color, translucentMult, nPlayerPos, playerPos, lViewPos, lViewPos1, dither);
#endif
#ifdef ATM_COLOR_MULTS
volumetricEffect.rgb *= GetAtmColorMult();
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
volumetricEffect.rgb *= moonPhaseInfluence;
#endif
#ifdef NETHER_STORM
color = mix(color, volumetricEffect.rgb, volumetricEffect.a);
#endif
#ifdef COLORED_LIGHT_FOG
vec3 lightFog = GetColoredLightFog(nPlayerPos, translucentMult, lViewPos, lViewPos1, dither);
float lightFogMult = COLORED_LIGHT_FOG_I;
//if (heldItemId == 40000 && heldItemId2 != 40000) lightFogMult = 0.0; // Hold spider eye to disable light fog
#ifdef OVERWORLD
lightFogMult *= 0.2 + 0.6 * mix(1.0, 1.0 - sunFactor * invRainFactor, eyeBrightnessM);
#endif
#endif
if (isEyeInWater == 1) {
if (z0 == 1.0) color.rgb = waterFogColor;
vec3 underwaterMult = vec3(0.80, 0.87, 0.97);
color.rgb *= underwaterMult * 0.85;
volumetricEffect.rgb *= pow2(underwaterMult * 0.71);
#ifdef COLORED_LIGHT_FOG
lightFog *= underwaterMult;
#endif
} else if (isEyeInWater == 2) {
if (z1 == 1.0) color.rgb = fogColor * 5.0;
volumetricEffect.rgb *= 0.0;
#ifdef COLORED_LIGHT_FOG
lightFog *= 0.0;
#endif
}
#ifdef COLORED_LIGHT_FOG
color /= 1.0 + pow2(GetLuminance(lightFog)) * lightFogMult * 2.0;
color += lightFog * lightFogMult * 0.5;
#endif
color = pow(color, vec3(2.2));
#ifdef LIGHTSHAFTS_ACTIVE
#ifdef END
volumetricEffect.rgb *= volumetricEffect.rgb;
#endif
color += volumetricEffect.rgb;
#endif
#ifdef BLOOM_FOG_COMPOSITE
color *= GetBloomFog(lViewPos); // Reminder: Bloom Fog can move between composite1-2-3
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = vec4(color, 1.0);
// supposed to be #if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
#if LIGHTSHAFT_QUALI_DEFINE > 0 && LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 && defined OVERWORLD || defined END
#if LENSFLARE_MODE > 0 || defined ENTITY_TAA_NOISY_CLOUD_FIX
if (viewWidth + viewHeight - gl_FragCoord.x - gl_FragCoord.y > 1.5)
vlFactorM = texelFetch(colortex4, texelCoord, 0).r;
#endif
/* DRAWBUFFERS:04 */
gl_FragData[1] = vec4(vlFactorM, 0.0, 0.0, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
flat out vec3 upVec, sunVec;
#ifdef LIGHTSHAFTS_ACTIVE
flat out float vlFactor;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#ifdef LIGHTSHAFTS_ACTIVE
#if LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END
vlFactor = texelFetch(colortex4, ivec2(viewWidth-1, viewHeight-1), 0).r;
#else
#if LIGHTSHAFT_BEHAVIOUR == 2
vlFactor = 0.0;
#elif LIGHTSHAFT_BEHAVIOUR == 3
vlFactor = 1.0;
#endif
#endif
#endif
}
#endif

View File

@ -0,0 +1,141 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
#ifdef MOTION_BLURRING
noperspective in vec2 texCoord;
#ifdef BLOOM_FOG_COMPOSITE2
flat in vec3 upVec, sunVec;
#endif
#endif
//Pipeline Constants//
//Common Variables//
#if defined MOTION_BLURRING && defined BLOOM_FOG_COMPOSITE2
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
#endif
//Common Functions//
#ifdef MOTION_BLURRING
vec3 MotionBlur(vec3 color, float z, float dither) {
if (z > 0.56) {
float mbwg = 0.0;
vec2 doublePixel = 2.0 / vec2(viewWidth, viewHeight);
vec3 mblur = vec3(0.0);
vec4 currentPosition = vec4(texCoord, z, 1.0) * 2.0 - 1.0;
vec4 viewPos = gbufferProjectionInverse * currentPosition;
viewPos = gbufferModelViewInverse * viewPos;
viewPos /= viewPos.w;
vec3 cameraOffset = cameraPosition - previousCameraPosition;
vec4 previousPosition = viewPos + vec4(cameraOffset, 0.0);
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
previousPosition /= previousPosition.w;
vec2 velocity = (currentPosition - previousPosition).xy;
velocity = velocity / (1.0 + length(velocity)) * MOTION_BLURRING_STRENGTH * 0.02;
vec2 coord = texCoord - velocity * (3.5 + dither);
for (int i = 0; i < 9; i++, coord += velocity) {
vec2 coordb = clamp(coord, doublePixel, 1.0 - doublePixel);
mblur += texture2DLod(colortex0, coordb, 0).rgb;
mbwg += 1.0;
}
mblur /= mbwg;
return mblur;
} else return color;
}
#endif
//Includes//
#ifdef MOTION_BLURRING
#include "/lib/util/dither.glsl"
#ifdef BLOOM_FOG_COMPOSITE2
#include "/lib/atmospherics/fog/bloomFog.glsl"
#endif
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex0, texelCoord, 0).rgb;
#ifdef MOTION_BLURRING
float z = texture2D(depthtex1, texCoord).x;
float dither = Bayer64(gl_FragCoord.xy);
color = MotionBlur(color, z, dither);
#ifdef BLOOM_FOG_COMPOSITE2
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
vec4 screenPos = vec4(texCoord, z0, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
#if defined DISTANT_HORIZONS && defined NETHER
float z0DH = texelFetch(dhDepthTex, texelCoord, 0).r;
vec4 screenPosDH = vec4(texCoord, z0DH, 1.0);
vec4 viewPosDH = dhProjectionInverse * (screenPosDH * 2.0 - 1.0);
viewPosDH /= viewPosDH.w;
lViewPos = min(lViewPos, length(viewPosDH.xyz));
#endif
color *= GetBloomFog(lViewPos); // Reminder: Bloom Fog can move between composite1-2-3
#endif
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = vec4(color, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
#ifdef MOTION_BLURRING
noperspective out vec2 texCoord;
#ifdef BLOOM_FOG_COMPOSITE2
flat out vec3 upVec, sunVec;
#endif
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
#ifdef MOTION_BLURRING
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
#ifdef BLOOM_FOG_COMPOSITE2
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#endif
#endif
}
#endif

View File

@ -0,0 +1,188 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
#if WORLD_BLUR > 0
noperspective in vec2 texCoord;
flat in vec3 upVec, sunVec;
#endif
//Pipeline Constants//
#if WORLD_BLUR > 0
const bool colortex0MipmapEnabled = true;
#endif
//Common Variables//
#if WORLD_BLUR > 0
#if WORLD_BLUR == 2 && WB_DOF_FOCUS >= 0
#if WB_DOF_FOCUS == 0
uniform float centerDepthSmooth;
#else
float centerDepthSmooth = (far * (WB_DOF_FOCUS - near)) / (WB_DOF_FOCUS * (far - near));
#endif
#endif
#endif
#if WORLD_BLUR > 0
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
vec2 dofOffsets[18] = vec2[18](
vec2( 0.0 , 0.25 ),
vec2(-0.2165 , 0.125 ),
vec2(-0.2165 , -0.125 ),
vec2( 0 , -0.25 ),
vec2( 0.2165 , -0.125 ),
vec2( 0.2165 , 0.125 ),
vec2( 0 , 0.5 ),
vec2(-0.25 , 0.433 ),
vec2(-0.433 , 0.25 ),
vec2(-0.5 , 0 ),
vec2(-0.433 , -0.25 ),
vec2(-0.25 , -0.433 ),
vec2( 0 , -0.5 ),
vec2( 0.25 , -0.433 ),
vec2( 0.433 , -0.2 ),
vec2( 0.5 , 0 ),
vec2( 0.433 , 0.25 ),
vec2( 0.25 , 0.433 )
);
#endif
//Common Functions//
#if WORLD_BLUR > 0
void DoWorldBlur(inout vec3 color, float z1, float lViewPos0) {
if (z1 < 0.56) return;
vec3 dof = vec3(0.0);
vec2 dofScale = vec2(1.0, aspectRatio);
#if WORLD_BLUR == 1 // Distance Blur
#ifdef OVERWORLD
float dbMult;
if (isEyeInWater == 0) {
dbMult = mix(WB_DB_NIGHT_I, WB_DB_DAY_I, sunFactor * eyeBrightnessM);
dbMult = mix(dbMult, WB_DB_RAIN_I, rainFactor * eyeBrightnessM);
} else dbMult = WB_DB_WATER_I;
#elif defined NETHER
float dbMult = WB_DB_NETHER_I;
#elif defined END
float dbMult = WB_DB_END_I;
#endif
float coc = clamp(lViewPos0 * 0.001, 0.0, 0.1) * dbMult * 0.03;
#elif WORLD_BLUR == 2 // Depth Of Field
#if WB_DOF_FOCUS >= 0
float coc = max(abs(z1 - centerDepthSmooth) * 0.125 * WB_DOF_I - 0.0001, 0.0);
#elif WB_DOF_FOCUS == -1
float coc = clamp(abs(lViewPos0 * 0.005 - pow2(vsBrightness)), 0.0, 0.1) * WB_DOF_I * 0.03;
#endif
#endif
coc = coc / sqrt(coc * coc + 0.1);
#ifdef WB_FOV_SCALED
coc *= gbufferProjection[1][1] * 0.8;
#endif
#ifdef WB_CHROMATIC
float midDistX = texCoord.x - 0.5;
float midDistY = texCoord.y - 0.5;
vec2 chromaticScale = vec2(midDistX, midDistY);
chromaticScale = sign(chromaticScale) * sqrt(abs(chromaticScale));
chromaticScale *= vec2(1.0, viewHeight / viewWidth);
vec2 aberration = (15.0 / vec2(viewWidth, viewHeight)) * chromaticScale * coc;
#endif
#ifdef WB_ANAMORPHIC
dofScale *= vec2(0.5, 1.5);
#endif
if (coc * 0.5 > 1.0 / max(viewWidth, viewHeight)) {
for (int i = 0; i < 18; i++) {
vec2 offset = dofOffsets[i] * coc * 0.0085 * dofScale;
float lod = log2(viewHeight * aspectRatio * coc * 0.75 / 320.0);
#ifndef WB_CHROMATIC
dof += texture2DLod(colortex0, texCoord + offset, lod).rgb;
#else
dof += vec3(texture2DLod(colortex0, texCoord + offset + aberration, lod).r,
texture2DLod(colortex0, texCoord + offset , lod).g,
texture2DLod(colortex0, texCoord + offset - aberration, lod).b);
#endif
}
dof /= 18.0;
color = dof;
}
}
#endif
//Includes//
#if WORLD_BLUR > 0 && defined BLOOM_FOG_COMPOSITE3
#include "/lib/atmospherics/fog/bloomFog.glsl"
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex0, texelCoord, 0).rgb;
#if WORLD_BLUR > 0
float z1 = texelFetch(depthtex1, texelCoord, 0).r;
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
vec4 screenPos = vec4(texCoord, z0, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
#if defined DISTANT_HORIZONS && defined NETHER
float z0DH = texelFetch(dhDepthTex, texelCoord, 0).r;
vec4 screenPosDH = vec4(texCoord, z0DH, 1.0);
vec4 viewPosDH = dhProjectionInverse * (screenPosDH * 2.0 - 1.0);
viewPosDH /= viewPosDH.w;
lViewPos = min(lViewPos, length(viewPosDH.xyz));
#endif
DoWorldBlur(color, z1, lViewPos);
#ifdef BLOOM_FOG_COMPOSITE3
color *= GetBloomFog(lViewPos); // Reminder: Bloom Fog can move between composite1-2-3
#endif
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = vec4(color, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
#if WORLD_BLUR > 0
noperspective out vec2 texCoord;
flat out vec3 upVec, sunVec;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
#if WORLD_BLUR > 0
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#endif
}
#endif

View File

@ -0,0 +1,96 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//Varyings//
varying vec2 texCoord;
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
//Pipeline Constants//
const bool colortex0MipmapEnabled = true;
//Common Variables//
float weight[7] = float[7](1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0);
vec2 view = vec2(viewWidth, viewHeight);
//Common Functions//
vec3 BloomTile(float lod, vec2 offset, vec2 scaledCoord) {
vec3 bloom = vec3(0.0);
float scale = exp2(lod);
vec2 coord = (scaledCoord - offset) * scale;
float padding = 0.5 + 0.005 * scale;
if (abs(coord.x - 0.5) < padding && abs(coord.y - 0.5) < padding) {
for (int i = -3; i <= 3; i++) {
for (int j = -3; j <= 3; j++) {
float wg = weight[i + 3] * weight[j + 3];
vec2 pixelOffset = vec2(i, j) / view;
vec2 bloomCoord = (scaledCoord - offset + pixelOffset) * scale;
bloom += texture2D(colortex0, bloomCoord).rgb * wg;
}
}
bloom /= 4096.0;
}
return pow(bloom / 128.0, vec3(0.25));
}
//Includes//
//Program//
void main() {
vec3 blur = vec3(0.0);
#ifdef BLOOM
vec2 scaledCoord = texCoord * max(vec2(viewWidth, viewHeight) / vec2(1920.0, 1080.0), vec2(1.0));
#if defined OVERWORLD || defined END
blur += BloomTile(2.0, vec2(0.0 , 0.0 ), scaledCoord);
blur += BloomTile(3.0, vec2(0.0 , 0.26 ), scaledCoord);
blur += BloomTile(4.0, vec2(0.135 , 0.26 ), scaledCoord);
blur += BloomTile(5.0, vec2(0.2075 , 0.26 ), scaledCoord) * 0.8;
blur += BloomTile(6.0, vec2(0.135 , 0.3325), scaledCoord) * 0.8;
blur += BloomTile(7.0, vec2(0.160625 , 0.3325), scaledCoord) * 0.6;
blur += BloomTile(8.0, vec2(0.1784375, 0.3325), scaledCoord) * 0.4;
#else
blur += BloomTile(2.0, vec2(0.0 , 0.0 ), scaledCoord);
blur += BloomTile(3.0, vec2(0.0 , 0.26 ), scaledCoord);
blur += BloomTile(4.0, vec2(0.135 , 0.26 ), scaledCoord);
blur += BloomTile(5.0, vec2(0.2075 , 0.26 ), scaledCoord);
blur += BloomTile(6.0, vec2(0.135 , 0.3325), scaledCoord);
blur += BloomTile(7.0, vec2(0.160625 , 0.3325), scaledCoord);
blur += BloomTile(8.0, vec2(0.1784375, 0.3325), scaledCoord) * 0.6;
#endif
#endif
/* DRAWBUFFERS:3 */
gl_FragData[0] = vec4(blur, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
texCoord = gl_MultiTexCoord0.xy;
gl_Position = ftransform();
}
#endif

View File

@ -0,0 +1,216 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
#if defined BLOOM_FOG || LENSFLARE_MODE > 0 && defined OVERWORLD
flat in vec3 upVec, sunVec;
#endif
//Pipeline Constants//
//Common Variables//
float pw = 1.0 / viewWidth;
float ph = 1.0 / viewHeight;
vec2 view = vec2(viewWidth, viewHeight);
#if defined BLOOM_FOG || LENSFLARE_MODE > 0 && defined OVERWORLD
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
#endif
//Common Functions//
void DoBSLTonemap(inout vec3 color) {
color = T_EXPOSURE * color;
color = color / pow(pow(color, vec3(TM_WHITE_CURVE)) + 1.0, vec3(1.0 / TM_WHITE_CURVE));
color = pow(color, mix(vec3(T_LOWER_CURVE), vec3(T_UPPER_CURVE), sqrt(color)));
color = pow(color, vec3(1.0 / 2.2));
}
void DoBSLColorSaturation(inout vec3 color) {
float grayVibrance = (color.r + color.g + color.b) / 3.0;
float graySaturation = grayVibrance;
if (T_SATURATION < 1.00) graySaturation = dot(color, vec3(0.299, 0.587, 0.114));
float mn = min(color.r, min(color.g, color.b));
float mx = max(color.r, max(color.g, color.b));
float sat = (1.0 - (mx - mn)) * (1.0 - mx) * grayVibrance * 5.0;
vec3 lightness = vec3((mn + mx) * 0.5);
color = mix(color, mix(color, lightness, 1.0 - T_VIBRANCE), sat);
color = mix(color, lightness, (1.0 - lightness) * (2.0 - T_VIBRANCE) / 2.0 * abs(T_VIBRANCE - 1.0));
color = color * T_SATURATION - graySaturation * (T_SATURATION - 1.0);
}
#ifdef BLOOM
vec2 rescale = max(vec2(viewWidth, viewHeight) / vec2(1920.0, 1080.0), vec2(1.0));
vec3 GetBloomTile(float lod, vec2 coord, vec2 offset) {
float scale = exp2(lod);
vec2 bloomCoord = coord / scale + offset;
bloomCoord = clamp(bloomCoord, offset, 1.0 / scale + offset);
vec3 bloom = texture2D(colortex3, bloomCoord / rescale).rgb;
bloom *= bloom;
bloom *= bloom;
return bloom * 128.0;
}
void DoBloom(inout vec3 color, vec2 coord, float dither, float lViewPos) {
vec3 blur1 = GetBloomTile(2.0, coord, vec2(0.0 , 0.0 ));
vec3 blur2 = GetBloomTile(3.0, coord, vec2(0.0 , 0.26 ));
vec3 blur3 = GetBloomTile(4.0, coord, vec2(0.135 , 0.26 ));
vec3 blur4 = GetBloomTile(5.0, coord, vec2(0.2075 , 0.26 ));
vec3 blur5 = GetBloomTile(6.0, coord, vec2(0.135 , 0.3325));
vec3 blur6 = GetBloomTile(7.0, coord, vec2(0.160625 , 0.3325));
vec3 blur7 = GetBloomTile(8.0, coord, vec2(0.1784375, 0.3325));
vec3 blur = (blur1 + blur2 + blur3 + blur4 + blur5 + blur6 + blur7) * 0.14;
float bloomStrength = BLOOM_STRENGTH + 0.2 * darknessFactor;
#if defined BLOOM_FOG && defined NETHER && defined BORDER_FOG
float farM = min(renderDistance, NETHER_VIEW_LIMIT); // consistency9023HFUE85JG
float netherBloom = lViewPos / clamp(farM, 96.0, 256.0);
netherBloom *= netherBloom;
netherBloom *= netherBloom;
netherBloom = 1.0 - exp(-8.0 * netherBloom);
netherBloom *= 1.0 - maxBlindnessDarkness;
bloomStrength = mix(bloomStrength * 0.7, bloomStrength * 1.8, netherBloom);
#endif
color = mix(color, blur, bloomStrength);
//color += blur * bloomStrength * (ditherFactor.x + ditherFactor.y);
}
#endif
//Includes//
#ifdef BLOOM_FOG
#include "/lib/atmospherics/fog/bloomFog.glsl"
#endif
#ifdef BLOOM
#include "/lib/util/dither.glsl"
#endif
#if LENSFLARE_MODE > 0 && defined OVERWORLD
#include "/lib/misc/lensFlare.glsl"
#endif
//Program//
void main() {
vec3 color = texture2D(colortex0, texCoord).rgb;
#if defined BLOOM_FOG || LENSFLARE_MODE > 0 && defined OVERWORLD
float z0 = texture2D(depthtex0, texCoord).r;
vec4 screenPos = vec4(texCoord, z0, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
#if defined DISTANT_HORIZONS && defined NETHER
float z0DH = texelFetch(dhDepthTex, texelCoord, 0).r;
vec4 screenPosDH = vec4(texCoord, z0DH, 1.0);
vec4 viewPosDH = dhProjectionInverse * (screenPosDH * 2.0 - 1.0);
viewPosDH /= viewPosDH.w;
lViewPos = min(lViewPos, length(viewPosDH.xyz));
#endif
#else
float lViewPos = 0.0;
#endif
float dither = texture2D(noisetex, texCoord * view / 128.0).b;
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef BLOOM_FOG
color /= GetBloomFog(lViewPos);
#endif
#ifdef BLOOM
DoBloom(color, texCoord, dither, lViewPos);
#endif
#ifdef COLORGRADING
color =
pow(color.r, GR_RC) * vec3(GR_RR, GR_RG, GR_RB) +
pow(color.g, GR_GC) * vec3(GR_GR, GR_GG, GR_GB) +
pow(color.b, GR_BC) * vec3(GR_BR, GR_BG, GR_BB);
color *= 0.01;
#endif
DoBSLTonemap(color);
#if defined GREEN_SCREEN_LIME || SELECT_OUTLINE == 4
int materialMaskInt = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
#endif
#ifdef GREEN_SCREEN_LIME
if (materialMaskInt == 240) { // Green Screen Lime Blocks
color = vec3(0.0, 1.0, 0.0);
}
#endif
#if SELECT_OUTLINE == 4
if (materialMaskInt == 252) { // Versatile Selection Outline
float colorMF = 1.0 - dot(color, vec3(0.25, 0.45, 0.1));
colorMF = smoothstep1(smoothstep1(smoothstep1(smoothstep1(smoothstep1(colorMF)))));
color = mix(color, 3.0 * (color + 0.2) * vec3(colorMF * SELECT_OUTLINE_I), 0.3);
}
#endif
#if LENSFLARE_MODE > 0 && defined OVERWORLD
DoLensFlare(color, viewPos.xyz, dither);
#endif
DoBSLColorSaturation(color);
float filmGrain = dither;
color += vec3((filmGrain - 0.25) / 128.0);
/* DRAWBUFFERS:3 */
gl_FragData[0] = vec4(color, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
#if defined BLOOM_FOG || LENSFLARE_MODE > 0 && defined OVERWORLD
flat out vec3 upVec, sunVec;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
#if defined BLOOM_FOG || LENSFLARE_MODE > 0 && defined OVERWORLD
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#endif
}
#endif

View File

@ -0,0 +1,79 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
//Pipeline Constants//
#include "/lib/pipelineSettings.glsl"
const bool colortex3MipmapEnabled = true;
//Common Variables//
vec2 view = vec2(viewWidth, viewHeight);
//Common Functions//
float GetLinearDepth(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
//Includes//
#ifdef TAA
#include "/lib/antialiasing/taa.glsl"
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex3, texelCoord, 0).rgb;
vec3 temp = vec3(0.0);
float z1 = 0.0;
#if defined TAA || defined TEMPORAL_FILTER
z1 = texelFetch(depthtex1, texelCoord, 0).r;
#endif
#ifdef TAA
DoTAA(color, temp, z1);
#endif
/* DRAWBUFFERS:32 */
gl_FragData[0] = vec4(color, 1.0);
gl_FragData[1] = vec4(temp, 1.0);
// Supposed to be #ifdef TEMPORAL_FILTER but Optifine bad
#if BLOCK_REFLECT_QUALITY >= 3 && RP_MODE >= 1
/* DRAWBUFFERS:321 */
gl_FragData[2] = vec4(z1, 1.0, 1.0, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}
#endif

View File

@ -0,0 +1,61 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
//Pipeline Constants//
//Common Variables//
//Common Functions//
float GetLinearDepth(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
//Includes//
#if FXAA_DEFINE == 1
#include "/lib/antialiasing/fxaa.glsl"
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex3, texelCoord, 0).rgb;
#if FXAA_DEFINE == 1
FXAA311(color);
#endif
/* DRAWBUFFERS:3 */
gl_FragData[0] = vec4(color, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}
#endif

View File

@ -0,0 +1,552 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
flat in vec3 upVec, sunVec;
#if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
flat in float vlFactor;
#endif
//Pipeline Constants//
const bool colortex0MipmapEnabled = true;
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
float farMinusNear = far - near;
vec2 view = vec2(viewWidth, viewHeight);
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
#else
float vlFactor = 0.0;
#endif
//Common Functions//
float GetLinearDepth(float depth) {
return (2.0 * near) / (far + near - depth * farMinusNear);
}
#if SSAO_QUALI > 0
vec2 OffsetDist(float x, int s) {
float n = fract(x * 1.414) * 3.1415;
return pow2(vec2(cos(n), sin(n)) * x / s);
}
float DoAmbientOcclusion(float z0, float linearZ0, float dither) {
if (z0 < 0.56) return 1.0;
float ao = 0.0;
#if SSAO_QUALI == 2
int samples = 4;
float scm = 0.4;
#elif SSAO_QUALI == 3
int samples = 12;
float scm = 0.6;
#endif
#define SSAO_I_FACTOR 0.004
float sampleDepth = 0.0, angle = 0.0, dist = 0.0;
float fovScale = gbufferProjection[1][1];
float distScale = max(farMinusNear * linearZ0 + near, 3.0);
vec2 scale = vec2(scm / aspectRatio, scm) * fovScale / distScale;
for (int i = 1; i <= samples; i++) {
vec2 offset = OffsetDist(i + dither, samples) * scale;
if (i % 2 == 0) offset.y = -offset.y;
vec2 coord1 = texCoord + offset;
vec2 coord2 = texCoord - offset;
sampleDepth = GetLinearDepth(texture2D(depthtex0, coord1).r);
float aosample = farMinusNear * (linearZ0 - sampleDepth) * 2.0;
angle = clamp(0.5 - aosample, 0.0, 1.0);
dist = clamp(0.5 * aosample - 1.0, 0.0, 1.0);
sampleDepth = GetLinearDepth(texture2D(depthtex0, coord2).r);
aosample = farMinusNear * (linearZ0 - sampleDepth) * 2.0;
angle += clamp(0.5 - aosample, 0.0, 1.0);
dist += clamp(0.5 * aosample - 1.0, 0.0, 1.0);
ao += clamp(angle + dist, 0.0, 1.0);
}
ao /= samples;
#define SSAO_IM SSAO_I * SSAO_I_FACTOR
return pow(ao, SSAO_IM);
}
#endif
#ifdef TEMPORAL_FILTER
float GetApproxDistance(float depth) {
return near * far / (far - depth * far);
}
// Previous frame reprojection from Chocapic13
vec2 Reprojection(vec3 pos, vec3 cameraOffset) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
vec4 previousPosition = viewPosPrev + vec4(cameraOffset, 0.0);
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
vec3 FHalfReprojection(vec3 pos) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
return viewPosPrev.xyz;
}
vec2 SHalfReprojection(vec3 playerPos, vec3 cameraOffset) {
vec4 proPos = vec4(playerPos + cameraOffset, 1.0);
vec4 previousPosition = gbufferPreviousModelView * proPos;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
#endif
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/util/dither.glsl"
#include "/lib/atmospherics/fog/mainFog.glsl"
#include "/lib/colors/skyColors.glsl"
#if AURORA_STYLE > 0
#include "/lib/atmospherics/auroraBorealis.glsl"
#endif
#ifdef NIGHT_NEBULA
#include "/lib/atmospherics/nightNebula.glsl"
#endif
#ifdef VL_CLOUDS_ACTIVE
#include "/lib/atmospherics/clouds/mainClouds.glsl"
#endif
#ifdef PBR_REFLECTIONS
#include "/lib/materials/materialMethods/reflections.glsl"
#endif
#ifdef END
#include "/lib/atmospherics/enderStars.glsl"
#endif
#ifdef WORLD_OUTLINE
#include "/lib/misc/worldOutline.glsl"
#endif
#ifdef DARK_OUTLINE
#include "/lib/misc/darkOutline.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
#ifdef DISTANT_LIGHT_BOKEH
#include "/lib/misc/distantLightBokeh.glsl"
#endif
//Program//
void main() {
vec3 color = texelFetch(colortex0, texelCoord, 0).rgb;
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
vec4 screenPos = vec4(texCoord, z0, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos);
vec3 nViewPos = normalize(viewPos.xyz);
vec3 playerPos = ViewToPlayer(viewPos.xyz);
float dither = texture2D(noisetex, texCoord * vec2(viewWidth, viewHeight) / 128.0).b;
#if defined TAA || defined TEMPORAL_FILTER
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
sqrtAtmColorMult = sqrt(atmColorMult);
#endif
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float skyFade = 0.0;
vec3 waterRefColor = vec3(0.0);
vec3 auroraBorealis = vec3(0.0);
vec3 nightNebula = vec3(0.0);
#ifdef TEMPORAL_FILTER
vec4 refToWrite = vec4(0.0);
#endif
if (z0 < 1.0) {
#ifdef DISTANT_LIGHT_BOKEH
int dlbo = 1;
vec3 dlbColor = color;
dlbColor += texelFetch(colortex0, texelCoord + ivec2( 0, dlbo), 0).rgb;
dlbColor += texelFetch(colortex0, texelCoord + ivec2( 0,-dlbo), 0).rgb;
dlbColor += texelFetch(colortex0, texelCoord + ivec2( dlbo, 0), 0).rgb;
dlbColor += texelFetch(colortex0, texelCoord + ivec2(-dlbo, 0), 0).rgb;
dlbColor = max(color, dlbColor * 0.2);
float dlbMix = GetDistantLightBokehMix(lViewPos);
color = mix(color, dlbColor, dlbMix);
#endif
#if SSAO_QUALI > 0 || defined WORLD_OUTLINE || defined TEMPORAL_FILTER
float linearZ0 = GetLinearDepth(z0);
#endif
#if SSAO_QUALI > 0
float ssao = DoAmbientOcclusion(z0, linearZ0, dither);
#else
float ssao = 1.0;
#endif
vec3 texture6 = texelFetch(colortex6, texelCoord, 0).rgb;
bool entityOrHand = z0 < 0.56;
int materialMaskInt = int(texture6.g * 255.1);
float intenseFresnel = 0.0;
float smoothnessD = texture6.r;
vec3 reflectColor = vec3(1.0);
if (materialMaskInt <= 240) {
#ifdef IPBR
#include "/lib/materials/materialHandling/deferredMaterials.glsl"
#elif defined CUSTOM_PBR
#if RP_MODE == 2 // seuspbr
float metalness = materialMaskInt / 240.0;
intenseFresnel = metalness;
#elif RP_MODE == 3 // labPBR
float metalness = float(materialMaskInt >= 230);
intenseFresnel = materialMaskInt / 240.0;
#endif
reflectColor = mix(reflectColor, color.rgb / max(color.r + 0.00001, max(color.g, color.b)), metalness);
#endif
} else {
if (materialMaskInt == 254) { // No SSAO, No TAA
ssao = 1.0;
entityOrHand = true;
}
}
color.rgb *= ssao;
#ifdef PBR_REFLECTIONS
float skyLightFactor = texture6.b;
vec3 texture5 = texelFetch(colortex5, texelCoord, 0).rgb;
vec3 normalM = mat3(gbufferModelView) * texture5;
float fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
float fresnelFactor = (1.0 - smoothnessD) * 0.7;
float fresnelM = max(fresnel - fresnelFactor, 0.0) / (1.0 - fresnelFactor);
#ifdef IPBR
fresnelM = mix(pow2(fresnelM), fresnelM * 0.75 + 0.25, intenseFresnel);
#else
fresnelM = mix(pow2(fresnelM), fresnelM * 0.5 + 0.5, intenseFresnel);
#endif
fresnelM = fresnelM * sqrt1(smoothnessD) - dither * 0.001;
if (fresnelM > 0.0) {
#ifdef TAA
float noiseMult = 0.3;
#else
float noiseMult = 0.1;
#endif
#ifdef TEMPORAL_FILTER
float blendFactor = 1.0;
float writeFactor = 1.0;
#endif
#if defined CUSTOM_PBR || defined IPBR && defined IS_IRIS
if (entityOrHand) {
noiseMult *= 0.1;
#ifdef TEMPORAL_FILTER
blendFactor = 0.0;
writeFactor = 0.0;
#endif
}
#endif
noiseMult *= pow2(1.0 - smoothnessD);
vec2 roughCoord = gl_FragCoord.xy / 128.0;
vec3 roughNoise = vec3(
texture2D(noisetex, roughCoord).r,
texture2D(noisetex, roughCoord + 0.09375).r,
texture2D(noisetex, roughCoord + 0.1875).r
);
roughNoise = fract(roughNoise + vec3(dither, dither * goldenRatio, dither * pow2(goldenRatio)));
roughNoise = noiseMult * (roughNoise - vec3(0.5));
normalM += roughNoise;
vec4 reflection = GetReflection(normalM, viewPos.xyz, nViewPos, playerPos, lViewPos, z0,
depthtex0, dither, skyLightFactor, fresnel,
smoothnessD, vec3(0.0), vec3(0.0), vec3(0.0), 0.0);
vec3 colorAdd = reflection.rgb * reflectColor;
//float colorMultInv = (0.75 - intenseFresnel * 0.5) * max(reflection.a, skyLightFactor);
//float colorMultInv = max(reflection.a, skyLightFactor);
float colorMultInv = 1.0;
vec3 colorP = color;
#ifdef TEMPORAL_FILTER
vec3 cameraOffset = cameraPosition - previousCameraPosition;
vec2 prvCoord = SHalfReprojection(playerPos, cameraOffset);
#if defined IPBR && !defined GENERATED_NORMALS
vec2 prvRefCoord = Reprojection(vec3(texCoord, max(refPos.z, z0)), cameraOffset);
vec4 oldRef = texture2D(colortex7, prvRefCoord);
#else
vec2 prvRefCoord = Reprojection(vec3(texCoord, z0), cameraOffset);
vec2 prvRefCoord2 = Reprojection(vec3(texCoord, max(refPos.z, z0)), cameraOffset);
vec4 oldRef1 = texture2D(colortex7, prvRefCoord);
vec4 oldRef2 = texture2D(colortex7, prvRefCoord2);
vec3 dif1 = colorAdd - oldRef1.rgb;
vec3 dif2 = colorAdd - oldRef2.rgb;
float dotDif1 = dot(dif1, dif1);
float dotDif2 = dot(dif2, dif2);
float oldRefMixer = clamp01((dotDif1 - dotDif2) * 500.0);
vec4 oldRef = mix(oldRef1, oldRef2, oldRefMixer);
#endif
vec4 newRef = vec4(colorAdd, colorMultInv);
vec2 oppositePreCoord = texCoord - 2.0 * (prvCoord - texCoord);
// Reduce blending at speed
blendFactor *= float(prvCoord.x > 0.0 && prvCoord.x < 1.0 && prvCoord.y > 0.0 && prvCoord.y < 1.0);
float velocity = length(cameraOffset) * max(16.0 - lViewPos / gbufferProjection[1][1], 3.0);
blendFactor *= mix(1.0, exp(-velocity) * 0.5 + 0.5, smoothnessD);
// Reduce blending if depth changed
float linearZDif = abs(GetLinearDepth(texture2D(colortex1, oppositePreCoord).r) - linearZ0) * far;
blendFactor *= max0(2.0 - linearZDif) * 0.5;
//color = mix(vec3(1,1,0), color, max0(2.0 - linearZDif) * 0.5);
// Reduce blending if normal changed
vec3 texture5P = texture2D(colortex5, oppositePreCoord, 0).rgb;
vec3 texture5Dif = abs(texture5 - texture5P);
if (texture5Dif != clamp(texture5Dif, vec3(-0.004), vec3(0.004))) {
blendFactor = 0.0;
//color.rgb = vec3(1,0,1);
}
blendFactor = max0(blendFactor); // Prevent first frame NaN
newRef = max(newRef, vec4(0.0)); // Prevent random NaNs from persisting
refToWrite = mix(newRef, oldRef, blendFactor * 0.95);
refToWrite = mix(max(refToWrite, newRef), refToWrite, pow2(pow2(pow2(refToWrite.a))));
color.rgb *= 1.0 - refToWrite.a * fresnelM;
color.rgb += refToWrite.rgb * fresnelM;
refToWrite *= writeFactor;
#else
color *= 1.0 - colorMultInv * fresnelM;
color += colorAdd * fresnelM;
#endif
color = max(colorP, color); // Prevents reflections from making a surface darker
//if (gl_FragCoord.x > 960) color = vec3(5.25,0,5.25);
}
#endif
#ifdef WORLD_OUTLINE
#ifndef WORLD_OUTLINE_ON_ENTITIES
if (!entityOrHand)
#endif
DoWorldOutline(color, linearZ0);
#endif
#ifndef SKY_EFFECT_REFLECTION
waterRefColor = sqrt(color) - 1.0;
#else
waterRefColor = color;
#endif
DoFog(color, skyFade, lViewPos, playerPos, VdotU, VdotS, dither);
} else { // Sky
#ifdef DISTANT_HORIZONS
float z0DH = texelFetch(dhDepthTex, texelCoord, 0).r;
if (z0DH < 1.0) { // Distant Horizons Chunks
vec4 screenPosDH = vec4(texCoord, z0DH, 1.0);
vec4 viewPosDH = dhProjectionInverse * (screenPosDH * 2.0 - 1.0);
viewPosDH /= viewPosDH.w;
lViewPos = length(viewPosDH.xyz);
playerPos = ViewToPlayer(viewPosDH.xyz);
#ifndef SKY_EFFECT_REFLECTION
waterRefColor = sqrt(color) - 1.0;
#else
waterRefColor = color;
#endif
DoFog(color.rgb, skyFade, lViewPos, playerPos, VdotU, VdotS, dither);
} else { // Start of Actual Sky
#endif
skyFade = 1.0;
#ifdef OVERWORLD
#if AURORA_STYLE > 0
auroraBorealis = GetAuroraBorealis(viewPos.xyz, VdotU, dither);
color.rgb += auroraBorealis;
#endif
#ifdef NIGHT_NEBULA
nightNebula += GetNightNebula(viewPos.xyz, VdotU, VdotS);
color.rgb += nightNebula;
#endif
#endif
#ifdef NETHER
color.rgb = netherColor * (1.0 - maxBlindnessDarkness);
#ifdef ATM_COLOR_MULTS
color.rgb *= atmColorMult;
#endif
#endif
#ifdef END
color.rgb = endSkyColor;
color.rgb += GetEnderStars(viewPos.xyz, VdotU);
color.rgb *= 1.0 - maxBlindnessDarkness;
#ifdef ATM_COLOR_MULTS
color.rgb *= atmColorMult;
#endif
#endif
#ifdef DISTANT_HORIZONS
} // End of Actual Sky
#endif
}
float cloudLinearDepth = 1.0;
vec4 clouds = vec4(0.0);
#ifdef VL_CLOUDS_ACTIVE
float cloudZCheck = 0.56;
if (z0 > cloudZCheck) {
clouds = GetClouds(cloudLinearDepth, skyFade, cameraPosition, playerPos,
lViewPos, VdotS, VdotU, dither, auroraBorealis, nightNebula);
color = mix(color, clouds.rgb, clouds.a);
}
#endif
#ifdef SKY_EFFECT_REFLECTION
waterRefColor = mix(waterRefColor, clouds.rgb, clouds.a);
waterRefColor = sqrt(waterRefColor) - 1.0;
#endif
#if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
if (viewWidth + viewHeight - gl_FragCoord.x - gl_FragCoord.y < 1.5)
cloudLinearDepth = vlFactor;
#endif
#if defined OVERWORLD && defined ATMOSPHERIC_FOG && (defined SPECIAL_BIOME_WEATHER || RAIN_STYLE == 2)
float altitudeFactorRaw = GetAtmFogAltitudeFactor(playerPos.y + cameraPosition.y);
vec3 atmFogColor = GetAtmFogColor(altitudeFactorRaw, VdotS);
#if RAIN_STYLE == 2
float factor = 1.0;
#else
float factor = max(inSnowy, inDry);
#endif
color = mix(color, atmFogColor, 0.5 * rainFactor * factor * sqrt1(skyFade));
#endif
#ifdef DARK_OUTLINE
if (clouds.a < 0.5) DoDarkOutline(color, skyFade, z0, dither);
#endif
/*DRAWBUFFERS:054*/
gl_FragData[0] = vec4(color, 1.0);
gl_FragData[1] = vec4(waterRefColor, 1.0 - skyFade);
gl_FragData[2] = vec4(cloudLinearDepth, 0.0, 0.0, 1.0);
#ifdef TEMPORAL_FILTER
/*DRAWBUFFERS:0547*/
gl_FragData[3] = refToWrite;
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
flat out vec3 upVec, sunVec;
#if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
flat out float vlFactor;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#if defined LIGHTSHAFTS_ACTIVE && (LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 || defined END)
vlFactor = texelFetch(colortex4, ivec2(viewWidth-1, viewHeight-1), 0).r;
#ifdef END
if (frameCounter % int(0.06666 / frameTimeSmooth + 0.5) == 0) { // Change speed is not too different above 10 fps
vec2 absCamPosXZ = abs(cameraPosition.xz);
float maxCamPosXZ = max(absCamPosXZ.x, absCamPosXZ.y);
if (gl_Fog.start / far > 0.5 || maxCamPosXZ > 350.0) vlFactor = max(vlFactor - OSIEBCA*2, 0.0);
else vlFactor = min(vlFactor + OSIEBCA*2, 1.0);
}
#endif
#endif
}
#endif

View File

@ -0,0 +1,188 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in int mat;
in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec3 playerPos;
in vec4 glColor;
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
vec2 lmCoordM = lmCoord;
mat4 gbufferProjection = dhProjection;
mat4 gbufferProjectionInverse = dhProjectionInverse;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
//Common Functions//
float Noise3D(vec3 p) {
p.z = fract(p.z) * 128.0;
float iz = floor(p.z);
float fz = fract(p.z);
vec2 a_off = vec2(23.0, 29.0) * (iz) / 128.0;
vec2 b_off = vec2(23.0, 29.0) * (iz + 1.0) / 128.0;
float a = texture2D(noisetex, p.xy + a_off).r;
float b = texture2D(noisetex, p.xy + b_off).r;
return mix(a, b, fz);
}
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/util/dither.glsl"
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#define GBUFFERS_TERRAIN
#include "/lib/lighting/mainLighting.glsl"
#undef GBUFFERS_TERRAIN
#ifdef SNOWY_WORLD
#include "/lib/materials/materialMethods/snowyWorld.glsl"
#endif
//Program//
void main() {
vec4 color = vec4(glColor.rgb, 1.0);
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(playerPos);
vec3 nViewPos = normalize(viewPos);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float dither = Bayer64(gl_FragCoord.xy);
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
#endif
bool noSmoothLighting = false, noDirectionalShading = false, noVanillaAO = false, centerShadowBias = false;
int subsurfaceMode = 0;
float smoothnessG = 0.0, smoothnessD = 0.0, highlightMult = 1.0, emission = 0.0, snowFactor = 1.0, snowMinNdotU = 0.0;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
if (mat == DH_BLOCK_LEAVES) {
#include "/lib/materials/specificMaterials/terrain/leaves.glsl"
} else if (mat == DH_BLOCK_GRASS) {
smoothnessG = pow2(color.g) * 0.85;
} else if (mat == DH_BLOCK_ILLUMINATED) {
emission = 2.5;
} else if (mat == DH_BLOCK_LAVA) {
emission = 1.5;
}
#ifdef SNOWY_WORLD
DoSnowyWorld(color, smoothnessG, highlightMult, smoothnessD, emission,
playerPos, lmCoord, snowFactor, snowMinNdotU, NdotU, subsurfaceMode);
#endif
vec3 playerPosAlt = ViewToPlayer(viewPos); // AMD has problems with vertex playerPos and DH
float lengthCylinder = max(length(playerPosAlt.xz), abs(playerPosAlt.y));
highlightMult *= 0.5 + 0.5 * pow2(1.0 - smoothstep(far, far * 1.5, lengthCylinder));
color.a *= smoothstep(far * 0.5, far * 0.7, lengthCylinder);
if (color.a < min(dither, 1.0)) discard;
vec3 noisePos = floor((playerPos + cameraPosition) * 4.0 + 0.001) / 32.0;
float noiseTexture = Noise3D(noisePos) + 0.5;
float noiseFactor = max0(1.0 - 0.3 * dot(color.rgb, color.rgb));
color.rgb *= pow(noiseTexture, 0.6 * noiseFactor);
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, noVanillaAO,
centerShadowBias, subsurfaceMode, smoothnessG, highlightMult, emission);
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out int mat;
out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec3 playerPos;
out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
//Program//
void main() {
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
mat = dhMaterialId;
lmCoord = GetLightMapCoordinates();
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
playerPos = (gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex).xyz;
glColor = gl_Color;
}
#endif

View File

@ -0,0 +1,239 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in int mat;
in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec3 playerPos;
in vec3 viewVector;
in vec4 glColor;
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
vec2 lmCoordM = lmCoord;
mat4 gbufferProjection = dhProjection;
mat4 gbufferProjectionInverse = dhProjectionInverse;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2 || defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
eastVec.x, northVec.x, normal.x,
eastVec.y, northVec.y, normal.y,
eastVec.z, northVec.z, normal.z
);
#endif
//Common Functions//
//Includes//
#include "/lib/util/dither.glsl"
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#include "/lib/atmospherics/fog/mainFog.glsl"
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef OVERWORLD
#include "/lib/atmospherics/sky.glsl"
#endif
#if WATER_REFLECT_QUALITY >= 0
#if defined SKY_EFFECT_REFLECTION && defined OVERWORLD
#if AURORA_STYLE > 0
#include "/lib/atmospherics/auroraBorealis.glsl"
#endif
#ifdef NIGHT_NEBULA
#include "/lib/atmospherics/nightNebula.glsl"
#else
#include "/lib/atmospherics/stars.glsl"
#endif
#ifdef VL_CLOUDS_ACTIVE
#include "/lib/atmospherics/clouds/mainClouds.glsl"
#endif
#endif
#include "/lib/materials/materialMethods/reflections.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
//Program//
void main() {
vec4 colorP = vec4(vec3(0.85), glColor.a);
vec4 color = glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
if (texture2D(depthtex1, screenPos.xy).r < 1.0) discard;
float lViewPos = length(playerPos);
float dither = Bayer64(gl_FragCoord.xy);
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
sqrtAtmColorMult = sqrt(atmColorMult);
#endif
#ifdef VL_CLOUDS_ACTIVE
float cloudLinearDepth = texelFetch(gaux1, texelCoord, 0).r;
if (pow2(cloudLinearDepth + OSIEBCA * dither) * renderDistance < min(lViewPos, renderDistance)) discard;
#endif
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
vec3 nViewPos = normalize(viewPos);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
bool noSmoothLighting = false, noDirectionalShading = false, noVanillaAO = false, centerShadowBias = false;
int subsurfaceMode = 0;
float smoothnessG = 0.0, highlightMult = 0.0, emission = 0.0, materialMask = 0.0, reflectMult = 0.0;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
float fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
if (mat == DH_BLOCK_WATER) {
#include "/lib/materials/specificMaterials/translucents/water.glsl"
}
float lengthCylinder = max(length(playerPos.xz), abs(playerPos.y) * 2.0);
color.a *= smoothstep(far * 0.5, far * 0.7, lengthCylinder);
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, noVanillaAO,
centerShadowBias, subsurfaceMode, smoothnessG, highlightMult, emission);
// Reflections
#if WATER_REFLECT_QUALITY >= 0
#ifdef LIGHT_COLOR_MULTS
highlightColor *= lightColorMult;
#endif
#ifdef MOON_PHASE_INF_REFLECTION
highlightColor *= pow2(moonPhaseInfluence);
#endif
float fresnelM = (pow3(fresnel) * 0.85 + 0.15) * reflectMult;
float skyLightFactor = pow2(max(lmCoordM.y - 0.7, 0.0) * 3.33333);
#if SHADOW_QUALITY > -1 && WATER_REFLECT_QUALITY >= 2 && WATER_MAT_QUALITY >= 2
skyLightFactor = max(skyLightFactor, min1(dot(shadowMult, shadowMult)));
#endif
vec4 reflection = GetReflection(normalM, viewPos.xyz, nViewPos, playerPos, lViewPos, -1.0,
depthtex1, dither, skyLightFactor, fresnel,
smoothnessG, geoNormal, color.rgb, shadowMult, highlightMult);
color.rgb = mix(color.rgb, reflection.rgb, fresnelM);
#endif
////
float sky = 0.0;
DoFog(color.rgb, sky, lViewPos, playerPos, VdotU, VdotS, dither);
color.a *= 1.0 - sky;
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out int mat;
out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec3 playerPos;
out vec3 viewVector;
out vec4 glColor;
//Attributes//
attribute vec4 at_tangent;
//Common Variables//
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
//Program//
void main() {
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
mat = dhMaterialId;
lmCoord = GetLightMapCoordinates();
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
playerPos = (gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex).xyz;
mat3 tbnMatrix = mat3(
eastVec.x, northVec.x, normal.x,
eastVec.y, northVec.y, normal.y,
eastVec.z, northVec.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
glColor = gl_Color;
}
#endif

View File

@ -0,0 +1,162 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
noperspective in vec2 texCoord;
//Pipeline Constants//
#include "/lib/pipelineSettings.glsl"
//Common Variables//
#if defined MC_ANISOTROPIC_FILTERING || COLORED_LIGHTING > 0
#define ANY_ERROR_MESSAGE
#endif
#ifdef MC_ANISOTROPIC_FILTERING
#define OPTIFINE_AF_ERROR
#endif
#if COLORED_LIGHTING > 0 && !defined IS_IRIS
#define OPTIFINE_ACL_ERROR
#endif
#if COLORED_LIGHTING > 0 && defined MC_OS_MAC
#define APPLE_ACL_ERROR
#endif
#if COLORED_LIGHTING > 0
#define COORDINATES_ACL_ERROR
#define SHADOWDISTANCE_ACL_ERROR
#endif
//Common Functions//
#if IMAGE_SHARPENING > 0
vec2 viewD = 1.0 / vec2(viewWidth, viewHeight);
vec2 sharpenOffsets[4] = vec2[4](
vec2( viewD.x, 0.0),
vec2( 0.0, viewD.x),
vec2(-viewD.x, 0.0),
vec2( 0.0, -viewD.x)
);
void SharpenImage(inout vec3 color, vec2 texCoordM) {
#ifdef TAA
float sharpenMult = IMAGE_SHARPENING;
#else
float sharpenMult = IMAGE_SHARPENING * 0.5;
#endif
float mult = 0.0125 * sharpenMult;
color *= 1.0 + 0.05 * sharpenMult;
for (int i = 0; i < 4; i++) {
color -= texture2D(colortex3, texCoordM + sharpenOffsets[i]).rgb * mult;
}
}
#endif
//Includes//
#ifdef ANY_ERROR_MESSAGE
#include "/lib/textRendering/textRenderer.glsl"
void beginTextM(int textSize, vec2 offset) {
float scale = 860;
beginText(ivec2(vec2(scale * viewWidth / viewHeight, scale) * texCoord) / textSize, ivec2(0 + offset.x, scale / textSize - offset.y));
text.bgCol = vec4(0.0);
}
#endif
//Program//
void main() {
vec2 texCoordM = texCoord;
#ifdef UNDERWATER_DISTORTION
if (isEyeInWater == 1)
texCoordM += WATER_REFRACTION_INTENSITY * 0.00035 * sin((texCoord.x + texCoord.y) * 25.0 + frameTimeCounter * 3.0);
#endif
vec3 color = texture2D(colortex3, texCoordM).rgb;
#if CHROMA_ABERRATION > 0
vec2 scale = vec2(1.0, viewHeight / viewWidth);
vec2 aberration = (texCoordM - 0.5) * (2.0 / vec2(viewWidth, viewHeight)) * scale * CHROMA_ABERRATION;
color.rb = vec2(texture2D(colortex3, texCoordM + aberration).r, texture2D(colortex3, texCoordM - aberration).b);
#endif
#if IMAGE_SHARPENING > 0
SharpenImage(color, texCoordM);
#endif
/*ivec2 boxOffsets[8] = ivec2[8](
ivec2( 1, 0),
ivec2( 0, 1),
ivec2(-1, 0),
ivec2( 0,-1),
ivec2( 1, 1),
ivec2( 1,-1),
ivec2(-1, 1),
ivec2(-1,-1)
);
for (int i = 0; i < 8; i++) {
color = max(color, texelFetch(colortex3, texelCoord + boxOffsets[i], 0).rgb);
}*/
#ifdef OPTIFINE_AF_ERROR
#include "/lib/textRendering/error_optifine_af.glsl"
#elif defined OPTIFINE_ACL_ERROR
#include "/lib/textRendering/error_optifine_acl.glsl"
#elif defined APPLE_ACL_ERROR
#include "/lib/textRendering/error_apple_acl.glsl"
#else
#ifdef COORDINATES_ACL_ERROR
ivec2 absCameraPositionIntXZ = abs(cameraPositionInt.xz);
if (max(absCameraPositionIntXZ.x, absCameraPositionIntXZ.y) > 8388550) {
#include "/lib/textRendering/error_coordinates_acl.glsl"
}
#endif
#ifdef SHADOWDISTANCE_ACL_ERROR
if (COLORED_LIGHTING_INTERNAL > shadowDistance*2) {
#include "/lib/textRendering/error_shadowdistance_acl.glsl"
}
#endif
#endif
#ifdef VIGNETTE_R
vec2 texCoordMin = texCoordM.xy - 0.5;
float vignette = 1.0 - dot(texCoordMin, texCoordMin) * (1.0 - GetLuminance(color));
color *= vignette;
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = vec4(color, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
noperspective out vec2 texCoord;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}
#endif

View File

@ -0,0 +1,73 @@
//////////////////////////////////
// Complementary Base by EminGT //
//////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
flat in vec4 glColor;
//Pipeline Constants//
//Common Variables//
//Common Functions//
//Includes//
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
color *= glColor;
color.rgb *= glColor.a; // Needed for Minecraft's "Glint Strength" apparently
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
flat out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
#if HAND_SWAYING > 0
if (gl_ProjectionMatrix[2][2] > -0.5) {
#include "/lib/misc/handSway.glsl"
}
#endif
}
#endif

View File

@ -0,0 +1,178 @@
//////////////////////////////////
// Complementary Base by EminGT //
//////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
flat in vec4 glColor;
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(viewPos);
vec3 playerPos = ViewToPlayer(viewPos);
float materialMask = 0.0;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
#ifndef GBUFFERS_LINE
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoord, false, false, false,
false, 0, 0.0, 0.0, 0.0);
#endif
#if SELECT_OUTLINE != 1 || defined SELECT_OUTLINE_AUTO_HIDE
if (abs(color.a - 0.4) + dot(color.rgb, color.rgb) < 0.01) {
#if SELECT_OUTLINE == 0
discard;
#elif SELECT_OUTLINE == 2 // Rainbow
float posFactor = playerPos.x + playerPos.y + playerPos.z + cameraPosition.x + cameraPosition.y + cameraPosition.z;
color.rgb = clamp(abs(mod(fract(frameTimeCounter*0.25 + posFactor*0.2) * 6.0 + vec3(0.0,4.0,2.0), 6.0) - 3.0) - 1.0,
0.0, 1.0) * vec3(3.0, 2.0, 3.0) * SELECT_OUTLINE_I;
#elif SELECT_OUTLINE == 3 // Select Color
color.rgb = vec3(SELECT_OUTLINE_R, SELECT_OUTLINE_G, SELECT_OUTLINE_B) * SELECT_OUTLINE_I;
#elif SELECT_OUTLINE == 4 // Versatile
color.a = 0.1;
materialMask = OSIEBCA * 252.0; // Versatile Selection Outline
#endif
#ifdef SELECT_OUTLINE_AUTO_HIDE
if (heldItemId == 40008 && (
heldItemId2 == 40008 ||
heldItemId2 == 45060 ||
heldItemId2 == 45108 ||
heldItemId2 >= 44000 &&
heldItemId2 < 45000)) {
// Both hands hold nothing or only a light/totem/shield in off-hand
discard;
}
#endif
}
#endif
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
#if COLORED_LIGHTING_INTERNAL > 0 && defined NETHER
if (gl_FragCoord.x < 0.0)
color = shadow2D(shadowtex0, vec3(0.5)); // To Activate Shadowmap in Nether
#endif
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(0.0, materialMask, 0.0, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
flat out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
//Program//
void main() {
#ifndef GBUFFERS_LINE
gl_Position = ftransform();
#else
float lineWidth = 2.0;
vec2 screenSize = vec2(viewWidth, viewHeight);
const mat4 VIEW_SCALE = mat4(mat3(1.0 - (1.0 / 256.0)));
vec4 linePosStart = projectionMatrix * VIEW_SCALE * modelViewMatrix * vec4(vaPosition, 1.0);
vec4 linePosEnd = projectionMatrix * VIEW_SCALE * modelViewMatrix * (vec4(vaPosition + vaNormal, 1.0));
vec3 ndc1 = linePosStart.xyz / linePosStart.w;
vec3 ndc2 = linePosEnd.xyz / linePosEnd.w;
vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * screenSize);
vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * lineWidth / screenSize;
if (lineOffset.x < 0.0)
lineOffset *= -1.0;
if (gl_VertexID % 2 == 0)
gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);
else
gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);
#endif
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
}
#endif

View File

@ -0,0 +1,140 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
flat in vec3 upVec, sunVec;
in vec4 glColor;
//Pipeline Constants//
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/util/dither.glsl"
#include "/lib/atmospherics/fog/mainFog.glsl"
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
vec3 colorP = color.rgb;
color *= glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(viewPos);
vec3 nViewPos = normalize(viewPos);
vec3 playerPos = ViewToPlayer(viewPos);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float dither = Bayer64(gl_FragCoord.xy);
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
#endif
#ifdef IPBR
float emission = dot(colorP, colorP);
if (0.5 > color.a && color.a > 0.01) {
color.a = 0.101;
emission = pow2(pow2(emission)) * 0.1;
}
color.rgb *= color.rgb * emission * 1.75;
color.rgb += emission * 0.05;
#else
color.rgb *= color.rgb * 4.0;
#endif
color.rgb *= 0.5 + 0.5 * exp(-lViewPos * 0.04);
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
// We do border fog here as well because the outer layer of the beam has broken depth in later programs
float sky = 0.0;
if (playerPos.y > 0.0) {
playerPos.y = pow(playerPos.y / renderDistance, 0.15) * renderDistance;
}
DoFog(color.rgb, sky, lViewPos, playerPos, VdotU, VdotS, dither);
color.a *= 1.0 - sky;
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
flat out vec3 upVec, sunVec;
out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
//Program//
void main() {
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
}
#endif

View File

@ -0,0 +1,288 @@
//////////////////////////////////
// Complementary Base by EminGT //
//////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat in vec3 binormal, tangent;
#endif
#ifdef POM
in vec3 viewVector;
in vec4 vTexCoordAM;
#endif
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
#endif
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/util/dither.glsl"
#include "/lib/lighting/mainLighting.glsl"
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#if defined GENERATED_NORMALS || defined COATED_TEXTURES
#include "/lib/util/miplevel.glsl"
#endif
#ifdef GENERATED_NORMALS
#include "/lib/materials/materialMethods/generatedNormals.glsl"
#endif
#ifdef COATED_TEXTURES
#include "/lib/materials/materialMethods/coatedTextures.glsl"
#endif
#if IPBR_EMISSIVE_MODE != 1
#include "/lib/materials/materialMethods/customEmission.glsl"
#endif
#ifdef CUSTOM_PBR
#include "/lib/materials/materialHandling/customMaterials.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
#ifdef PORTAL_EDGE_EFFECT
#include "/lib/misc/voxelization.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
#ifdef GENERATED_NORMALS
vec3 colorP = color.rgb;
#endif
color *= glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(viewPos);
vec3 playerPos = ViewToPlayer(viewPos);
bool noSmoothLighting = false, noDirectionalShading = false;
float smoothnessD = 0.0, skyLightFactor = 0.0, materialMask = 0.0;
float smoothnessG = 0.0, highlightMult = 1.0, emission = 0.0, noiseFactor = 1.0;
vec2 lmCoordM = lmCoord;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
#ifdef IPBR
#include "/lib/materials/materialHandling/blockEntityMaterials.glsl"
#if IPBR_EMISSIVE_MODE != 1
emission = GetCustomEmissionForIPBR(color, emission);
#endif
#else
#ifdef CUSTOM_PBR
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMask, viewPos, lViewPos);
#endif
if (blockEntityId == 5025) { // End Portal, End Gateway
#ifdef SPECIAL_PORTAL_EFFECTS
#include "/lib/materials/specificMaterials/others/endPortalEffect.glsl"
#endif
} else if (blockEntityId == 5004) { // Signs
noSmoothLighting = true;
if (glColor.r + glColor.g + glColor.b <= 2.99 || lmCoord.x > 0.999) { // Sign Text
#include "/lib/materials/specificMaterials/others/signText.glsl"
}
} else {
noSmoothLighting = true;
}
#endif
#ifdef GENERATED_NORMALS
GenerateNormals(normalM, colorP);
#endif
#ifdef COATED_TEXTURES
CoatTextures(color.rgb, noiseFactor, playerPos, false);
#endif
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, false,
false, 0, smoothnessG, highlightMult, emission);
#ifdef PBR_REFLECTIONS
#ifdef OVERWORLD
skyLightFactor = pow2(max(lmCoord.y - 0.7, 0.0) * 3.33333);
#else
skyLightFactor = dot(shadowMult, shadowMult) / 3.0;
#endif
#endif
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, blockEntityId);
#endif
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(smoothnessD, materialMask, skyLightFactor, 1.0);
#if BLOCK_REFLECT_QUALITY >= 2 && RP_MODE != 0
/* DRAWBUFFERS:065 */
gl_FragData[2] = vec4(mat3(gbufferModelViewInverse) * normalM, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat out vec3 binormal, tangent;
#endif
#ifdef POM
out vec3 viewVector;
out vec4 vTexCoordAM;
#endif
//Attributes//
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM
attribute vec4 mc_midTexCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
attribute vec4 at_tangent;
#endif
//Common Variables//
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
//Program//
void main() {
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
if (normal != normal) normal = -upVec; // Mod Fix: Fixes Better Nether Fireflies
#ifdef IPBR
/*if (blockEntityId == 5024) { // End Portal, End Gateway
gl_Position.z -= 0.002;
}*/
#endif
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM
if (blockEntityId == 5008) { // Chest
float fractWorldPosY = fract((gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex).y + cameraPosition.y);
if (fractWorldPosY > 0.56 && 0.57 > fractWorldPosY) gl_Position.z -= 0.0001;
}
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
#endif
#ifdef POM
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
#endif
}
#endif

View File

@ -0,0 +1,150 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
#if CLOUD_STYLE_DEFINE == 50
// We use CLOUD_STYLE_DEFINE instead of CLOUD_STYLE in this file because Optifine can't use generated defines for pipeline stuff
in vec2 texCoord;
flat in vec3 upVec, sunVec;
in vec4 glColor;
#endif
//Pipeline Constants//
//Common Variables//
#if CLOUD_STYLE_DEFINE == 50
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
#endif
//Common Functions//
//Includes//
#if CLOUD_STYLE_DEFINE == 50
#include "/lib/colors/skyColors.glsl"
#include "/lib/util/spaceConversion.glsl"
#if defined TAA && defined BORDER_FOG
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
#endif
//Program//
void main() {
#if CLOUD_STYLE_DEFINE != 50
discard;
#else
vec4 color = texture2D(tex, texCoord) * glColor;
vec4 translucentMult = vec4(mix(vec3(0.666), color.rgb * (1.0 - pow2(pow2(color.a))), color.a), 1.0);
#ifdef OVERWORLD
vec3 cloudLight = mix(vec3(0.8, 1.6, 1.5) * sqrt1(nightFactor), mix(dayDownSkyColor, dayMiddleSkyColor, 0.1), sunFactor);
color.rgb *= sqrt(cloudLight) * (1.2 + 0.4 * noonFactor * invRainFactor);
#if CLOUD_R != 100 || CLOUD_G != 100 || CLOUD_B != 100
color.rgb *= vec3(CLOUD_R, CLOUD_G, CLOUD_B) * 0.01;
#endif
#ifdef ATM_COLOR_MULTS
color.rgb *= sqrt(GetAtmColorMult()); // C72380KD - Reduced atmColorMult impact on things
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
color.rgb *= moonPhaseInfluence;
#endif
#endif
#if defined BORDER_FOG && !defined DREAM_TWEAKED_BORDERFOG
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
vec3 playerPos = ViewToPlayer(viewPos);
float xzMaxDistance = max(abs(playerPos.x), abs(playerPos.z));
float cloudDistance = 375.0;
cloudDistance = clamp((cloudDistance - xzMaxDistance) / cloudDistance, 0.0, 1.0);
color.a *= clamp01(cloudDistance * 3.0);
#endif
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:063 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);
gl_FragData[2] = vec4(1.0 - translucentMult.rgb, translucentMult.a);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
#if CLOUD_STYLE_DEFINE == 50
out vec2 texCoord;
flat out vec3 upVec, sunVec;
out vec4 glColor;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
#if CLOUD_STYLE_DEFINE == 50
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#endif
//Program//
void main() {
#if CLOUD_STYLE_DEFINE != 50
gl_Position = vec4(-1.0);
#else
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
#endif
}
#endif

View File

@ -0,0 +1,63 @@
//////////////////////////////////
// Complementary Base by EminGT //
//////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
flat in vec4 glColor;
//Pipeline Constants//
//Common Variables//
//Common Functions//
//Includes//
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
color.rgb *= glColor.rgb;
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
flat out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
}
#endif

View File

@ -0,0 +1,309 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
flat in vec2 midCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat in vec3 binormal, tangent;
#endif
#ifdef POM
in vec3 viewVector;
in vec4 vTexCoordAM;
#endif
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
#endif
//Common Functions//
//Includes//
#include "/lib/util/dither.glsl"
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#if defined GENERATED_NORMALS || defined COATED_TEXTURES
#include "/lib/util/miplevel.glsl"
#endif
#ifdef GENERATED_NORMALS
#include "/lib/materials/materialMethods/generatedNormals.glsl"
#endif
#ifdef COATED_TEXTURES
#include "/lib/materials/materialMethods/coatedTextures.glsl"
#endif
#if IPBR_EMISSIVE_MODE != 1
#include "/lib/materials/materialMethods/customEmission.glsl"
#endif
#ifdef CUSTOM_PBR
#include "/lib/materials/materialHandling/customMaterials.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
#ifdef GENERATED_NORMALS
vec3 colorP = color.rgb;
#endif
color *= glColor;
float smoothnessD = 0.0, skyLightFactor = 0.0, materialMask = OSIEBCA * 254.0; // No SSAO, No TAA
vec3 normalM = normal;
float alphaCheck = color.a;
#ifdef DO_PIXELATION_EFFECTS
// Fixes artifacts on fragment edges with non-nvidia gpus
alphaCheck = max(fwidth(color.a), alphaCheck);
#endif
if (alphaCheck > 0.001) {
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
vec3 viewPos = ScreenToView(screenPos);
vec3 nViewPos = normalize(viewPos);
vec3 playerPos = ViewToPlayer(viewPos);
float lViewPos = length(viewPos);
bool noSmoothLighting = atlasSize.x < 600.0; // To fix fire looking too dim
bool noGeneratedNormals = false, noDirectionalShading = false, noVanillaAO = false;
float smoothnessG = 0.0, highlightMult = 0.0, emission = 0.0, noiseFactor = 0.75;
vec2 lmCoordM = lmCoord;
vec3 shadowMult = vec3(1.0);
#ifdef IPBR
#include "/lib/materials/materialHandling/entityMaterials.glsl"
#ifdef IS_IRIS
vec3 maRecolor = vec3(0.0);
#include "/lib/materials/materialHandling/irisMaterials.glsl"
#endif
if (materialMask != OSIEBCA * 254.0) materialMask += OSIEBCA * 100.0; // Entity Reflection Handling
#ifdef GENERATED_NORMALS
if (!noGeneratedNormals) GenerateNormals(normalM, colorP);
#endif
#ifdef COATED_TEXTURES
CoatTextures(color.rgb, noiseFactor, playerPos, false);
#endif
#if IPBR_EMISSIVE_MODE != 1
emission = GetCustomEmissionForIPBR(color, emission);
#endif
#else
#ifdef CUSTOM_PBR
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMask, viewPos, lViewPos);
#endif
if (entityId == 50004) { // Lightning Bolt
#include "/lib/materials/specificMaterials/entities/lightningBolt.glsl"
} else if (entityId == 50008) { // Item Frame, Glow Item Frame
noSmoothLighting = true;
} else if (entityId == 50076) { // Boats
playerPos.y += 0.38; // consistentBOAT2176
}
#endif
color.rgb = mix(color.rgb, entityColor.rgb, entityColor.a);
normalM = gl_FrontFacing ? normalM : -normalM; // Inverted Normal Workaround
vec3 geoNormal = normalM;
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, noVanillaAO,
true, 0, smoothnessG, highlightMult, emission);
#if defined IPBR && defined IS_IRIS
color.rgb += maRecolor;
#endif
#ifdef PBR_REFLECTIONS
#ifdef OVERWORLD
skyLightFactor = pow2(max(lmCoord.y - 0.7, 0.0) * 3.33333);
#else
skyLightFactor = dot(shadowMult, shadowMult) / 3.0;
#endif
#endif
}
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(smoothnessD, materialMask, skyLightFactor, 1.0);
#if BLOCK_REFLECT_QUALITY >= 2 && RP_MODE >= 1
/* DRAWBUFFERS:065 */
gl_FragData[2] = vec4(mat3(gbufferModelViewInverse) * normalM, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
flat out vec2 midCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat out vec3 binormal, tangent;
#endif
#ifdef POM
out vec3 viewVector;
out vec4 vTexCoordAM;
#endif
//Attributes//
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
attribute vec4 mc_midTexCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
attribute vec4 at_tangent;
#endif
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
lmCoord.x = min(lmCoord.x, 0.9);
//Fixes some servers/mods making entities insanely bright, while also slightly reducing the max blocklight on a normal entity
glColor = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
#endif
#ifdef POM
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
#endif
#ifdef GBUFFERS_ENTITIES_GLOWING
if (glColor.a > 0.99) gl_Position.z *= 0.01;
#endif
#ifdef FLICKERING_FIX
if (entityId == 50008 || entityId == 50012) { // Item Frame, Glow Item Frame
if (dot(normal, upVec) > 0.99) {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec3 comPos = fract(position.xyz + cameraPosition);
comPos = abs(comPos - vec3(0.5));
if ((comPos.y > 0.437 && comPos.y < 0.438) || (comPos.y > 0.468 && comPos.y < 0.469)) {
gl_Position.z += 0.0001;
}
}
if (gl_Normal.y == 1.0) { // Maps
normal = upVec * 2.0;
}
} else if (entityId == 50084) { // Slime, Chicken
gl_Position.z -= 0.00015;
}
#if SHADOW_QUALITY == -1
if (glColor.a < 0.5) gl_Position.z += 0.0005;
#endif
#endif
}
#endif

View File

@ -0,0 +1,270 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
in vec2 lmCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
flat in vec2 midCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat in vec3 binormal, tangent;
#endif
#ifdef POM
in vec3 viewVector;
in vec4 vTexCoordAM;
#endif
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, vec3(0.0, 1.0, 0.0)); // NdotU is different here to improve held map visibility
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
#endif
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#if defined GENERATED_NORMALS || defined COATED_TEXTURES
#include "/lib/util/miplevel.glsl"
#endif
#ifdef GENERATED_NORMALS
#include "/lib/materials/materialMethods/generatedNormals.glsl"
#endif
#ifdef COATED_TEXTURES
#include "/lib/materials/materialMethods/coatedTextures.glsl"
#endif
#if IPBR_EMISSIVE_MODE != 1
#include "/lib/materials/materialMethods/customEmission.glsl"
#endif
#ifdef CUSTOM_PBR
#include "/lib/materials/materialHandling/customMaterials.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
float smoothnessD = 0.0, skyLightFactor = 0.0, materialMask = OSIEBCA * 254.0; // No SSAO, No TAA
vec3 normalM = normal;
float alphaCheck = color.a;
#ifdef DO_PIXELATION_EFFECTS
// Fixes artifacts on fragment edges with non-nvidia gpus
alphaCheck = max(fwidth(color.a), alphaCheck);
#endif
if (alphaCheck > 0.001) {
#ifdef GENERATED_NORMALS
vec3 colorP = color.rgb;
#endif
color *= glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z + 0.38);
vec3 viewPos = ScreenToView(screenPos);
vec3 playerPos = ViewToPlayer(viewPos);
if (color.a < 0.75) materialMask = 0.0;
bool noSmoothLighting = true, noGeneratedNormals = false, noDirectionalShading = false, noVanillaAO = false;
float smoothnessG = 0.0, highlightMult = 1.0, emission = 0.0, noiseFactor = 0.6;
vec2 lmCoordM = lmCoord;
vec3 geoNormal = normalM;
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
vec3 shadowMult = vec3(0.4);
#ifdef IPBR
#ifdef IS_IRIS
vec3 maRecolor = vec3(0.0);
#include "/lib/materials/materialHandling/irisMaterials.glsl"
if (materialMask != OSIEBCA * 254.0) materialMask += OSIEBCA * 100.0; // Entity Reflection Handling
#endif
#ifdef GENERATED_NORMALS
if (!noGeneratedNormals) GenerateNormals(normalM, colorP);
#endif
#ifdef COATED_TEXTURES
CoatTextures(color.rgb, noiseFactor, playerPos, false);
#endif
#if IPBR_EMISSIVE_MODE != 1
emission = GetCustomEmissionForIPBR(color, emission);
#endif
#else
#ifdef CUSTOM_PBR
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMask, viewPos, 0.0);
#endif
#endif
DoLighting(color, shadowMult, playerPos, viewPos, 0.0, geoNormal, normalM, 0.5,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, noVanillaAO,
false, 0, smoothnessG, highlightMult, emission);
#if defined IPBR && defined IS_IRIS
color.rgb += maRecolor;
#endif
#if (defined CUSTOM_PBR || defined IPBR && defined IS_IRIS) && defined PBR_REFLECTIONS
#ifdef OVERWORLD
skyLightFactor = pow2(max(lmCoord.y - 0.7, 0.0) * 3.33333);
#else
skyLightFactor = dot(shadowMult, shadowMult) / 3.0;
#endif
#endif
}
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(smoothnessD, materialMask, skyLightFactor, 1.0);
#if BLOCK_REFLECT_QUALITY >= 2 && (RP_MODE >= 2 || defined IS_IRIS)
/* DRAWBUFFERS:065 */
gl_FragData[2] = vec4(mat3(gbufferModelViewInverse) * normalM, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
out vec2 lmCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec4 glColor;
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
flat out vec2 midCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
flat out vec3 binormal, tangent;
#endif
#ifdef POM
out vec3 viewVector;
out vec4 vTexCoordAM;
#endif
//Attributes//
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
attribute vec4 mc_midTexCoord;
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
attribute vec4 at_tangent;
#endif
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || defined POM || defined IPBR && defined IS_IRIS
midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
#endif
#if defined GENERATED_NORMALS || defined CUSTOM_PBR
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
#endif
#ifdef POM
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
#endif
#if HAND_SWAYING > 0
#include "/lib/misc/handSway.glsl"
#endif
}
#endif

View File

@ -0,0 +1,214 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in vec3 upVec, sunVec;
flat in vec4 glColor;
#ifdef OVERWORLD
flat in float vanillaStars;
#endif
//Pipeline Constants//
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
//Common Functions//
//Includes//
#include "/lib/util/dither.glsl"
#ifdef OVERWORLD
#include "/lib/atmospherics/sky.glsl"
#include "/lib/atmospherics/stars.glsl"
#endif
#ifdef CAVE_FOG
#include "/lib/atmospherics/fog/caveFactor.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
#if SUN_MOON_STYLE >= 2
#include "/lib/util/spaceConversion.glsl"
#endif
//Program//
void main() {
vec4 color = vec4(glColor.rgb, 1.0);
#ifdef OVERWORLD
if (vanillaStars > 0.5) {
discard;
}
#if IRIS_VERSION >= 10800 && IRIS_VERSION < 10805
if (renderStage == MC_RENDER_STAGE_MOON) {
discard; // Fixes the vanilla sky gradient causing the sun to disappear
}
#endif
vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
vec3 nViewPos = normalize(viewPos.xyz);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float dither = Bayer8(gl_FragCoord.xy);
color.rgb = GetSky(VdotU, VdotS, dither, true, false);
#ifdef ATM_COLOR_MULTS
color.rgb *= GetAtmColorMult();
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
color.rgb *= moonPhaseInfluence;
#endif
vec2 starCoord = GetStarCoord(viewPos.xyz, 0.5);
color.rgb += GetStars(starCoord, VdotU, VdotS);
#if SUN_MOON_STYLE >= 2
float absVdotS = abs(VdotS);
#if SUN_MOON_STYLE == 2
float sunSizeFactor1 = 0.9975;
float sunSizeFactor2 = 400.0;
float moonCrescentOffset = 0.0055;
float moonPhaseFactor1 = 2.45;
float moonPhaseFactor2 = 750.0;
#else
float sunSizeFactor1 = 0.9983;
float sunSizeFactor2 = 588.235;
float moonCrescentOffset = 0.0042;
float moonPhaseFactor1 = 2.2;
float moonPhaseFactor2 = 1000.0;
#endif
if (absVdotS > sunSizeFactor1) {
float sunMoonMixer = sqrt1(sunSizeFactor2 * (absVdotS - sunSizeFactor1));
#ifdef SUN_MOON_DURING_RAIN
sunMoonMixer *= 1.0 - 0.4 * rainFactor2;
#else
sunMoonMixer *= 1.0 - rainFactor2;
#endif
if (VdotS > 0.0) {
sunMoonMixer = pow2(sunMoonMixer) * GetHorizonFactor(SdotU);
#ifdef CAVE_FOG
sunMoonMixer *= 1.0 - 0.65 * GetCaveFactor();
#endif
color.rgb = mix(color.rgb, vec3(0.9, 0.5, 0.3) * 10.0, sunMoonMixer);
} else {
float horizonFactor = GetHorizonFactor(-SdotU);
sunMoonMixer = max0(sunMoonMixer - 0.25) * 1.33333 * horizonFactor;
starCoord = GetStarCoord(viewPos.xyz, 1.0) * 0.5 + 0.617;
float moonNoise = texture2D(noisetex, starCoord).g
+ texture2D(noisetex, starCoord * 2.5).g * 0.7
+ texture2D(noisetex, starCoord * 5.0).g * 0.5;
moonNoise = max0(moonNoise - 0.75) * 1.7;
vec3 moonColor = vec3(0.38, 0.4, 0.5) * (1.2 - (0.2 + 0.2 * sqrt1(nightFactor)) * moonNoise);
if (moonPhase >= 1) {
float moonPhaseOffset = 0.0;
if (moonPhase != 4) {
moonPhaseOffset = moonCrescentOffset;
moonColor *= 8.5;
} else moonColor *= 10.0;
if (moonPhase > 4) {
moonPhaseOffset = -moonPhaseOffset;
}
float ang = fract(timeAngle - (0.25 + moonPhaseOffset));
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
vec2 sunRotationData2 = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
vec3 rawSunVec2 = (gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData2) * 2000.0, 1.0)).xyz;
float moonPhaseVdosS = dot(nViewPos, normalize(rawSunVec2.xyz));
sunMoonMixer *= pow2(1.0 - min1(pow(abs(moonPhaseVdosS), moonPhaseFactor2) * moonPhaseFactor1));
} else moonColor *= 4.0;
#ifdef CAVE_FOG
sunMoonMixer *= 1.0 - 0.5 * GetCaveFactor();
#endif
color.rgb = mix(color.rgb, moonColor, sunMoonMixer);
}
}
#endif
#endif
color.rgb *= 1.0 - maxBlindnessDarkness;
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out vec3 upVec, sunVec;
flat out vec4 glColor;
#ifdef OVERWORLD
flat out float vanillaStars;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
glColor = gl_Color;
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#ifdef OVERWORLD
//Vanilla Star Dedection by Builderb0y
vanillaStars = float(glColor.r == glColor.g && glColor.g == glColor.b && glColor.r > 0.0 && glColor.r < 0.51);
#endif
}
#endif

View File

@ -0,0 +1,153 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
flat in vec4 glColor;
#ifdef OVERWORLD
flat in vec3 upVec, sunVec;
#endif
//Pipeline Constants//
//Common Variables//
#ifdef OVERWORLD
float SdotU = dot(sunVec, upVec);
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
#endif
//Common Functions//
//Includes//
#include "/lib/colors/lightAndAmbientColors.glsl"
#ifdef CAVE_FOG
#include "/lib/atmospherics/fog/caveFactor.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
#ifdef OVERWORLD
vec2 tSize = textureSize(tex, 0);
vec4 color = texture2D(tex, texCoord);
color.rgb *= glColor.rgb;
vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w;
vec3 nViewPos = normalize(viewPos.xyz);
float VdotS = dot(nViewPos, sunVec);
float VdotU = dot(nViewPos, upVec);
#ifdef IS_IRIS
bool isSun = renderStage == MC_RENDER_STAGE_SUN;
bool isMoon = renderStage == MC_RENDER_STAGE_MOON;
#else
bool tSizeCheck = abs(tSize.y - 264.0) < 248.5; //tSize.y must range from 16 to 512
bool sunSideCheck = VdotS > 0.0;
bool isSun = tSizeCheck && sunSideCheck;
bool isMoon = tSizeCheck && !sunSideCheck;
#endif
if (isSun || isMoon) {
#if SUN_MOON_STYLE >= 2
discard;
#endif
if (isSun) {
color.rgb *= dot(color.rgb, color.rgb) * normalize(lightColor) * 3.2;
color.rgb *= 0.25 + (0.75 - 0.25 * rainFactor) * sunVisibility2;
}
if (isMoon) {
color.rgb *= smoothstep1(min1(length(color.rgb))) * 1.3;
}
color.rgb *= GetHorizonFactor(VdotU);
#ifdef CAVE_FOG
color.rgb *= 1.0 - 0.75 * GetCaveFactor();
#endif
} else { // Custom Sky
#if MC_VERSION >= 11300
color.rgb *= color.rgb * smoothstep1(sqrt1(max0(VdotU)));
#else
discard;
// Old mc custom skyboxes are weirdly broken, so we discard.
#endif
}
if (isEyeInWater == 1) color.rgb *= 0.25;
#ifdef SUN_MOON_DURING_RAIN
color.a *= 1.0 - 0.8 * rainFactor;
#else
color.a *= 1.0 - rainFactor;
#endif
#endif
#ifdef NETHER
vec4 color = vec4(0.0);
#endif
#ifdef END
vec4 color = vec4(endSkyColor, 1.0);
#endif
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
flat out vec4 glColor;
#ifdef OVERWORLD
flat out vec3 upVec, sunVec;
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
#ifdef OVERWORLD
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#endif
}
#endif

View File

@ -0,0 +1,75 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
in vec4 glColor;
//Pipeline Constants//
//Common Variables//
//Common Functions//
//Includes//
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord) * glColor;
#ifdef IPBR
if (CheckForColor(color.rgb, vec3(224, 121, 250))) { // Enderman Eye Edges
color.rgb = vec3(0.8, 0.25, 0.8);
}
#endif
color.rgb *= 1.0 - 0.6 * pow2(pow2(min1(GetLuminance(color.rgb) * 1.2))); // Fixes ultra bright Breeze
color.rgb = pow1_5(color.rgb);
color.rgb *= pow2(1.0 + color.b + 0.5 * color.g) * 1.5;
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
glColor = gl_Color;
}
#endif

View File

@ -0,0 +1,485 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in int mat;
in vec2 texCoord;
in vec2 lmCoord;
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
flat in vec2 midCoord;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 normal;
in vec3 vertexPos;
in vec4 glColorRaw;
#if RAIN_PUDDLES >= 1 || defined GENERATED_NORMALS || defined CUSTOM_PBR
flat in vec3 binormal, tangent;
#endif
#ifdef POM
in vec3 viewVector;
in vec4 vTexCoordAM;
#endif
#if ANISOTROPIC_FILTER > 0
in vec4 spriteBounds;
#endif
//Pipeline Constants//
#if COLORED_LIGHTING_INTERNAL > 0
const float voxelDistance = 32.0;
#endif
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
vec4 glColor = glColorRaw;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if RAIN_PUDDLES >= 1 || defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
#endif
//Common Functions//
void DoFoliageColorTweaks(inout vec3 color, inout vec3 shadowMult, inout float snowMinNdotU, vec3 viewPos, vec3 nViewPos, float lViewPos, float dither) {
#ifdef DREAM_TWEAKED_LIGHTING
return;
#endif
float factor = max(80.0 - lViewPos, 0.0);
shadowMult *= 1.0 + 0.004 * noonFactor * factor;
#if defined IPBR && !defined IPBR_COMPATIBILITY_MODE
if (signMidCoordPos.x < 0.0) color.rgb *= 1.08;
else color.rgb *= 0.93;
#endif
#ifdef FOLIAGE_ALT_SUBSURFACE
float edgeSize = 0.12;
float edgeEffectFactor = 0.75;
edgeEffectFactor *= (sqrt1(abs(dot(nViewPos, normal))) - 0.1) * 1.111;
vec2 texCoordM = texCoord;
texCoordM.y -= edgeSize * pow2(dither) * absMidCoordPos.y;
texCoordM.y = max(texCoordM.y, midCoord.y - absMidCoordPos.y);
vec4 colorSample = texture2DLod(tex, texCoordM, 0);
if (colorSample.a < 0.5) {
float edgeFactor = dot(nViewPos, lightVec);
shadowMult *= 1.0 + edgeEffectFactor * (1.0 + edgeFactor);
}
shadowMult *= 1.0 + 0.2333 * edgeEffectFactor * (dot(normal, lightVec) - 1.0);
#endif
#ifdef SNOWY_WORLD
if (glColor.g - glColor.b > 0.01)
snowMinNdotU = min(pow2(pow2(max0(color.g * 2.0 - color.r - color.b))) * 5.0, 0.1);
else
snowMinNdotU = min(pow2(pow2(max0(color.g * 2.0 - color.r - color.b))) * 3.0, 0.1) * 0.25;
#ifdef DISTANT_HORIZONS
// DH chunks don't have foliage. The border looks too noticeable without this tweak
snowMinNdotU = mix(snowMinNdotU, 0.09, smoothstep(far * 0.5, far, lViewPos));
#endif
#endif
}
void DoBrightBlockTweaks(vec3 color, float minLight, inout vec3 shadowMult, inout float highlightMult) {
float factor = mix(minLight, 1.0, pow2(pow2(color.r)));
shadowMult = vec3(factor);
highlightMult /= factor;
}
void DoOceanBlockTweaks(inout float smoothnessD) {
smoothnessD *= max0(lmCoord.y - 0.95) * 20.0;
}
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#include "/lib/util/dither.glsl"
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || ANISOTROPIC_FILTER > 0 || defined DISTANT_LIGHT_BOKEH
#include "/lib/util/miplevel.glsl"
#endif
#ifdef GENERATED_NORMALS
#include "/lib/materials/materialMethods/generatedNormals.glsl"
#endif
#ifdef COATED_TEXTURES
#include "/lib/materials/materialMethods/coatedTextures.glsl"
#endif
#if IPBR_EMISSIVE_MODE != 1
#include "/lib/materials/materialMethods/customEmission.glsl"
#endif
#ifdef CUSTOM_PBR
#include "/lib/materials/materialHandling/customMaterials.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
#if ANISOTROPIC_FILTER > 0
#include "/lib/materials/materialMethods/anisotropicFiltering.glsl"
#endif
#ifdef PUDDLE_VOXELIZATION
#include "/lib/misc/puddleVoxelization.glsl"
#endif
#ifdef SNOWY_WORLD
#include "/lib/materials/materialMethods/snowyWorld.glsl"
#endif
#ifdef DISTANT_LIGHT_BOKEH
#include "/lib/misc/distantLightBokeh.glsl"
#endif
//Program//
void main() {
#if ANISOTROPIC_FILTER == 0
vec4 color = texture2D(tex, texCoord);
#else
vec4 color = textureAF(tex, texCoord);
#endif
float smoothnessD = 0.0, materialMask = 0.0, skyLightFactor = 0.0;
#if !defined POM || !defined POM_ALLOW_CUTOUT
if (color.a <= 0.00001) discard; // 6WIR4HT23
#endif
vec3 colorP = color.rgb;
color.rgb *= glColor.rgb;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(viewPos);
vec3 nViewPos = normalize(viewPos);
vec3 playerPos = vertexPos;
float dither = Bayer64(gl_FragCoord.xy);
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
int subsurfaceMode = 0;
bool noSmoothLighting = false, noDirectionalShading = false, noVanillaAO = false, centerShadowBias = false, noGeneratedNormals = false, doTileRandomisation = true;
float smoothnessG = 0.0, highlightMult = 1.0, emission = 0.0, noiseFactor = 1.0, snowFactor = 1.0, snowMinNdotU = 0.0, noPuddles = 0.0;
vec2 lmCoordM = lmCoord;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
#ifdef IPBR
vec3 maRecolor = vec3(0.0);
#include "/lib/materials/materialHandling/terrainMaterials.glsl"
#ifdef GENERATED_NORMALS
if (!noGeneratedNormals) GenerateNormals(normalM, colorP);
#endif
#ifdef COATED_TEXTURES
CoatTextures(color.rgb, noiseFactor, playerPos, doTileRandomisation);
#endif
#if IPBR_EMISSIVE_MODE != 1
emission = GetCustomEmissionForIPBR(color, emission);
#endif
#else
#ifdef CUSTOM_PBR
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMask, viewPos, lViewPos);
#endif
if (mat == 10001) { // No directional shading
noDirectionalShading = true;
} else if (mat == 10005) { // Grounded Waving Foliage
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
} else if (mat == 10009) { // Leaves
#include "/lib/materials/specificMaterials/terrain/leaves.glsl"
} else if (mat == 10013) { // Vine
subsurfaceMode = 3, centerShadowBias = true; noSmoothLighting = true;
} else if (mat == 10017) { // Non-waving Foliage
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
} else if (mat == 10021) { // Upper Waving Foliage
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
} else if (mat == 10028) { // Modded Light Sources
noSmoothLighting = true; noDirectionalShading = true;
emission = GetLuminance(color.rgb) * 2.5;
}
#ifdef SNOWY_WORLD
else if (mat == 10132) { // Grass Block:Normal
if (glColor.b < 0.999) { // Grass Block:Normal:Grass Part
snowMinNdotU = min(pow2(pow2(color.g)) * 1.9, 0.1);
color.rgb = color.rgb * 0.5 + 0.5 * (color.rgb / glColor.rgb);
}
}
#endif
else if (lmCoord.x > 0.99999) lmCoordM.x = 0.95;
#endif
#ifdef SNOWY_WORLD
DoSnowyWorld(color, smoothnessG, highlightMult, smoothnessD, emission,
playerPos, lmCoord, snowFactor, snowMinNdotU, NdotU, subsurfaceMode);
#endif
#if RAIN_PUDDLES >= 1
float puddleLightFactor = max0(lmCoord.y * 32.0 - 31.0) * clamp((1.0 - 1.15 * lmCoord.x) * 10.0, 0.0, 1.0);
float puddleNormalFactor = pow2(max0(NdotUmax0 - 0.5) * 2.0);
float puddleMixer = puddleLightFactor * inRainy * puddleNormalFactor;
#if RAIN_PUDDLES < 3
float wetnessM = wetness;
#else
float wetnessM = 1.0;
#endif
#ifdef PUDDLE_VOXELIZATION
vec3 voxelPos = SceneToPuddleVoxel(playerPos);
vec3 voxel_sample_pos = clamp01(voxelPos / vec3(puddle_voxelVolumeSize));
if (CheckInsidePuddleVoxelVolume(voxelPos)) {
noPuddles += texture2D(puddle_sampler, voxel_sample_pos.xz).r;
}
#endif
if (pow2(pow2(wetnessM)) * puddleMixer - noPuddles > 0.00001) {
vec2 worldPosXZ = playerPos.xz + cameraPosition.xz;
vec2 puddleWind = vec2(frameTimeCounter) * 0.03;
#if WATER_STYLE == 1
vec2 puddlePosNormal = floor(worldPosXZ * 16.0) * 0.0625;
#else
vec2 puddlePosNormal = worldPosXZ;
#endif
puddlePosNormal *= 0.1;
vec2 pNormalCoord1 = puddlePosNormal + vec2(puddleWind.x, puddleWind.y);
vec2 pNormalCoord2 = puddlePosNormal + vec2(puddleWind.x * -1.5, puddleWind.y * -1.0);
vec3 pNormalNoise1 = texture2D(noisetex, pNormalCoord1).rgb;
vec3 pNormalNoise2 = texture2D(noisetex, pNormalCoord2).rgb;
float pNormalMult = 0.03;
vec3 puddleNormal = vec3((pNormalNoise1.xy + pNormalNoise2.xy - vec2(1.0)) * pNormalMult, 1.0);
puddleNormal = clamp(normalize(puddleNormal * tbnMatrix), vec3(-1.0), vec3(1.0));
#if RAIN_PUDDLES == 1 || RAIN_PUDDLES == 3
vec2 puddlePosForm = puddlePosNormal * 0.05;
float pFormNoise = texture2D(noisetex, puddlePosForm).b * 3.0;
pFormNoise += texture2D(noisetex, puddlePosForm * 0.5).b * 5.0;
pFormNoise += texture2D(noisetex, puddlePosForm * 0.25).b * 8.0;
pFormNoise *= sqrt1(wetnessM) * 0.5625 + 0.4375;
pFormNoise = clamp(pFormNoise - 7.0, 0.0, 1.0);
#else
float pFormNoise = wetnessM;
#endif
puddleMixer *= pFormNoise;
float puddleSmoothnessG = 0.7 - rainFactor * 0.3;
float puddleHighlight = (1.5 - subsurfaceMode * 0.6 * invNoonFactor);
smoothnessG = mix(smoothnessG, puddleSmoothnessG, puddleMixer);
highlightMult = mix(highlightMult, puddleHighlight, puddleMixer);
smoothnessD = mix(smoothnessD, 1.0, sqrt1(puddleMixer));
normalM = mix(normalM, puddleNormal, puddleMixer * rainFactor);
}
#endif
#if SHOW_LIGHT_LEVEL > 0
#include "/lib/misc/showLightLevels.glsl"
#endif
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, dither,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, noVanillaAO,
centerShadowBias, subsurfaceMode, smoothnessG, highlightMult, emission);
#ifdef IPBR
color.rgb += maRecolor;
#endif
#ifdef PBR_REFLECTIONS
#ifdef OVERWORLD
skyLightFactor = pow2(max(lmCoord.y - 0.7, 0.0) * 3.33333);
#else
skyLightFactor = dot(shadowMult, shadowMult) / 3.0;
#endif
#endif
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, mat);
#endif
/* DRAWBUFFERS:06 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(smoothnessD, materialMask, skyLightFactor, 1.0);
#if BLOCK_REFLECT_QUALITY >= 2 && RP_MODE != 0
/* DRAWBUFFERS:065 */
gl_FragData[2] = vec4(mat3(gbufferModelViewInverse) * normalM, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out int mat;
out vec2 texCoord;
out vec2 lmCoord;
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
flat out vec2 midCoord;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 normal;
out vec3 vertexPos;
out vec4 glColorRaw;
#if RAIN_PUDDLES >= 1 || defined GENERATED_NORMALS || defined CUSTOM_PBR
flat out vec3 binormal, tangent;
#endif
#ifdef POM
out vec3 viewVector;
out vec4 vTexCoordAM;
#endif
#if ANISOTROPIC_FILTER > 0
out vec4 spriteBounds;
#endif
//Attributes//
attribute vec4 mc_Entity;
attribute vec4 mc_midTexCoord;
#if RAIN_PUDDLES >= 1 || defined GENERATED_NORMALS || defined CUSTOM_PBR
attribute vec4 at_tangent;
#endif
//Common Variables//
vec4 glColor = vec4(1.0);
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef WAVING_ANYTHING_TERRAIN
#include "/lib/materials/materialMethods/wavingBlocks.glsl"
#endif
//Program//
void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
glColorRaw = gl_Color;
if (glColorRaw.a < 0.1) glColorRaw.a = 1.0;
glColor = glColorRaw;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
mat = int(mc_Entity.x + 0.5);
#if ANISOTROPIC_FILTER > 0
if (mc_Entity.y > 0.5 && dot(normal, upVec) < 0.999) absMidCoordPos = vec2(0.0); // Fix257062
#endif
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vertexPos = position.xyz;
#ifdef WAVING_ANYTHING_TERRAIN
DoWave(position.xyz, mat);
#endif
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef FLICKERING_FIX
if (mat == 10257) gl_Position.z -= 0.00001; // Iron Bars
#endif
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
#if RAIN_PUDDLES >= 1 || defined GENERATED_NORMALS || defined CUSTOM_PBR
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
#endif
#ifdef POM
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
#endif
#if ANISOTROPIC_FILTER > 0
vec2 spriteRadius = abs(texCoord - mc_midTexCoord.xy);
vec2 bottomLeft = mc_midTexCoord.xy - spriteRadius;
vec2 topRight = mc_midTexCoord.xy + spriteRadius;
spriteBounds = vec4(bottomLeft, topRight);
#endif
}
#endif

View File

@ -0,0 +1,241 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
in vec2 texCoord;
in vec2 lmCoord;
flat in vec3 upVec, sunVec;
in vec3 normal;
flat in vec4 glColor;
#ifdef CLOUD_SHADOWS
flat in vec3 eastVec;
#if SUN_ANGLE != 0
flat in vec3 northVec;
#endif
#endif
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#include "/lib/util/dither.glsl"
#if MC_VERSION >= 11500
#include "/lib/atmospherics/fog/mainFog.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
vec4 colorP = color;
color *= glColor;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
vec3 viewPos = ScreenToView(screenPos);
float lViewPos = length(viewPos);
vec3 playerPos = ViewToPlayer(viewPos);
float dither = texture2D(noisetex, gl_FragCoord.xy / 128.0).b;
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
#endif
#ifdef VL_CLOUDS_ACTIVE
float cloudLinearDepth = texelFetch(gaux1, texelCoord, 0).r;
if (cloudLinearDepth > 0.0) // Because Iris changes the pipeline position of opaque particles
if (pow2(cloudLinearDepth + OSIEBCA * dither) * renderDistance < min(lViewPos, renderDistance)) discard;
#endif
float emission = 0.0, materialMask = OSIEBCA * 254.0; // No SSAO, No TAA
vec2 lmCoordM = lmCoord;
vec3 normalM = normal, geoNormal = normal, shadowMult = vec3(1.0);
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
#if defined IPBR && defined IPBR_PARTICLE_FEATURES
// We don't want to detect particles from the block atlas
#if MC_VERSION >= 12000
float atlasCheck = 1100.0; // I think texture atlas got bigger in newer mc
#else
float atlasCheck = 900.0;
#endif
if (atlasSize.x < atlasCheck) {
if (color.b > 1.15 * (color.r + color.g) && color.g > color.r * 1.25 && color.g < 0.425 && color.b > 0.75) { // Water Particle
materialMask = 0.0;
color.rgb = sqrt3(color.rgb);
color.rgb *= 0.7;
if (dither > 0.4) discard;
#ifdef OVERWORLD
} else if (color.b > 0.7 && color.r < 0.28 && color.g < 0.425 && color.g > color.r * 1.4){ // physics mod rain
if (color.a < 0.1 || isEyeInWater == 3) discard;
color.a *= rainTexOpacity;
color.rgb = sqrt2(color.rgb) * (blocklightCol * 2.0 * lmCoord.x + ambientColor * lmCoord.y * (0.7 + 0.35 * sunFactor));
} else if (color.rgb == vec3(1.0) && color.a < 0.765 && color.a > 0.605) { // physics mod snow (default snow opacity only)
if (color.a < 0.1 || isEyeInWater == 3) discard;
color.a *= snowTexOpacity;
color.rgb = sqrt2(color.rgb) * (blocklightCol * 2.0 * lmCoord.x + lmCoord.y * (0.7 + 0.35 * sunFactor) + ambientColor * 0.2);
#endif
} else if (color.r == color.g && color.r - 0.5 * color.b < 0.06) { // Underwater Particle
if (isEyeInWater == 1) {
color.rgb = sqrt2(color.rgb) * 0.35;
if (fract(playerPos.y + cameraPosition.y) > 0.25) discard;
}
} else if (color.a < 0.99 && dot(color.rgb, color.rgb) < 1.0) { // Campfire Smoke
color.a *= 0.5;
materialMask = 0.0;
} else if (max(abs(colorP.r - colorP.b), abs(colorP.b - colorP.g)) < 0.001) { // Grayscale Particles
float dotColor = dot(color.rgb, color.rgb);
if (dotColor > 0.25 && color.g < 0.5 && (color.b > color.r * 1.1 && color.r > 0.3 || color.r > (color.g + color.b) * 3.0)) {
// Ender Particle, Crying Obsidian Particle, Redstone Particle
emission = clamp(color.r * 8.0, 1.6, 5.0);
color.rgb = pow1_5(color.rgb);
lmCoordM = vec2(0.0);
} else if (color.r > 0.83 && color.g > 0.23 && color.b < 0.4) {
// Lava Particles
emission = 2.0;
color.b *= 0.5;
color.r *= 1.2;
}
}
}
bool noSmoothLighting = false;
#else
bool noSmoothLighting = true;
#endif
#ifdef REDUCE_CLOSE_PARTICLES
if (lViewPos - 1.0 < dither) discard;
#endif
#ifdef GLOWING_COLORED_PARTICLES
if (atlasSize.x < 900.0) {
if (dot(glColor.rgb, vec3(1.0)) < 2.99) {
emission = 5.0;
}
}
#endif
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, dither,
worldGeoNormal, lmCoordM, noSmoothLighting, false, true,
false, 0, 0.0, 1.0, emission);
#if MC_VERSION >= 11500
vec3 nViewPos = normalize(viewPos);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float sky = 0.0;
DoFog(color.rgb, sky, lViewPos, playerPos, VdotU, VdotS, dither);
#endif
vec3 translucentMult = mix(vec3(0.666), color.rgb * (1.0 - pow2(pow2(color.a))), color.a);
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:063 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(0.0, materialMask, 0.0, 1.0);
gl_FragData[2] = vec4(1.0 - translucentMult, 1.0);
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
out vec2 texCoord;
out vec2 lmCoord;
flat out vec3 upVec, sunVec;
out vec3 normal;
flat out vec4 glColor;
#ifdef CLOUD_SHADOWS
flat out vec3 eastVec;
#if SUN_ANGLE != 0
flat out vec3 northVec;
#endif
#endif
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
gl_Position = ftransform();
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
#ifdef FLICKERING_FIX
gl_Position.z -= 0.000002;
#endif
#ifdef CLOUD_SHADOWS
eastVec = normalize(gbufferModelView[0].xyz);
#if SUN_ANGLE != 0
northVec = normalize(gbufferModelView[2].xyz);
#endif
#endif
}
#endif

View File

@ -0,0 +1,373 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in int mat;
in vec2 texCoord;
in vec2 lmCoord;
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
flat in vec3 upVec, sunVec, northVec, eastVec;
in vec3 playerPos;
in vec3 normal;
in vec3 viewVector;
in vec4 glColor;
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2 || defined GENERATED_NORMALS || defined CUSTOM_PBR
flat in vec3 binormal, tangent;
#endif
#ifdef POM
in vec4 vTexCoordAM;
#endif
//Pipeline Constants//
//Common Variables//
float NdotU = dot(normal, upVec);
float NdotUmax0 = max(NdotU, 0.0);
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
float shadowTimeVar1 = abs(sunVisibility - 0.5) * 2.0;
float shadowTimeVar2 = shadowTimeVar1 * shadowTimeVar1;
float shadowTime = shadowTimeVar2 * shadowTimeVar2;
#ifdef OVERWORLD
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#else
vec3 lightVec = sunVec;
#endif
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2 || defined GENERATED_NORMALS || defined CUSTOM_PBR
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
#endif
//Common Functions//
float GetLinearDepth(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
//Includes//
#include "/lib/util/dither.glsl"
#include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/mainLighting.glsl"
#include "/lib/atmospherics/fog/mainFog.glsl"
#ifdef OVERWORLD
#include "/lib/atmospherics/sky.glsl"
#endif
#if WATER_REFLECT_QUALITY >= 0
#if defined SKY_EFFECT_REFLECTION && defined OVERWORLD
#if AURORA_STYLE > 0
#include "/lib/atmospherics/auroraBorealis.glsl"
#endif
#ifdef NIGHT_NEBULA
#include "/lib/atmospherics/nightNebula.glsl"
#else
#include "/lib/atmospherics/stars.glsl"
#endif
#ifdef VL_CLOUDS_ACTIVE
#include "/lib/atmospherics/clouds/mainClouds.glsl"
#endif
#endif
#include "/lib/materials/materialMethods/reflections.glsl"
#endif
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#if defined GENERATED_NORMALS || defined COATED_TEXTURES || WATER_STYLE >= 2
#include "/lib/util/miplevel.glsl"
#endif
#ifdef GENERATED_NORMALS
#include "/lib/materials/materialMethods/generatedNormals.glsl"
#endif
#if IPBR_EMISSIVE_MODE != 1
#include "/lib/materials/materialMethods/customEmission.glsl"
#endif
#ifdef CUSTOM_PBR
#include "/lib/materials/materialHandling/customMaterials.glsl"
#endif
#ifdef ATM_COLOR_MULTS
#include "/lib/colors/colorMultipliers.glsl"
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
#include "/lib/colors/moonPhaseInfluence.glsl"
#endif
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
#ifdef PORTAL_EDGE_EFFECT
#include "/lib/misc/voxelization.glsl"
#endif
#ifdef CONNECTED_GLASS_EFFECT
#include "/lib/materials/materialMethods/connectedGlass.glsl"
#endif
//Program//
void main() {
vec4 colorP = texture2D(tex, texCoord);
vec4 color = colorP * vec4(glColor.rgb, 1.0);
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
#else
vec3 viewPos = ScreenToView(screenPos);
#endif
float lViewPos = length(viewPos);
float dither = Bayer64(gl_FragCoord.xy);
#ifdef TAA
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
#endif
#ifdef LIGHT_COLOR_MULTS
lightColorMult = GetLightColorMult();
#endif
#ifdef ATM_COLOR_MULTS
atmColorMult = GetAtmColorMult();
sqrtAtmColorMult = sqrt(atmColorMult);
#endif
#ifdef VL_CLOUDS_ACTIVE
float cloudLinearDepth = texelFetch(gaux1, texelCoord, 0).r;
if (pow2(cloudLinearDepth + OSIEBCA * dither) * renderDistance < min(lViewPos, renderDistance)) discard;
#endif
#if WATER_MAT_QUALITY >= 3
float materialMask = 0.0;
#endif
vec3 nViewPos = normalize(viewPos);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
float VdotN = dot(nViewPos, normal);
// Materials
vec4 translucentMult = vec4(1.0);
bool noSmoothLighting = false, noDirectionalShading = false, translucentMultCalculated = false, noGeneratedNormals = false;
int subsurfaceMode = 0;
float smoothnessG = 0.0, highlightMult = 1.0, reflectMult = 0.0, emission = 0.0;
vec2 lmCoordM = lmCoord;
vec3 normalM = VdotN > 0.0 ? -normal : normal; // Inverted Iris Water Normal Workaround
vec3 geoNormal = normalM;
vec3 worldGeoNormal = normalize(ViewToPlayer(geoNormal * 10000.0));
vec3 shadowMult = vec3(1.0);
float fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
#ifdef IPBR
#include "/lib/materials/materialHandling/translucentMaterials.glsl"
#ifdef GENERATED_NORMALS
if (!noGeneratedNormals) GenerateNormals(normalM, colorP.rgb * colorP.a * 1.5);
#endif
#if IPBR_EMISSIVE_MODE != 1
emission = GetCustomEmissionForIPBR(color, emission);
#endif
#else
#ifdef CUSTOM_PBR
float smoothnessD, materialMaskPh;
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMaskPh, viewPos, lViewPos);
reflectMult = smoothnessD;
#endif
if (mat == 32000) { // Water
#include "/lib/materials/specificMaterials/translucents/water.glsl"
} else if (mat == 30020) { // Nether Portal
#ifdef SPECIAL_PORTAL_EFFECTS
#include "/lib/materials/specificMaterials/translucents/netherPortal.glsl"
#endif
}
#endif
#if WATER_MAT_QUALITY >= 3 && SELECT_OUTLINE == 4
int materialMaskInt = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
if (materialMaskInt == 252) {
materialMask = OSIEBCA * 252.0; // Versatile Selection Outline
}
#endif
// Blending
if (!translucentMultCalculated)
translucentMult = vec4(mix(vec3(0.666), color.rgb * (1.0 - pow2(pow2(color.a))), color.a), 1.0);
translucentMult.rgb = mix(translucentMult.rgb, vec3(1.0), min1(pow2(pow2(lViewPos / far))));
// Lighting
DoLighting(color, shadowMult, playerPos, viewPos, lViewPos, geoNormal, normalM, dither,
worldGeoNormal, lmCoordM, noSmoothLighting, noDirectionalShading, false,
false, subsurfaceMode, smoothnessG, highlightMult, emission);
// Reflections
#if WATER_REFLECT_QUALITY >= 0
#ifdef LIGHT_COLOR_MULTS
highlightColor *= lightColorMult;
#endif
#ifdef MOON_PHASE_INF_REFLECTION
highlightColor *= pow2(moonPhaseInfluence);
#endif
float fresnelM = (pow3(fresnel) * 0.85 + 0.15) * reflectMult;
float skyLightFactor = pow2(max(lmCoordM.y - 0.7, 0.0) * 3.33333);
#if SHADOW_QUALITY > -1 && WATER_REFLECT_QUALITY >= 2 && WATER_MAT_QUALITY >= 2
skyLightFactor = max(skyLightFactor, min1(dot(shadowMult, shadowMult)));
#endif
vec4 reflection = GetReflection(normalM, viewPos.xyz, nViewPos, playerPos, lViewPos, -1.0,
depthtex1, dither, skyLightFactor, fresnel,
smoothnessG, geoNormal, color.rgb, shadowMult, highlightMult);
color.rgb = mix(color.rgb, reflection.rgb, fresnelM);
#endif
////
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, mat);
#endif
float sky = 0.0;
DoFog(color.rgb, sky, lViewPos, playerPos, VdotU, VdotS, dither);
color.a *= 1.0 - sky;
/* DRAWBUFFERS:03 */
gl_FragData[0] = color;
gl_FragData[1] = vec4(1.0 - translucentMult.rgb, translucentMult.a);
// supposed to be #if WATER_MAT_QUALITY >= 3 but optifine bad
#if DETAIL_QUALITY >= 3
/* DRAWBUFFERS:036 */
gl_FragData[2] = vec4(0.0, materialMask, 0.0, 1.0);
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out int mat;
out vec2 texCoord;
out vec2 lmCoord;
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
flat out vec3 upVec, sunVec, northVec, eastVec;
out vec3 playerPos;
out vec3 normal;
out vec3 viewVector;
out vec4 glColor;
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2 || defined GENERATED_NORMALS || defined CUSTOM_PBR
flat out vec3 binormal, tangent;
#endif
#ifdef POM
out vec4 vTexCoordAM;
#endif
//Attributes//
attribute vec4 mc_Entity;
attribute vec4 mc_midTexCoord;
attribute vec4 at_tangent;
//Common Variables//
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2 || defined GENERATED_NORMALS || defined CUSTOM_PBR
#else
vec3 binormal;
vec3 tangent;
#endif
//Common Functions//
//Includes//
#ifdef TAA
#include "/lib/antialiasing/jitter.glsl"
#endif
#ifdef WAVING_WATER_VERTEX
#include "/lib/materials/materialMethods/wavingBlocks.glsl"
#endif
//Program//
void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
mat = int(mc_Entity.x + 0.5);
normal = normalize(gl_NormalMatrix * gl_Normal);
upVec = normalize(gbufferModelView[1].xyz);
eastVec = normalize(gbufferModelView[0].xyz);
northVec = normalize(gbufferModelView[2].xyz);
sunVec = GetSunVector();
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
#ifdef POM
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
#endif
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
playerPos = position.xyz;
#ifdef WAVING_WATER_VERTEX
DoWave(position.xyz, mat);
#endif
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif
}
#endif

View File

@ -0,0 +1,95 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in vec2 lmCoord;
in vec2 texCoord;
flat in vec3 upVec, sunVec;
flat in vec4 glColor;
//Pipeline Constants//
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunFactor = SdotU < 0.0 ? clamp(SdotU + 0.375, 0.0, 0.75) / 0.75 : clamp(SdotU + 0.03125, 0.0, 0.0625) / 0.0625;
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
float sunVisibility2 = sunVisibility * sunVisibility;
//Common Functions//
//Includes//
#include "/lib/colors/lightAndAmbientColors.glsl"
#ifdef COLOR_CODED_PROGRAMS
#include "/lib/misc/colorCodedPrograms.glsl"
#endif
//Program//
void main() {
vec4 color = texture2D(tex, texCoord);
color *= glColor;
if (color.a < 0.1 || isEyeInWater == 3) discard;
if (color.r + color.g < 1.5) color.a *= rainTexOpacity;
else color.a *= snowTexOpacity;
color.rgb = sqrt3(color.rgb) * (blocklightCol * 2.0 * lmCoord.x + (ambientColor + 0.2 * lightColor) * lmCoord.y * (0.6 + 0.3 * sunFactor));
#ifdef COLOR_CODED_PROGRAMS
ColorCodeProgram(color, -1);
#endif
/* DRAWBUFFERS:0 */
gl_FragData[0] = color;
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out vec2 lmCoord;
out vec2 texCoord;
flat out vec3 upVec, sunVec;
flat out vec4 glColor;
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
glColor = gl_Color;
#ifdef WAVING_RAIN
float rainWavingFactor = eyeBrightnessM2; // Prevents clipping inside interiors
position.xz += rainWavingFactor * (0.4 * position.y + 0.2) * vec2(sin(frameTimeCounter * 0.3) + 0.5, sin(frameTimeCounter * 0.5) * 0.5);
position.xz *= 1.0 - 0.08 * position.y * rainWavingFactor;
#endif
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = GetLightMapCoordinates();
upVec = normalize(gbufferModelView[1].xyz);
sunVec = GetSunVector();
}
#endif

View File

@ -0,0 +1,317 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
flat in int mat;
in vec2 texCoord;
flat in vec3 sunVec, upVec;
in vec4 position;
flat in vec4 glColor;
#ifdef CONNECTED_GLASS_EFFECT
in vec2 signMidCoordPos;
flat in vec2 absMidCoordPos;
#endif
//Pipeline Constants//
//Common Variables//
float SdotU = dot(sunVec, upVec);
float sunVisibility = clamp(SdotU + 0.0625, 0.0, 0.125) / 0.125;
//Common Functions//
void DoNaturalShadowCalculation(inout vec4 color1, inout vec4 color2) {
color1.rgb *= glColor.rgb;
color1.rgb = mix(vec3(1.0), color1.rgb, pow(color1.a, (1.0 - color1.a) * 0.5) * 1.05);
color1.rgb *= 1.0 - pow(color1.a, 64.0);
color1.rgb *= 0.2; // Natural Strength
color2.rgb = normalize(color1.rgb) * 0.5;
}
//Includes//
#ifdef CONNECTED_GLASS_EFFECT
#include "/lib/materials/materialMethods/connectedGlass.glsl"
#endif
//Program//
void main() {
vec4 color1 = texture2DLod(tex, texCoord, 0); // Shadow Color
#if SHADOW_QUALITY >= 1
vec4 color2 = color1; // Light Shaft Color
color2.rgb *= 0.25; // Natural Strength
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
float positionYM = position.y;
#endif
if (mat < 32008) {
if (mat < 32000) {
#ifdef CONNECTED_GLASS_EFFECT
if (mat == 30008) { // Tinted Glass
DoSimpleConnectedGlass(color1);
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
positionYM = 0.0; // 86AHGA: For scene-aware light shafts to be less prone to get extreme under large glass planes
#endif
}
if (mat >= 31000) { // Stained Glass, Stained Glass Pane
DoSimpleConnectedGlass(color1);
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
positionYM = 0.0; // 86AHGA
#endif
}
#endif
DoNaturalShadowCalculation(color1, color2);
} else {
if (mat == 32000) { // Water
vec3 worldPos = position.xyz + cameraPosition;
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
// For scene-aware light shafts to be more prone to get extreme near water
positionYM += 3.5;
#endif
// Water Caustics
#if WATER_CAUSTIC_STYLE < 3
#if MC_VERSION >= 11300
float wcl = GetLuminance(color1.rgb);
color1.rgb = color1.rgb * pow2(wcl) * 1.2;
#else
color1.rgb = mix(color1.rgb, vec3(GetLuminance(color1.rgb)), 0.88);
color1.rgb = pow2(color1.rgb) * vec3(2.5, 3.0, 3.0) * 0.96;
#endif
#else
#define WATER_SPEED_MULT_M WATER_SPEED_MULT * 0.035
vec2 causticWind = vec2(frameTimeCounter * WATER_SPEED_MULT_M, 0.0);
vec2 cPos1 = worldPos.xz * 0.10 - causticWind;
vec2 cPos2 = worldPos.xz * 0.05 + causticWind;
float cMult = 14.0;
float offset = 0.001;
float caustic = 0.0;
caustic += dot(texture2D(gaux4, cPos1 + vec2(offset, 0.0)).rg, vec2(cMult))
- dot(texture2D(gaux4, cPos1 - vec2(offset, 0.0)).rg, vec2(cMult));
caustic += dot(texture2D(gaux4, cPos2 + vec2(0.0, offset)).rg, vec2(cMult))
- dot(texture2D(gaux4, cPos2 - vec2(0.0, offset)).rg, vec2(cMult));
color1.rgb = vec3(max0(min1(caustic * 0.8 + 0.35)) * 0.65 + 0.35);
#if MC_VERSION < 11300
color1.rgb *= vec3(0.3, 0.45, 0.9);
#endif
#endif
#if MC_VERSION >= 11300
#if WATERCOLOR_MODE >= 2
color1.rgb *= glColor.rgb;
#else
color1.rgb *= vec3(0.3, 0.45, 0.9);
#endif
#endif
color1.rgb *= vec3(0.6, 0.8, 1.1);
////
// Underwater Light Shafts
vec3 worldPosM = worldPos;
#if WATER_FOG_MULT > 100
#define WATER_FOG_MULT_M WATER_FOG_MULT * 0.01;
worldPosM *= WATER_FOG_MULT_M;
#endif
vec2 waterWind = vec2(syncedTime * 0.01, 0.0);
float waterNoise = texture2D(noisetex, worldPosM.xz * 0.012 - waterWind).g;
waterNoise += texture2D(noisetex, worldPosM.xz * 0.05 + waterWind).g;
float factor = max(2.5 - 0.025 * length(position.xz), 0.8333) * 1.3;
waterNoise = pow(waterNoise * 0.5, factor) * factor * 1.3;
#if MC_VERSION >= 11300 && WATERCOLOR_MODE >= 2
color2.rgb = normalize(sqrt1(glColor.rgb)) * vec3(0.24, 0.22, 0.26);
#else
color2.rgb = vec3(0.08, 0.12, 0.195);
#endif
color2.rgb *= waterNoise * (1.0 + sunVisibility - rainFactor);
////
#ifdef UNDERWATERCOLOR_CHANGED
color1.rgb *= vec3(UNDERWATERCOLOR_RM, UNDERWATERCOLOR_GM, UNDERWATERCOLOR_BM);
color2.rgb *= vec3(UNDERWATERCOLOR_RM, UNDERWATERCOLOR_GM, UNDERWATERCOLOR_BM);
#endif
} else /*if (mat == 32004)*/ { // Ice
color1.rgb *= color1.rgb;
color1.rgb *= color1.rgb;
color1.rgb = mix(vec3(1.0), color1.rgb, pow(color1.a, (1.0 - color1.a) * 0.5) * 1.05);
color1.rgb *= 1.0 - pow(color1.a, 64.0);
color1.rgb *= 0.28;
color2.rgb = normalize(pow(color1.rgb, vec3(0.25))) * 0.5;
}
}
} else {
if (mat < 32020) { // Glass, Glass Pane, Beacon (32008, 32012, 32016)
#ifdef CONNECTED_GLASS_EFFECT
if (mat == 32008) { // Glass
DoSimpleConnectedGlass(color1);
}
if (mat == 32012) { // Glass Pane
DoSimpleConnectedGlass(color1);
}
#endif
if (color1.a > 0.5) color1 = vec4(0.0, 0.0, 0.0, 1.0);
else color1 = vec4(vec3(0.2 * (1.0 - GLASS_OPACITY)), 1.0);
color2.rgb = vec3(0.3);
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
positionYM = 0.0; // 86AHGA
#endif
} else {
DoNaturalShadowCalculation(color1, color2);
}
}
#endif
gl_FragData[0] = color1; // Shadow Color
#if SHADOW_QUALITY >= 1
#if defined LIGHTSHAFTS_ACTIVE && LIGHTSHAFT_BEHAVIOUR == 1 && defined OVERWORLD
color2.a = 0.25 + max0(positionYM * 0.05); // consistencyMEJHRI7DG
#endif
gl_FragData[1] = color2; // Light Shaft Color
#endif
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
flat out int mat;
out vec2 texCoord;
flat out vec3 sunVec, upVec;
out vec4 position;
flat out vec4 glColor;
#ifdef CONNECTED_GLASS_EFFECT
out vec2 signMidCoordPos;
flat out vec2 absMidCoordPos;
#endif
//Pipeline Constants//
#if COLORED_LIGHTING_INTERNAL > 0
#extension GL_ARB_shader_image_load_store : enable
#endif
//Attributes//
attribute vec4 mc_Entity;
#if defined PERPENDICULAR_TWEAKS || defined WAVING_ANYTHING_TERRAIN || defined WAVING_WATER_VERTEX || defined CONNECTED_GLASS_EFFECT
attribute vec4 mc_midTexCoord;
#endif
#if COLORED_LIGHTING_INTERNAL > 0
attribute vec3 at_midBlock;
#endif
//Common Variables//
vec2 lmCoord;
#if COLORED_LIGHTING_INTERNAL > 0
writeonly uniform uimage3D voxel_img;
#ifdef PUDDLE_VOXELIZATION
writeonly uniform uimage2D puddle_img;
#endif
#endif
//Common Functions//
//Includes//
#include "/lib/util/spaceConversion.glsl"
#if defined WAVING_ANYTHING_TERRAIN || defined WAVING_WATER_VERTEX
#include "/lib/materials/materialMethods/wavingBlocks.glsl"
#endif
#if COLORED_LIGHTING_INTERNAL > 0
#include "/lib/misc/voxelization.glsl"
#ifdef PUDDLE_VOXELIZATION
#include "/lib/misc/puddleVoxelization.glsl"
#endif
#endif
//Program//
void main() {
texCoord = gl_MultiTexCoord0.xy;
lmCoord = GetLightMapCoordinates();
glColor = gl_Color;
sunVec = GetSunVector();
upVec = normalize(gbufferModelView[1].xyz);
mat = int(mc_Entity.x + 0.5);
position = shadowModelViewInverse * shadowProjectionInverse * ftransform();
#if defined WAVING_ANYTHING_TERRAIN || defined WAVING_WATER_VERTEX
DoWave(position.xyz, mat);
#endif
#ifdef CONNECTED_GLASS_EFFECT
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
signMidCoordPos = sign(texMinMidCoord);
absMidCoordPos = abs(texMinMidCoord);
#endif
#ifdef PERPENDICULAR_TWEAKS
if (mat == 10005 || mat == 10017) { // Foliage
#ifndef CONNECTED_GLASS_EFFECT
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texMinMidCoord = texCoord - midCoord;
#endif
if (texMinMidCoord.y < 0.0) {
vec3 normal = gl_NormalMatrix * gl_Normal;
position.xyz += normal * 0.35;
}
}
#endif
if (mat == 32000) { // Water
position.y += 0.015 * max0(length(position.xyz) - 50.0);
}
#if COLORED_LIGHTING_INTERNAL > 0
if (gl_VertexID % 4 == 0) {
UpdateVoxelMap(mat);
#ifdef PUDDLE_VOXELIZATION
UpdatePuddleVoxelMap(mat);
#endif
}
#endif
gl_Position = shadowProjection * shadowModelView * position;
float lVertexPos = sqrt(gl_Position.x * gl_Position.x + gl_Position.y * gl_Position.y);
float distortFactor = lVertexPos * shadowMapBias + (1.0 - shadowMapBias);
gl_Position.xy *= 1.0 / distortFactor;
gl_Position.z = gl_Position.z * 0.2;
}
#endif

View File

@ -0,0 +1,137 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Shadowcomp 1//////////Shadowcomp 1//////////Shadowcomp 1//////////
#ifdef SHADOWCOMP
#define OPTIMIZATION_ACL_HALF_RATE_UPDATES
#define OPTIMIZATION_ACL_BEHIND_PLAYER
layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
#if COLORED_LIGHTING_INTERNAL == 128
const ivec3 workGroups = ivec3(16, 8, 16);
#elif COLORED_LIGHTING_INTERNAL == 192
const ivec3 workGroups = ivec3(24, 12, 24);
#elif COLORED_LIGHTING_INTERNAL == 256
const ivec3 workGroups = ivec3(32, 16, 32);
#elif COLORED_LIGHTING_INTERNAL == 384
const ivec3 workGroups = ivec3(48, 24, 48);
#elif COLORED_LIGHTING_INTERNAL == 512
const ivec3 workGroups = ivec3(64, 32, 64);
#elif COLORED_LIGHTING_INTERNAL == 768
const ivec3 workGroups = ivec3(96, 32, 96);
#elif COLORED_LIGHTING_INTERNAL == 1024
const ivec3 workGroups = ivec3(128, 32, 128);
#endif
//Common Variables//
ivec3[6] face_offsets = ivec3[6](
ivec3( 1, 0, 0),
ivec3( 0, 1, 0),
ivec3( 0, 0, 1),
ivec3(-1, 0, 0),
ivec3( 0, -1, 0),
ivec3( 0, 0, -1)
);
writeonly uniform image3D floodfill_img;
writeonly uniform image3D floodfill_img_copy;
//Common Functions//
vec4 GetLightSample(sampler3D lightSampler, ivec3 pos) {
return texelFetch(lightSampler, pos, 0);
}
vec4 GetLightAverage(sampler3D lightSampler, ivec3 pos, ivec3 voxelVolumeSize) {
vec4 light_old = GetLightSample(lightSampler, pos);
vec4 light_px = GetLightSample(lightSampler, clamp(pos + face_offsets[0], ivec3(0), voxelVolumeSize - 1));
vec4 light_py = GetLightSample(lightSampler, clamp(pos + face_offsets[1], ivec3(0), voxelVolumeSize - 1));
vec4 light_pz = GetLightSample(lightSampler, clamp(pos + face_offsets[2], ivec3(0), voxelVolumeSize - 1));
vec4 light_nx = GetLightSample(lightSampler, clamp(pos + face_offsets[3], ivec3(0), voxelVolumeSize - 1));
vec4 light_ny = GetLightSample(lightSampler, clamp(pos + face_offsets[4], ivec3(0), voxelVolumeSize - 1));
vec4 light_nz = GetLightSample(lightSampler, clamp(pos + face_offsets[5], ivec3(0), voxelVolumeSize - 1));
vec4 light = light_old + light_px + light_py + light_pz + light_nx + light_ny + light_nz;
return light / 7.2; // Slightly higher than 7 to prevent the light from travelling too far
}
//Includes//
#include "/lib/misc/voxelization.glsl"
//Program//
void main() {
ivec3 pos = ivec3(gl_GlobalInvocationID);
vec3 posM = vec3(pos) / vec3(voxelVolumeSize);
vec3 posOffset = floor(previousCameraPosition) - floor(cameraPosition);
ivec3 previousPos = ivec3(vec3(pos) - posOffset);
ivec3 absPosFromCenter = abs(pos - voxelVolumeSize / 2);
if (absPosFromCenter.x + absPosFromCenter.y + absPosFromCenter.z > 16) {
#ifdef OPTIMIZATION_ACL_BEHIND_PLAYER
vec4 viewPos = gbufferProjectionInverse * vec4(0.0, 0.0, 1.0, 1.0);
viewPos /= viewPos.w;
vec3 nPlayerPos = normalize(mat3(gbufferModelViewInverse) * viewPos.xyz);
if (dot(normalize(posM - 0.5), nPlayerPos) < 0.0) {
#ifdef COLORED_LIGHT_FOG
if ((frameCounter & 1) == 0) {
imageStore(floodfill_img_copy, pos, GetLightSample(floodfill_sampler, previousPos));
} else {
imageStore(floodfill_img, pos, GetLightSample(floodfill_sampler_copy, previousPos));
}
#endif
return;
}
#endif
}
vec4 light = vec4(0.0);
uint voxel = texelFetch(voxel_sampler, pos, 0).x;
if ((frameCounter & 1) == 0) {
if (voxel == 1u) {
imageStore(floodfill_img_copy, pos, vec4(0.0));
return;
}
#ifdef OPTIMIZATION_ACL_HALF_RATE_UPDATES
if (posM.x < 0.5) {
imageStore(floodfill_img_copy, pos, GetLightSample(floodfill_sampler, previousPos));
return;
}
#endif
light = GetLightAverage(floodfill_sampler, previousPos, voxelVolumeSize);
} else {
if (voxel == 1u) {
imageStore(floodfill_img, pos, vec4(0.0));
return;
}
#ifdef OPTIMIZATION_ACL_HALF_RATE_UPDATES
if (posM.x > 0.5) {
imageStore(floodfill_img, pos, GetLightSample(floodfill_sampler_copy, previousPos));
return;
}
#endif
light = GetLightAverage(floodfill_sampler_copy, previousPos, voxelVolumeSize);
}
if (voxel == 0u || voxel >= 200u) {
if (voxel >= 200u) {
vec3 tint = specialTintColor[min(voxel - 200u, specialTintColor.length() - 1u)];
light.rgb *= tint;
}
} else {
vec4 color = GetSpecialBlocklightColor(int(voxel));
light = max(light, vec4(pow2(color.rgb), color.a));
}
if ((frameCounter & 1) == 0) {
imageStore(floodfill_img_copy, pos, light);
} else {
imageStore(floodfill_img, pos, light);
}
}
#endif

View File

@ -0,0 +1,42 @@
/////////////////////////////////////
// Complementary Shaders by EminGT //
/////////////////////////////////////
//Common//
#include "/lib/common.glsl"
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
#ifdef FRAGMENT_SHADER
//Pipeline Constants//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
}
#endif
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
#ifdef VERTEX_SHADER
//Attributes//
//Common Variables//
//Common Functions//
//Includes//
//Program//
void main() {
}
#endif