custommods
This commit is contained in:
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldDay;
|
||||
|
||||
uniform float isEyeInCave;
|
||||
uniform float blindFactor;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 skyColor;
|
||||
|
||||
uniform mat4 gbufferProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
#ifdef LIGHT_SHAFTS
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
uniform sampler2D shadowcolor0;
|
||||
#endif
|
||||
|
||||
#ifdef RAINBOW
|
||||
uniform float rainStrength;
|
||||
uniform float wetness;
|
||||
uniform float isDry, isRainy, isSnowy;
|
||||
#endif
|
||||
|
||||
#if ((defined BLACK_OUTLINE || defined PROMO_OUTLINE) && defined OUTLINE_ON_EVERYTHING && defined END && defined ENDER_NEBULA) || defined WATER_REFRACT && !defined NETHER || NETHER_REFRACT > 0 && defined NETHER || defined LIGHT_SHAFTS || defined RAINBOW
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if NIGHT_VISION > 1 || ((defined BLACK_OUTLINE || defined PROMO_OUTLINE) && defined OUTLINE_ON_EVERYTHING)
|
||||
uniform float nightVision;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex0Clear = true;//
|
||||
const bool colortex1Clear = true;//
|
||||
const bool colortex2Clear = false;//
|
||||
const bool colortex3Clear = true;//
|
||||
const bool gaux1Clear = false;
|
||||
const bool gaux2Clear = false;
|
||||
const bool gaux3Clear = false;
|
||||
const bool gaux4Clear = true;//
|
||||
#ifdef COLORED_LIGHT
|
||||
const bool colortex8Clear = true;//
|
||||
const bool colortex9Clear = false;//
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION == 2
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 1
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 0
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * (1.0 - 2.0 * float(timeAngle > 0.5325 && timeAngle < 0.9675));
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
|
||||
#if defined LIGHT_SHAFTS || defined VL_CLOUDS
|
||||
float GetDepth(float depth) {
|
||||
return 2.0 * near * far / (far + near - (2.0 * depth - 1.0) * (far - near));
|
||||
}
|
||||
|
||||
float GetDistX(float dist) {
|
||||
return (far * (dist - near)) / (dist * (far - near));
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/atmospherics/waterFog.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef LIGHT_SHAFTS
|
||||
#ifdef SMOKEY_WATER_LIGHTSHAFTS
|
||||
#include "/lib/lighting/caustics.glsl"
|
||||
#endif
|
||||
#include "/lib/atmospherics/volumetricLight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
#include "/lib/atmospherics/volumetricClouds.glsl"
|
||||
#endif
|
||||
|
||||
#if (defined BLACK_OUTLINE || defined PROMO_OUTLINE) && defined OUTLINE_ON_EVERYTHING
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#endif
|
||||
|
||||
#if defined PROMO_OUTLINE && defined OUTLINE_ON_EVERYTHING
|
||||
#include "/lib/outline/promoOutline.glsl"
|
||||
#endif
|
||||
|
||||
#if defined BLACK_OUTLINE && defined OUTLINE_ON_EVERYTHING
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/outline/blackOutline.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0, texCoord.xy);
|
||||
vec3 translucent = texture2D(colortex1,texCoord.xy).rgb;
|
||||
float z0 = texture2D(depthtex0, texCoord.xy).r;
|
||||
float z1 = texture2D(depthtex1, texCoord.xy).r;
|
||||
bool water = false;
|
||||
|
||||
if (translucent.b > 0.999 && z1 > z0) {
|
||||
water = true;
|
||||
translucent = vec3(1.0);
|
||||
}
|
||||
|
||||
#if defined LIGHT_SHAFTS || defined WATER_REFRACT && !defined NETHER || NETHER_REFRACT > 0 && defined NETHER || defined RAINBOW
|
||||
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord, z0, 1.0) * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
#endif
|
||||
|
||||
#if defined WATER_REFRACT && !defined NETHER || NETHER_REFRACT > 0 && defined NETHER
|
||||
#ifndef NETHER
|
||||
if (water)
|
||||
#endif
|
||||
{
|
||||
vec3 worldPos = ViewToWorld(viewPos.xyz);
|
||||
#ifndef NETHER
|
||||
vec3 worldPosM = worldPos.xyz + cameraPosition.xyz;
|
||||
vec2 refractPos = worldPosM.xz * 0.005 + worldPosM.y * 0.0025 + 0.0035 * WATER_SPEED * frametime;
|
||||
#else
|
||||
vec3 worldPosM = normalize(worldPos) * 0.035;
|
||||
vec2 refractPos = worldPosM.xz + worldPosM.y * 0.5 - 0.001 * WATER_SPEED * frametime;
|
||||
#endif
|
||||
|
||||
vec2 refractNoise = texture2D(noisetex, refractPos).rg - vec2(0.5);
|
||||
|
||||
float hand = 1.0 - float(z0 < 0.56);
|
||||
float d0 = GetLinearDepth(z0);
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
float refractScale = fovScale;
|
||||
#ifndef NETHER
|
||||
float distScale0 = max((far - near) * d0 + near, 6.0);
|
||||
refractScale *= REFRACT_STRENGTH / distScale0;
|
||||
#else
|
||||
#if NETHER_REFRACT == 1
|
||||
refractScale *= 2.0;
|
||||
#elif NETHER_REFRACT == 2
|
||||
refractScale *= 4.0;
|
||||
#else
|
||||
refractScale *= 8.0;
|
||||
#endif
|
||||
refractScale *= clamp(pow2(length(viewPos)) * 0.0001, 0.0, 0.1); //9452873723569
|
||||
#endif
|
||||
refractNoise *= vec2(0.07 * hand * refractScale);
|
||||
vec2 refractCoord = texCoord.xy + refractNoise;
|
||||
|
||||
#ifndef NETHER
|
||||
float waterCheck = float(texture2D(colortex1, refractCoord).b > 0.999);
|
||||
float z0check = texture2D(depthtex0, refractCoord).r;
|
||||
float z1check = texture2D(depthtex1, refractCoord).r;
|
||||
float depthDif = GetLinearDepth(z1check) - GetLinearDepth(z0check);
|
||||
refractNoise *= clamp(depthDif * 150.0, 0.0, 1.0);
|
||||
if (z0check >= 0.56 && waterCheck > 0.95)
|
||||
#else
|
||||
float z0check = texture2D(depthtex0, refractCoord).r;
|
||||
vec4 viewPosCheck = gbufferProjectionInverse * (vec4(texCoord, z0check, 1.0) * 2.0 - 1.0);
|
||||
viewPosCheck /= viewPosCheck.w;
|
||||
refractNoise *= clamp(pow2(length(viewPosCheck)) * 0.0001, 0.0, 0.1); //9452873723569
|
||||
#endif
|
||||
{
|
||||
refractCoord = texCoord.xy + refractNoise;
|
||||
#if MC_VERSION > 10710
|
||||
color.rgb = texture2D(colortex0, refractCoord).rgb;
|
||||
#else
|
||||
//To fix blocky water in Mc 1.7.10 (reason unknown)
|
||||
color.rgb = texture2DLod(colortex0, refractCoord, 0).rgb;
|
||||
#endif
|
||||
#ifndef NETHER
|
||||
if (isEyeInWater == 1) {
|
||||
translucent = texture2D(colortex1, refractCoord).rgb;
|
||||
if (translucent.b > 0.999) translucent = vec3(1.0);
|
||||
z0 = texture2D(depthtex0, refractCoord).r;
|
||||
z1 = texture2D(depthtex1, refractCoord).r;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined LIGHT_SHAFTS || defined RAINBOW
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
#endif
|
||||
|
||||
#if defined BLACK_OUTLINE && defined OUTLINE_ON_EVERYTHING
|
||||
float outlineMask = BlackOutlineMask(depthtex0, depthtex1);
|
||||
float wFogMult = 1.0 + eBS;
|
||||
if (outlineMask > 0.5 || isEyeInWater > 0.5)
|
||||
BlackOutline(color.rgb, depthtex0, wFogMult);
|
||||
#endif
|
||||
|
||||
#if defined PROMO_OUTLINE && defined OUTLINE_ON_EVERYTHING
|
||||
if (z1 - z0 > 0.0) PromoOutline(color.rgb, depthtex0);
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 1 && z0 == 1.0) {
|
||||
color.rgb = 0.8 * pow(underwaterColor.rgb * (1.0 - blindFactor), vec3(2.0));
|
||||
}
|
||||
|
||||
if (isEyeInWater == 2) color.rgb *= vec3(2.0, 0.4, 0.02);
|
||||
|
||||
#if defined LIGHT_SHAFTS || defined VL_CLOUDS || defined RAINBOW
|
||||
#ifdef OVERWORLD
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float cosS = dot(nViewPos, lightVec);
|
||||
#else
|
||||
float cosS = 0.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 vl = vec3(0.0);
|
||||
vec4 clouds = vec4(0.0);
|
||||
#if defined LIGHT_SHAFTS || defined VL_CLOUDS
|
||||
vec3 vlAlbedo = translucent;
|
||||
if (isEyeInWater == 0 && water) vlAlbedo = vec3(0.0);
|
||||
float depth0 = GetDepth(z0);
|
||||
float depth1 = GetDepth(z1);
|
||||
#ifdef LIGHT_SHAFTS
|
||||
vl = GetVolumetricRays(depth0, depth1, vlAlbedo, dither, cosS);
|
||||
#endif
|
||||
#ifdef VL_CLOUDS
|
||||
clouds = GetVolumetricClouds(depth0, depth1, vlAlbedo, dither, viewPos);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RAINBOW
|
||||
#include "/lib/atmospherics/rainbow.glsl"
|
||||
#endif
|
||||
|
||||
#if NIGHT_VISION > 1
|
||||
if (nightVision > 0.0) {
|
||||
float nightVisionGreen = length(color.rgb);
|
||||
nightVisionGreen = smoothstep(0.0, 1.0, nightVisionGreen) * 3.0 + 0.25 * sqrt(nightVisionGreen);
|
||||
float whiteFactor = 0.01;
|
||||
vec3 nightVisionFinal = vec3(nightVisionGreen * whiteFactor, nightVisionGreen, nightVisionGreen * whiteFactor);
|
||||
color.rgb = mix(color.rgb, nightVisionFinal, nightVision);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:01*/
|
||||
gl_FragData[0] = color;
|
||||
gl_FragData[1] = vec4(vl, 1.0);
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
/*DRAWBUFFERS:015*/
|
||||
gl_FragData[2] = clouds;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
|
||||
uniform float blindFactor;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 skyColor;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
uniform sampler2D colortex5;
|
||||
#endif
|
||||
|
||||
#if NIGHT_VISION > 1
|
||||
uniform float nightVision;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessFactor;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
#if !(LIGHT_SHAFT_QUALITY == 3)
|
||||
const bool colortex1MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float sunVisibilityLSM = clamp(dot( sunVec,upVec) + 0.125, 0.0, 0.25) * 4.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
float rainStrengthSp2 = rainStrengthS * rainStrengthS;
|
||||
float lightShaftTime = pow(abs(sunVisibility - 0.5) * 2.0, 10.0);
|
||||
float worldBrightness = max(timeBrightness, moonBrightness);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0,texCoord.xy);
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
float offsetC = 2.0;
|
||||
float lodC = 1.5;
|
||||
vec4 clouds1 = texture2DLod(colortex5, texCoord.xy + vec2( 0.0, offsetC / viewHeight), lodC);
|
||||
vec4 clouds2 = texture2DLod(colortex5, texCoord.xy + vec2( 0.0, -offsetC / viewHeight), lodC);
|
||||
vec4 clouds3 = texture2DLod(colortex5, texCoord.xy + vec2( offsetC / viewWidth, 0.0), lodC);
|
||||
vec4 clouds4 = texture2DLod(colortex5, texCoord.xy + vec2(-offsetC / viewWidth, 0.0), lodC);
|
||||
vec4 clouds = (clouds1 + clouds2 + clouds3 + clouds4) * 0.25;
|
||||
clouds *= clouds;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
vec3 vl = texture2DLod(colortex1, texCoord.xy, 1.5).rgb;
|
||||
vl *= vl;
|
||||
#else
|
||||
#if LIGHT_SHAFT_QUALITY == 1
|
||||
float lod = 1.0;
|
||||
#elif LIGHT_SHAFT_QUALITY == 2
|
||||
float lod = 0.5;
|
||||
#else
|
||||
float lod = 0.0;
|
||||
#endif
|
||||
|
||||
#ifndef MC_GL_RENDERER_GEFORCE
|
||||
if (fract(viewHeight / 2.0) > 0.25 || fract(viewWidth / 2.0) > 0.25)
|
||||
lod = 0.0;
|
||||
#endif
|
||||
|
||||
float offset = 1.0;
|
||||
vec3 vl1 = texture2DLod(colortex1, texCoord.xy + vec2( 0.0, offset / viewHeight), lod).rgb;
|
||||
vec3 vl2 = texture2DLod(colortex1, texCoord.xy + vec2( 0.0, -offset / viewHeight), lod).rgb;
|
||||
vec3 vl3 = texture2DLod(colortex1, texCoord.xy + vec2( offset / viewWidth, 0.0), lod).rgb;
|
||||
vec3 vl4 = texture2DLod(colortex1, texCoord.xy + vec2(-offset / viewWidth, 0.0), lod).rgb;
|
||||
vec3 vlSum = (vl1 + vl2 + vl3 + vl4) * 0.25;
|
||||
vec3 vl = vlSum;
|
||||
|
||||
vl *= vl;
|
||||
#endif
|
||||
#if MC_VERSION >= 11900
|
||||
vl *= 1.0 - darknessFactor;
|
||||
#endif
|
||||
vec3 vlP = vl;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
if (isEyeInWater == 0) {
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
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 NdotU = dot(nViewPos, upVec);
|
||||
NdotU = max(NdotU, 0.0);
|
||||
NdotU = 1.0 - NdotU;
|
||||
if (NdotU > 0.5) NdotU = smoothstep(0.0, 1.0, NdotU);
|
||||
NdotU *= NdotU;
|
||||
NdotU *= NdotU;
|
||||
NdotU = mix(NdotU, 1.0, rainStrengthSp2 * 0.75);
|
||||
vl *= NdotU * NdotU;
|
||||
#else
|
||||
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 NdotU = dot(nViewPos, upVec);
|
||||
NdotU = max(NdotU, 0.0);
|
||||
NdotU = 1.0 - NdotU;
|
||||
if (NdotU > 0.5) NdotU = smoothstep(0.0, 1.0, NdotU);
|
||||
NdotU = mix(NdotU, 1.0, rainStrengthSp2 * 0.75);
|
||||
NdotU = pow(NdotU, 8.0 * smoothstep(0.0, 1.0, pow2(1.0 - worldBrightness)));
|
||||
vl *= max(NdotU, 0.0); // Using max() here fixes a bug that affects auto exposure
|
||||
#endif
|
||||
vlP = vl;
|
||||
|
||||
vec3 lightCol2 = lightCol * lightCol;
|
||||
vec3 dayLightCol = lightCol2 * 0.73;
|
||||
vec3 nightLightCol = lightCol2 * 20.0;
|
||||
vec3 vlColor = mix(nightLightCol, dayLightCol, sunVisibility);
|
||||
//duplicate 98765
|
||||
vec3 weatherSky = weatherCol * weatherCol;
|
||||
weatherSky *= GetLuminance(ambientCol / (weatherSky)) * 1.4;
|
||||
weatherSky *= mix(SKY_RAIN_NIGHT, SKY_RAIN_DAY, sunVisibility);
|
||||
weatherSky = max(weatherSky, skyColor * skyColor * 0.75); // Lightning Sky Color
|
||||
weatherSky *= rainStrengthS;
|
||||
vlColor = mix(vlColor, weatherSky * 10.0, rainStrengthSp2);
|
||||
vl *= vlColor;
|
||||
|
||||
float rainMult = mix(LIGHT_SHAFT_NIGHT_RAIN_MULTIPLIER,
|
||||
LIGHT_SHAFT_DAY_RAIN_MULTIPLIER * (0.65 + 0.2 * vsBrightness),
|
||||
sunVisibility);
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
vl *= mix(1.0, LIGHT_SHAFT_NOON_MULTIPLIER * 0.4, timeBrightness * (1.0 - rainStrengthS * 0.8));
|
||||
vl *= mix(LIGHT_SHAFT_NIGHT_MULTIPLIER * 0.65, 2.0, sunVisibility);
|
||||
vl *= mix(1.0, rainMult, rainStrengthSp2);
|
||||
#else
|
||||
float timeBrightnessSqrt = sqrt1(timeBrightness);
|
||||
|
||||
vl *= mix(1.0, LIGHT_SHAFT_NOON_MULTIPLIER * 0.75, timeBrightnessSqrt * (1.0 - rainStrengthS * 0.8));
|
||||
vl *= mix(LIGHT_SHAFT_NIGHT_MULTIPLIER * (0.91 - moonBrightness * 0.39), 2.0, sunVisibility);
|
||||
vl *= mix(1.0, rainMult, rainStrengthSp2);
|
||||
#endif
|
||||
} else vl *= length(lightCol) * 0.175 * LIGHT_SHAFT_UNDERWATER_MULTIPLIER * (1.0 - rainStrengthS * 0.85);
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
vl *= endCol * 0.1 * LIGHT_SHAFT_THE_END_MULTIPLIER;
|
||||
vl *= LIGHT_SHAFT_STRENGTH * (1.0 - rainStrengthS * eBS * 0.875) * shadowFade * (1.0 + isEyeInWater*1.5) * (1.0 - blindFactor);
|
||||
#else
|
||||
vl *= LIGHT_SHAFT_STRENGTH * shadowFade * (1.0 - blindFactor);
|
||||
|
||||
float vlFactor = (1.0 - min((timeBrightness)*2.0, 0.75));
|
||||
vlFactor = mix(vlFactor, 0.05, rainStrengthS);
|
||||
if (isEyeInWater == 1) vlFactor = 3.0;
|
||||
vl *= vlFactor * 1.15;
|
||||
#endif
|
||||
|
||||
#if NIGHT_VISION > 1
|
||||
if (nightVision > 0.0) {
|
||||
vl = vec3(0.0, length(vl), 0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
color.rgb += vl;
|
||||
#else
|
||||
vec3 addedColor = color.rgb + vl * lightShaftTime;
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
vec3 vlMixBlend = vlP * (1.0 - 0.5 * rainStrengthS);
|
||||
#else
|
||||
vec3 vlMixBlend = vlP * 0.5;
|
||||
vlP *= 0.75;
|
||||
#endif
|
||||
float mixedTime = sunVisibility < 0.5 ?
|
||||
sqrt3(max(moonBrightness - 0.3, 0.0) / 0.7) * lightShaftTime
|
||||
: pow2(pow2((sunVisibilityLSM - 0.5) * 2.0));
|
||||
vec3 mixedColor = mix(color.rgb, vl / max(vlP, 0.01), vlMixBlend * mixedTime);
|
||||
color.rgb = mix(mixedColor, addedColor, sunVisibility * (1.0 - rainStrengthS));
|
||||
#endif
|
||||
|
||||
#ifdef VL_CLOUDS
|
||||
clouds.a *= CLOUD_OPACITY;
|
||||
color.rgb = mix(color.rgb, clouds.rgb, clouds.a);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = color;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform vec3 cameraPosition, previousCameraPosition;
|
||||
|
||||
uniform mat4 gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelView, gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
//Common Functions//
|
||||
vec3 MotionBlur(vec3 color, float z, float dither) {
|
||||
|
||||
float hand = float(z < 0.56);
|
||||
|
||||
if (hand < 0.5) {
|
||||
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_BLUR_STRENGTH * 0.02;
|
||||
|
||||
vec2 coord = texCoord.st - 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;
|
||||
}
|
||||
|
||||
|
||||
//Includes//
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2D(colortex0,texCoord).rgb;
|
||||
|
||||
#ifdef MOTION_BLUR
|
||||
float z = texture2D(depthtex1, texCoord.st).x;
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
|
||||
color = MotionBlur(color, z, dither);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = vec4(color,1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D colortex0;
|
||||
|
||||
#if defined DOF_IS_ON || (defined NETHER_BLUR && defined NETHER)
|
||||
|
||||
uniform int isEyeInWater;
|
||||
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
uniform mat4 gbufferProjection;
|
||||
|
||||
#if DOF == 2 || (defined NETHER_BLUR && defined NETHER)
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform float rainStrengthS;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
#endif
|
||||
|
||||
#if DOF == 1 && !(defined NETHER_BLUR && defined NETHER) && DOF_FOCUS == 0
|
||||
uniform float centerDepthSmooth;
|
||||
#endif
|
||||
|
||||
#if DOF == 1 && !(defined NETHER_BLUR && defined NETHER) && DOF_FOCUS > 0
|
||||
uniform float far, near;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
|
||||
//Common Variables//
|
||||
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 )
|
||||
);
|
||||
|
||||
#if DOF == 2 || (defined NETHER_BLUR && defined NETHER)
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
vec3 GetBlur(vec3 color, float z) {
|
||||
vec3 dof = vec3(0.0);
|
||||
float hand = float(z < 0.56);
|
||||
|
||||
#if DOF == 2 || (defined NETHER && defined NETHER_BLUR)
|
||||
float z0 = texture2D(depthtex0, texCoord.xy).r;
|
||||
vec4 screenPos = vec4(texCoord.x, texCoord.y, z0, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
#endif
|
||||
|
||||
#if defined NETHER && defined NETHER_BLUR
|
||||
// Nether Blur
|
||||
float coc = max(min(length(viewPos) * 0.001, 0.1) * NETHER_BLUR_STRENGTH / 256, 0.0);
|
||||
#elif DOF == 2
|
||||
// Distance Blur
|
||||
float coc = min(length(viewPos) * 0.001, 0.1) * DOF_STRENGTH
|
||||
* (1.0 + max(rainStrengthS * eBS * RAIN_BLUR_MULT, isEyeInWater * UNDERWATER_BLUR_MULT)) / 256;
|
||||
coc = max(coc, 0.0);
|
||||
#else
|
||||
// Depth Of Field
|
||||
#if DOF_FOCUS > 0
|
||||
float centerDepthSmooth = (far * (DOF_FOCUS - near)) / (DOF_FOCUS * (far - near));
|
||||
#endif
|
||||
float coc = max(abs(z - centerDepthSmooth) * 0.125 * DOF_STRENGTH - 0.0001, 0.0);
|
||||
#endif
|
||||
coc = coc / sqrt(coc * coc + 0.1);
|
||||
|
||||
vec2 dofScale = vec2(1.0, aspectRatio);
|
||||
|
||||
#ifdef ANAMORPHIC_BLUR
|
||||
dofScale *= vec2(0.5, 1.5);
|
||||
#endif
|
||||
#ifdef FOV_SCALED_BLUR
|
||||
coc *= gbufferProjection[1][1] / 1.37;
|
||||
#endif
|
||||
#ifdef CHROMATIC_BLUR
|
||||
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
|
||||
|
||||
if (coc * 0.5 > 1.0 / max(viewWidth, viewHeight) && hand < 0.5) {
|
||||
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 CHROMATIC_BLUR
|
||||
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;
|
||||
}
|
||||
else dof = color;
|
||||
return dof;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2DLod(colortex0, texCoord, 0.0).rgb;
|
||||
|
||||
#if defined DOF_IS_ON || (defined NETHER && defined NETHER_BLUR)
|
||||
float z = texture2D(depthtex1, texCoord.st).x;
|
||||
|
||||
color = GetBlur(color, z);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = vec4(color,1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform float rainStrengthS;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
|
||||
//Common Variables//
|
||||
float pw = 1.0 / viewWidth;
|
||||
float ph = 1.0 / viewHeight;
|
||||
|
||||
float weight[7] = float[7](1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0);
|
||||
|
||||
//Common Functions//
|
||||
vec3 BloomTile(float lod, vec2 offset, vec2 rescale) {
|
||||
vec3 bloom = vec3(0.0);
|
||||
float scale = exp2(lod);
|
||||
vec2 coord = (texCoord - 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) * rescale;
|
||||
vec2 bloomCoord = (texCoord - offset + pixelOffset) * scale;
|
||||
bloom += texture2D(colortex0, bloomCoord).rgb * wg;
|
||||
}
|
||||
}
|
||||
bloom /= 4096.0;
|
||||
}
|
||||
|
||||
return pow(bloom / 128.0, vec3(0.25));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#ifndef ANAMORPHIC_BLOOM
|
||||
vec2 rescale = 1.0 / vec2(1920.0, 1080.0);
|
||||
|
||||
#if !defined NETHER
|
||||
vec3 blur = BloomTile(2.0, vec2(0.0 , 0.0 ), rescale);
|
||||
blur += BloomTile(3.0, vec2(0.0 , 0.26 ), rescale);
|
||||
blur += BloomTile(4.0, vec2(0.135 , 0.26 ), rescale);
|
||||
blur += BloomTile(5.0, vec2(0.2075 , 0.26 ), rescale) * 0.8;
|
||||
blur += BloomTile(6.0, vec2(0.135 , 0.3325), rescale) * 0.8;
|
||||
blur += BloomTile(7.0, vec2(0.160625 , 0.3325), rescale) * 0.6;
|
||||
blur += BloomTile(8.0, vec2(0.1784375, 0.3325), rescale) * 0.4;
|
||||
#else
|
||||
vec3 blur = BloomTile(2.0, vec2(0.0 , 0.0 ), rescale);
|
||||
blur += BloomTile(3.0, vec2(0.0 , 0.26 ), rescale);
|
||||
blur += BloomTile(4.0, vec2(0.135 , 0.26 ), rescale);
|
||||
blur += BloomTile(5.0, vec2(0.2075 , 0.26 ), rescale);
|
||||
blur += BloomTile(6.0, vec2(0.135 , 0.3325), rescale);
|
||||
blur += BloomTile(7.0, vec2(0.160625 , 0.3325), rescale);
|
||||
blur += BloomTile(8.0, vec2(0.1784375, 0.3325), rescale) * 0.6;
|
||||
#endif
|
||||
#else
|
||||
vec3 bloom = vec3(0.0);
|
||||
float scale = 4.0;
|
||||
vec2 coord = texCoord * scale;
|
||||
float padding = 0.52;
|
||||
|
||||
if (abs(coord.x - 0.5) < padding && abs(coord.y - 0.5) < padding) {
|
||||
for(int i = -27; i <= 27; i++) {
|
||||
for(int j = -3; j <= 3; j++) {
|
||||
float wg = pow(0.9, abs(2.0 * i) + 1.0);
|
||||
float hg = weight[j + 3];
|
||||
hg *= hg / 400.0;
|
||||
vec2 pixelOffset = vec2(i * pw, j * ph);
|
||||
vec2 bloomCoord = (texCoord + pixelOffset) * scale;
|
||||
bloom += texture2D(colortex0, bloomCoord).rgb * wg * hg;
|
||||
}
|
||||
}
|
||||
bloom /= 128.0;
|
||||
}
|
||||
|
||||
vec3 blur = pow(bloom / 128.0, vec3(0.25));
|
||||
blur = clamp(blur, vec3(0.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:1 */
|
||||
gl_FragData[0] = vec4(blur, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
|
||||
uniform float blindFactor;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
uniform vec3 sunPosition;
|
||||
uniform mat4 gbufferProjection;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
#endif
|
||||
|
||||
#ifdef BLURRY_START
|
||||
uniform float starter;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessFactor;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
#if AUTO_EXPOSURE > 0
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
float pw = 1.0 / viewWidth;
|
||||
float ph = 1.0 / viewHeight;
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
void UnderwaterDistort(inout vec2 texCoord) {
|
||||
vec2 originalTexCoord = texCoord;
|
||||
|
||||
float wind = frameTimeCounter * ANIMATION_SPEED;
|
||||
texCoord +=vec2(cos(texCoord.y * 32.0 + wind * 3.0),
|
||||
sin(texCoord.x * 32.0 + wind * 1.7)) * 0.001 * UNDERWATER_DISTORT;
|
||||
|
||||
float mask = float(texCoord.x > 0.0 && texCoord.x < 1.0 &&
|
||||
texCoord.y > 0.0 && texCoord.y < 1.0);
|
||||
if (mask < 0.5) texCoord = originalTexCoord;
|
||||
}
|
||||
|
||||
vec3 GetBloomTile(float lod, vec2 coord, vec2 offset, vec2 ditherAdd) {
|
||||
float scale = exp2(lod);
|
||||
vec2 bloomCoord = coord / scale + offset;
|
||||
bloomCoord += ditherAdd;
|
||||
bloomCoord = clamp(bloomCoord, offset, 1.0 / scale + offset);
|
||||
|
||||
vec3 bloom = texture2D(colortex1, bloomCoord).rgb;
|
||||
bloom *= bloom;
|
||||
bloom *= bloom;
|
||||
return bloom * 256.0;
|
||||
}
|
||||
|
||||
void Bloom(inout vec3 color, vec2 coord, float dither) {
|
||||
#ifndef ANAMORPHIC_BLOOM
|
||||
#if AA > 1
|
||||
dither = fract(16.0 * frameTimeCounter + dither);
|
||||
#endif
|
||||
|
||||
vec2 rescale = 1.0 / vec2(1920.0, 1080.0);
|
||||
vec2 ditherAdd = vec2(0.0);
|
||||
float ditherM = dither - 0.5;
|
||||
if (rescale.x > pw) ditherAdd.x += ditherM * pw;
|
||||
if (rescale.y > ph) ditherAdd.y += ditherM * ph;
|
||||
|
||||
vec3 blur1 = GetBloomTile(2.0, coord, vec2(0.0 , 0.0 ), ditherAdd);
|
||||
vec3 blur2 = GetBloomTile(3.0, coord, vec2(0.0 , 0.26 ), ditherAdd);
|
||||
vec3 blur3 = GetBloomTile(4.0, coord, vec2(0.135 , 0.26 ), ditherAdd);
|
||||
vec3 blur4 = GetBloomTile(5.0, coord, vec2(0.2075 , 0.26 ), ditherAdd);
|
||||
vec3 blur5 = GetBloomTile(6.0, coord, vec2(0.135 , 0.3325), ditherAdd);
|
||||
vec3 blur6 = GetBloomTile(7.0, coord, vec2(0.160625 , 0.3325), ditherAdd);
|
||||
vec3 blur7 = GetBloomTile(8.0, coord, vec2(0.1784375, 0.3325), ditherAdd);
|
||||
|
||||
vec3 blur = (blur1 + blur2 + blur3 + blur4 + blur5 + blur6 + blur7) * 0.14;
|
||||
#else
|
||||
vec3 blur = texture2D(colortex1, coord / 4.0).rgb;
|
||||
blur = clamp(blur, vec3(0.0), vec3(1.0));
|
||||
blur *= blur;
|
||||
blur *= blur * 128.0;
|
||||
#endif
|
||||
|
||||
#ifndef NETHER
|
||||
float bloomStrength = BLOOM_STRENGTH;
|
||||
if (isEyeInWater == 1) bloomStrength = UNDERWATER_BLOOM_STRENGTH;
|
||||
#else
|
||||
float bloomStrength = NETHER_BLOOM_STRENGTH;
|
||||
#endif
|
||||
|
||||
bloomStrength *= 0.18;
|
||||
|
||||
#ifdef BLURRY_START
|
||||
float animation = min(starter, 0.1) * 10.0;
|
||||
bloomStrength = mix(1.0, bloomStrength, animation);
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
bloomStrength = mix(bloomStrength, 0.26, darknessFactor);
|
||||
#endif
|
||||
|
||||
color = mix(color, blur, bloomStrength);
|
||||
}
|
||||
|
||||
void AutoExposure(inout vec3 color, inout float exposure, float tempExposure) {
|
||||
float exposureLod = log2(viewWidth * 0.3);
|
||||
|
||||
exposure = length(texture2DLod(colortex0, vec2(0.5), exposureLod).rgb);
|
||||
exposure = clamp(exposure, 0.0001, 10.0);
|
||||
|
||||
#if AUTO_EXPOSURE == 1
|
||||
color /= 2.5 * clamp(tempExposure, 0.001, 0.5) + 0.125;
|
||||
#else
|
||||
color /= 3 * tempExposure;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ColorGrading(inout vec3 color) {
|
||||
vec3 cgColor = pow(color.r, CG_RC) * pow(vec3(CG_RR, CG_RG, CG_RB) / 255.0, vec3(2.2)) +
|
||||
pow(color.g, CG_GC) * pow(vec3(CG_GR, CG_GG, CG_GB) / 255.0, vec3(2.2)) +
|
||||
pow(color.b, CG_BC) * pow(vec3(CG_BR, CG_BG, CG_BB) / 255.0, vec3(2.2));
|
||||
vec3 cgMin = pow(vec3(CG_RM, CG_GM, CG_BM) / 255.0, vec3(2.2));
|
||||
color = (cgColor * (1.0 - cgMin) + cgMin) * vec3(CG_RI, CG_GI, CG_BI);
|
||||
|
||||
vec3 cgTint = pow(vec3(CG_TR, CG_TG, CG_TB) / 255.0, vec3(2.2)) * GetLuminance(color) * CG_TI;
|
||||
color = mix(color, cgTint, CG_TM);
|
||||
}
|
||||
|
||||
void BSLTonemap(inout vec3 color) {
|
||||
color = TONEMAP_EXPOSURE * color;
|
||||
#ifdef TWO
|
||||
color *= 2.0 + vsBrightness;
|
||||
#endif
|
||||
color = color / pow(pow(color, vec3(TONEMAP_WHITE_CURVE)) + 1.0, vec3(1.0 / TONEMAP_WHITE_CURVE));
|
||||
color = pow(color, mix(vec3(TONEMAP_LOWER_CURVE), vec3(TONEMAP_UPPER_CURVE), sqrt(color)));
|
||||
}
|
||||
|
||||
void ColorSaturation(inout vec3 color) {
|
||||
float grayVibrance = (color.r + color.g + color.b) / 3.0;
|
||||
float graySaturation = grayVibrance;
|
||||
if (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 - VIBRANCE), sat);
|
||||
color = mix(color, lightness, (1.0 - lightness) * (2.0 - VIBRANCE) / 2.0 * abs(VIBRANCE - 1.0));
|
||||
color = color * SATURATION - graySaturation * (SATURATION - 1.0);
|
||||
}
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
vec2 GetLightPos() {
|
||||
vec4 tpos = gbufferProjection * vec4(sunPosition, 1.0);
|
||||
tpos.xyz /= tpos.w;
|
||||
return tpos.xy / tpos.z * 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
#include "/lib/post/lensFlare.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef BLOOM
|
||||
#include "/lib/util/dither.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec2 newTexCoord = texCoord;
|
||||
if (isEyeInWater == 1) UnderwaterDistort(newTexCoord);
|
||||
|
||||
vec2 filmGrainCoord = texCoord * vec2(viewWidth, viewHeight) / 512.0;
|
||||
vec3 filmGrain = texture2D(noisetex, filmGrainCoord).rgb;
|
||||
vec3 color = texture2D(colortex0, newTexCoord).rgb;
|
||||
|
||||
#if AUTO_EXPOSURE > 0
|
||||
float tempExposure = texture2D(colortex2, vec2(pw, ph)).r;
|
||||
#endif
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
float tempVisibleSun = texture2D(colortex2, vec2(3.0 * pw, ph)).r;
|
||||
#endif
|
||||
|
||||
vec3 temporalColor = vec3(0.0);
|
||||
#if AA > 1
|
||||
temporalColor = texture2D(colortex2, texCoord).gba;
|
||||
#endif
|
||||
|
||||
#ifdef BLOOM
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
Bloom(color, newTexCoord, dither);
|
||||
#endif
|
||||
|
||||
#if AUTO_EXPOSURE > 0
|
||||
float exposure = 1.0;
|
||||
AutoExposure(color, exposure, tempExposure);
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_GRADING
|
||||
ColorGrading(color);
|
||||
#endif
|
||||
|
||||
BSLTonemap(color);
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
vec2 lightPos = GetLightPos();
|
||||
float truePos = sign(sunVec.z);
|
||||
|
||||
float visibleSun = float(texture2D(depthtex1, lightPos + 0.5).r >= 1.0);
|
||||
visibleSun *= max(1.0 - isEyeInWater, eBS) * (1.0 - blindFactor) * (1.0 - rainStrengthS);
|
||||
|
||||
float multiplier = tempVisibleSun * LENS_FLARE_STRENGTH * 0.5 * float(!(moonPhase == 4 && sunVisibility < 0.5));
|
||||
|
||||
if (multiplier > 0.001) LensFlare(color, lightPos, truePos, multiplier);
|
||||
#endif
|
||||
|
||||
float temporalData = 0.0;
|
||||
|
||||
#if AUTO_EXPOSURE > 0
|
||||
if (texCoord.x < 2.0 * pw && texCoord.y < 2.0 * ph)
|
||||
temporalData = mix(tempExposure, sqrt(exposure), 0.016);
|
||||
#endif
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
if (texCoord.x > 2.0 * pw && texCoord.x < 4.0 * pw && texCoord.y < 2.0 * ph)
|
||||
temporalData = mix(tempVisibleSun, visibleSun, 0.1);
|
||||
#endif
|
||||
|
||||
#if VIGNETTE == 1
|
||||
float vignette = 1.0 - length(texCoord.xy - 0.5) * (1.0 - GetLuminance(color));
|
||||
vignette = pow(vignette, VIGNETTE_STRENGTH);
|
||||
color *= vignette;
|
||||
#elif VIGNETTE == 2
|
||||
float vignette = length(texCoord.xy - 0.5);
|
||||
vignette = pow(vignette, 4.0 / VIGNETTE_STRENGTH);
|
||||
color = mix(color, vec3(1.4), vignette);
|
||||
#endif
|
||||
|
||||
color = pow(color, vec3(1.0 / 2.2));
|
||||
|
||||
ColorSaturation(color);
|
||||
|
||||
color += (filmGrain - 0.25) / 128.0;
|
||||
|
||||
/*DRAWBUFFERS:12*/
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
gl_FragData[1] = vec4(temporalData, temporalColor);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float far, near;
|
||||
|
||||
uniform vec3 cameraPosition, previousCameraPosition;
|
||||
|
||||
uniform mat4 gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex1MipmapEnabled = true;
|
||||
|
||||
//Common Functions//
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
//Includes//
|
||||
#if AA > 1
|
||||
#include "/lib/antialiasing/taa.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2DLod(colortex1, texCoord, 0).rgb;
|
||||
|
||||
#if AA > 1
|
||||
vec4 temp = vec4(texture2D(colortex2, texCoord).r, 0.0, 0.0, 0.0);
|
||||
TAA(color, temp);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:1*/
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
#if AA > 1
|
||||
/*DRAWBUFFERS:12*/
|
||||
gl_FragData[1] = vec4(temp);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#if AA == 1 || AA == 3
|
||||
#include "/lib/antialiasing/fxaa.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2D(colortex1, texCoord).rgb;
|
||||
|
||||
#if AA == 1 || AA == 3
|
||||
FXAA311(color);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:1*/
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,138 @@
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
#ifdef AO
|
||||
varying vec2 texCoord;
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
#ifdef AO
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform mat4 gbufferProjection;
|
||||
|
||||
uniform sampler2D depthtex0;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
#ifdef AO
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
|
||||
vec2 OffsetDist(float x, int s) {
|
||||
float n = fract(x * 1.414) * 3.1415;
|
||||
return vec2(cos(n), sin(n)) * x / s;
|
||||
}
|
||||
|
||||
float AmbientOcclusion(sampler2D depth, vec2 coord, float dither) {
|
||||
float ao = 0.0;
|
||||
|
||||
#if AO_QUALITY == 1
|
||||
#if AA > 1
|
||||
int samples = 12;
|
||||
#else
|
||||
int samples = 4;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if AO_QUALITY == 2
|
||||
int samples = 4;
|
||||
#endif
|
||||
|
||||
#if AO_QUALITY == 3
|
||||
int samples = 12;
|
||||
#endif
|
||||
|
||||
#if AO_QUALITY == 1 && AA > 1
|
||||
coord *= 2.0;
|
||||
coord += 0.5 / vec2(viewWidth, viewHeight);
|
||||
|
||||
if (coord.x < 0.0 || coord.x > 1.0 || coord.y < 0.0 || coord.y > 1.0) return 1.0;
|
||||
#endif
|
||||
|
||||
#if AA > 1
|
||||
dither = fract(frameTimeCounter * 4.0 + dither);
|
||||
#endif
|
||||
|
||||
float d = texture2D(depth, coord).r;
|
||||
if(d >= 1.0) return 1.0;
|
||||
float hand = float(d < 0.56);
|
||||
d = GetLinearDepth(d);
|
||||
|
||||
float sampleDepth = 0.0, angle = 0.0, dist = 0.0;
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
float distScale = max((far - near) * d + near, 6.0);
|
||||
vec2 scale = vec2(0.175, 0.35) * vec2(1.0 / aspectRatio, 1.0) * fovScale / distScale;
|
||||
|
||||
for(int i = 1; i <= samples; i++) {
|
||||
vec2 offset = OffsetDist(i + dither, samples) * scale;
|
||||
|
||||
sampleDepth = GetLinearDepth(texture2D(depth, coord + offset).r);
|
||||
float aosample = (far - near) * (d - sampleDepth) * 2.0;
|
||||
if (hand > 0.5) aosample *= 1024.0;
|
||||
angle = clamp(0.5 - aosample, 0.0, 1.0);
|
||||
dist = clamp(0.5 * aosample - 1.0, 0.0, 1.0);
|
||||
|
||||
sampleDepth = GetLinearDepth(texture2D(depth, coord - offset).r);
|
||||
aosample = (far - near) * (d - sampleDepth) * 2.0;
|
||||
if (hand > 0.5) aosample *= 1024.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;
|
||||
|
||||
return ao;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef AO
|
||||
#include "/lib/util/dither.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#ifdef AO
|
||||
float ao = AmbientOcclusion(depthtex0, texCoord, Bayer64(gl_FragCoord.xy));
|
||||
#else
|
||||
float ao = 1.0;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:4 */
|
||||
gl_FragData[0] = vec4(ao, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#ifdef AO
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#ifdef AO
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
#else
|
||||
gl_Position = vec4(0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,640 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
varying vec3 lightAlbedo;
|
||||
varying vec3 lightBuffer;
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldDay;
|
||||
|
||||
uniform float isEyeInCave;
|
||||
uniform float blindFactor, nightVision;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 fogColor;
|
||||
|
||||
uniform mat4 gbufferProjection, gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelView, gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
#ifdef AO
|
||||
uniform sampler2D colortex4;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT || defined GLOWING_ENTITY_FIX || defined AO
|
||||
uniform sampler2D colortex3;
|
||||
#endif
|
||||
|
||||
#if (defined ADV_MAT && defined REFLECTION_SPECULAR) || defined SEVEN || (defined END && defined ENDER_NEBULA) || (defined NETHER && defined NETHER_SMOKE)
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
uniform float isDry, isRainy, isSnowy;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
#endif
|
||||
#ifdef COLORED_LIGHT
|
||||
const bool colortex8MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
vec3 lightVec = sunVec * (1.0 - 2.0 * float(timeAngle > 0.5325 && timeAngle < 0.9675));
|
||||
|
||||
vec2 aoOffsets[4] = vec2[4](
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0, 1.0),
|
||||
vec2(-1.0, 0.0),
|
||||
vec2( 0.0, -1.0)
|
||||
);
|
||||
|
||||
#if WORLD_TIME_ANIMATION == 2
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 1
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 0
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
vec3 lightNight = vec3(0.0);
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
|
||||
#ifdef AO
|
||||
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 linearZ0, float dither) {
|
||||
float ao = 0.0;
|
||||
|
||||
#if AA > 1
|
||||
int samples = 12 * AO_QUALITY;
|
||||
|
||||
float ditherAnimate = 1.61803398875 * mod(float(frameCounter), 3600.0);
|
||||
dither = fract(dither + ditherAnimate);
|
||||
#else
|
||||
int samples = 24 * AO_QUALITY;
|
||||
#endif
|
||||
|
||||
float farMinusNear = far - near;
|
||||
|
||||
float sampleDepth = 0.0, angle = 0.0, dist = 0.0;
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
float distScale = max(farMinusNear * linearZ0 + near, 3.0);
|
||||
vec2 scale = vec2(0.4 / aspectRatio, 0.5) * 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;
|
||||
|
||||
return pow(ao, AO_STRENGTH_NEW);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SELECTION_MODE == 2 && defined ADV_MAT
|
||||
vec3 GetVersatileOutline(vec3 color) {
|
||||
vec3 colorSqrt = sqrt(color.rgb);
|
||||
float perceived = 0.1126 * colorSqrt.r + 0.4152 * colorSqrt.g + 0.2722 * colorSqrt.b;
|
||||
|
||||
color.rgb = color.rgb + max(normalize(color.rgb) * max(perceived * perceived, 0.001), vec3(0.0));
|
||||
color.rgb *= 20.0;
|
||||
|
||||
perceived = max(1.0 - perceived * 1.3, 0.0);
|
||||
perceived *= perceived;
|
||||
perceived *= perceived;
|
||||
perceived = min(perceived, 1.0);
|
||||
float perSteep = 16.0;
|
||||
if (perceived > 0.5) perceived = pow((perceived - 0.5) * 2.0, 1.0 / perSteep) * 0.5 + 0.5;
|
||||
else perceived = pow(perceived * 2.0, perSteep) * 0.5;
|
||||
color.rgb *= max(perceived * 0.5, 0.007);
|
||||
return color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#endif
|
||||
|
||||
#if defined SEVEN || (defined ADV_MAT && defined REFLECTION_SPECULAR && defined OVERWORLD) || (defined END && defined ENDER_NEBULA) || (defined NETHER && defined NETHER_SMOKE)
|
||||
#ifdef AURORA
|
||||
#include "/lib/color/auroraColor.glsl"
|
||||
#endif
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
|
||||
#ifdef BLACK_OUTLINE
|
||||
#include "/lib/outline/blackOutline.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef PROMO_OUTLINE
|
||||
#include "/lib/outline/promoOutline.glsl"
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/raytrace.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/materialDeferred.glsl"
|
||||
#include "/lib/reflections/roughReflections.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0, texCoord);
|
||||
float z = texture2D(depthtex0, texCoord).r;
|
||||
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
|
||||
vec4 screenPos = vec4(texCoord, z, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
vec3 netherSmoke = DrawNetherSmoke(viewPos.xyz, dither, pow((netherCol * 2.5) / NETHER_I, vec3(2.2)) * 4);
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 enderNebula = DrawEnderNebula(viewPos.xyz, dither, endCol, nebulaStars);
|
||||
nebulaStars = pow(nebulaStars, vec3(1.0 / 2.2));
|
||||
nebulaStars *= pow(nebulaStars, vec3(2.2));
|
||||
enderNebula = pow(enderNebula, vec3(1.0 / 2.2));
|
||||
enderNebula *= pow(enderNebula, vec3(2.2));
|
||||
#endif
|
||||
|
||||
if (z < 1.0) {
|
||||
#if defined ADV_MAT || defined GLOWING_ENTITY_FIX || defined AO
|
||||
float skymapMod = texture2D(colortex3, texCoord).b;
|
||||
// skymapMod = 1.0 = Glowing Status Effect
|
||||
// skymapMod = 0.995 = Versatile Selection Outline
|
||||
// skymapMod = 0.515 ... 0.99 = Cauldron
|
||||
// skymapMod = 0.51 = No SSAO
|
||||
// skymapMod = 0.0 ... 0.5 = Rain Puddles
|
||||
// skymapMod = 0.0 ... 0.1 = Specular Sky Reflections
|
||||
#endif
|
||||
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
vec3 worldPos = ViewToWorld(viewPos.xyz);
|
||||
|
||||
#ifdef AO
|
||||
float ao = clamp(DoAmbientOcclusion(GetLinearDepth(z), dither), 0.0, 1.0);
|
||||
float ambientOcclusion = ao;
|
||||
#endif
|
||||
|
||||
#if SELECTION_MODE == 2 && defined ADV_MAT
|
||||
if (skymapMod > 0.9925 && 0.9975 > skymapMod) {
|
||||
color.rgb = GetVersatileOutline(color.rgb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
float smoothness = 0.0, metalness = 0.0, f0 = 0.0;
|
||||
vec3 normal = vec3(0.0), rawAlbedo = vec3(0.0);
|
||||
|
||||
GetMaterials(smoothness, metalness, f0, normal, rawAlbedo, texCoord);
|
||||
|
||||
float smoothnessP = smoothness;
|
||||
smoothness *= smoothness;
|
||||
|
||||
float fresnel = pow(clamp(1.0 + dot(normal, nViewPos), 0.0, 1.0), 5.0);
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
|
||||
rawAlbedo *= 5.0;
|
||||
float fresnelFactor = 0.25;
|
||||
|
||||
#ifdef COMPBR
|
||||
if (f0 > 1.1) {
|
||||
fresnel = fresnel * 0.8 + 0.2;
|
||||
fresnelFactor *= 1.5;
|
||||
}
|
||||
fresnel3 = mix(mix(vec3(0.02), rawAlbedo, metalness), vec3(1.0), fresnel);
|
||||
if (metalness <= 0.004 && metalness > 0.0 && skymapMod == 0.0) fresnel3 = vec3(0.0);
|
||||
fresnel3 *= fresnelFactor * smoothness;
|
||||
#else
|
||||
#if RP_SUPPORT == 4
|
||||
fresnel3 = mix(mix(vec3(0.02), rawAlbedo, metalness), vec3(1.0), fresnel);
|
||||
fresnel3 *= fresnelFactor * smoothness;
|
||||
#endif
|
||||
#if RP_SUPPORT == 3
|
||||
fresnel3 = mix(mix(vec3(max(f0, 0.02)), rawAlbedo, metalness), vec3(1.0), fresnel);
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
fresnel3 = ComplexFresnel(fresnel, f0) * 1.5;
|
||||
color.rgb *= 1.5;
|
||||
}
|
||||
fresnel3 *= fresnelFactor * smoothness;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float lFresnel3 = length(fresnel3);
|
||||
if (lFresnel3 < 0.0050) fresnel3 *= (lFresnel3 - 0.0025) / 0.0025;
|
||||
|
||||
if (lFresnel3 > 0.0025) {
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
|
||||
#ifdef REFLECTION_ROUGH
|
||||
float roughness = 1.0 - smoothnessP;
|
||||
#ifdef COMPBR
|
||||
roughness *= 1.0 - 0.35 * float(metalness == 1.0);
|
||||
#endif
|
||||
roughness *= roughness;
|
||||
|
||||
vec3 roughPos = worldPos + cameraPosition;
|
||||
roughPos *= 1000.0;
|
||||
vec3 roughNoise = texture2D(noisetex, roughPos.xz + roughPos.y).rgb;
|
||||
roughNoise = 0.3 * (roughNoise - vec3(0.5));
|
||||
|
||||
roughNoise *= roughness;
|
||||
|
||||
normal += roughNoise;
|
||||
reflection = RoughReflection(viewPos.xyz, normal, dither, smoothness);
|
||||
|
||||
#ifdef DOUBLE_QUALITY_ROUGH_REF
|
||||
vec3 altRoughNormal = normal - roughNoise*2;
|
||||
reflection += RoughReflection(viewPos.xyz, altRoughNormal, dither, smoothness);
|
||||
reflection /= 2.0;
|
||||
#endif
|
||||
#else
|
||||
reflection = RoughReflection(viewPos.xyz, normal, dither, smoothness);
|
||||
#endif
|
||||
|
||||
float cauldron = float(skymapMod > 0.51 && skymapMod < 0.9905);
|
||||
if (cauldron > 0.5) { //Cauldron Reflections
|
||||
#ifdef OVERWORLD
|
||||
fresnel3 = fresnel3 * 3.33333333 + vec3(0.0333333);
|
||||
|
||||
float skymapModM = (skymapMod - 0.515) / 0.475;
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
skymapModM = skymapModM * skymapModM;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
skymapModM = max(skymapModM - 0.80, 0.0) * 5.0;
|
||||
#else
|
||||
skymapModM = max(skymapModM - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
skymapModM = skymapModM * 0.5;
|
||||
|
||||
vec3 skyReflectionPos = reflect(nViewPos, normal);
|
||||
float refNdotU = dot(skyReflectionPos, upVec);
|
||||
skyReflection = GetSkyColor(lightCol, refNdotU, skyReflectionPos, true);
|
||||
skyReflectionPos *= 1000000.0;
|
||||
|
||||
#ifdef AURORA
|
||||
skyReflection += DrawAurora(skyReflectionPos, dither, 8, refNdotU);
|
||||
#endif
|
||||
#ifdef CLOUDS
|
||||
vec4 cloud = DrawCloud(skyReflectionPos, dither, lightCol, ambientCol, refNdotU, 3);
|
||||
float cloudMixRate = smoothness * smoothness * (3.0 - 2.0 * smoothness);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a * cloudMixRate);
|
||||
#endif
|
||||
skyReflection = mix(vec3(0.001), skyReflection, skymapModM * 2.0);
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol * 0.005;
|
||||
#endif
|
||||
#ifdef END
|
||||
float skymapModM = (skymapMod - 0.515) / 0.475;
|
||||
skyReflection = endCol * 0.025;
|
||||
#ifdef ENDER_NEBULA
|
||||
vec3 skyReflectionPos = reflect(nViewPos, normal);
|
||||
skyReflectionPos *= 1000000.0;
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 nebulaCRef = DrawEnderNebula(skyReflectionPos, dither, endCol, nebulaStars);
|
||||
nebulaCRef += nebulaStars;
|
||||
skyReflection = nebulaCRef;
|
||||
#endif
|
||||
skyReflection *= 5.0 * skymapModM;
|
||||
#endif
|
||||
}
|
||||
if (skymapMod > 0.0 && skymapMod < 0.505) {
|
||||
#ifdef OVERWORLD //Rain Puddle + Specular Sky Reflections
|
||||
float skymapModM = skymapMod * 2.0;
|
||||
|
||||
vec3 skyReflectionPos = reflect(nViewPos, normal);
|
||||
float refNdotU = dot(skyReflectionPos, upVec);
|
||||
skyReflection = GetSkyColor(lightCol, refNdotU, skyReflectionPos, true);
|
||||
skyReflectionPos *= 1000000.0;
|
||||
|
||||
#ifdef CLOUDS
|
||||
vec4 cloud = DrawCloud(skyReflectionPos, dither, lightCol, ambientCol, refNdotU, 3);
|
||||
float cloudMixRate = smoothness * smoothness * (3.0 - 2.0 * smoothness);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a * cloudMixRate);
|
||||
#endif
|
||||
skyReflection = mix(vec3(0.001), skyReflection * 5.0, skymapModM);
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA //End Ground Reflections
|
||||
vec3 skyReflectionPos = reflect(nViewPos, normal);
|
||||
skyReflectionPos *= 1000000.0;
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 nebulaGRef = DrawEnderNebula(skyReflectionPos, dither, endCol, nebulaStars);
|
||||
nebulaGRef += nebulaStars;
|
||||
skyReflection = nebulaGRef;
|
||||
#endif
|
||||
}
|
||||
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
|
||||
|
||||
#ifdef AO
|
||||
if (skymapMod < 0.505) reflection.rgb *= pow(min(ao + max(0.25 - lViewPos * 0.01, 0.0), 1.0), min(lViewPos * 0.75, 10.0));
|
||||
#endif
|
||||
|
||||
color.rgb = color.rgb * (1.0 - fresnel3 * (1.0 - metalness)) +
|
||||
reflection.rgb * fresnel3;
|
||||
|
||||
#ifdef SHOW_RAY_TRACING
|
||||
float timeThing1 = abs(fract(frameTimeCounter * 1.35) - 0.5) * 2.0;
|
||||
float timeThing2 = abs(fract(frameTimeCounter * 1.15) - 0.5) * 2.0;
|
||||
float timeThing3 = abs(fract(frameTimeCounter * 1.55) - 0.5) * 2.0;
|
||||
color.rgb = 3.0 * pow(vec3(timeThing1, timeThing2, timeThing3), vec3(3.2));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLOWING_ENTITY_FIX
|
||||
if (skymapMod > 0.9975) {
|
||||
vec2 glowOutlineOffsets[8] = vec2[8](
|
||||
vec2(-1.0, 0.0),
|
||||
vec2( 0.0, 1.0),
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0,-1.0),
|
||||
vec2(-1.0,-1.0),
|
||||
vec2(-1.0, 1.0),
|
||||
vec2( 1.0,-1.0),
|
||||
vec2( 1.0, 1.0)
|
||||
);
|
||||
|
||||
float outline = 0.0;
|
||||
|
||||
for(int i = 0; i < 64; i++) {
|
||||
vec2 offset = vec2(0.0);
|
||||
offset = glowOutlineOffsets[i-8*int(i/8)] * 0.00025 * (int(i/8)+1);
|
||||
outline += clamp(1.0 - texture2D(colortex3, texCoord + offset).b, 0.0, 1.0);
|
||||
}
|
||||
|
||||
color.rgb += outline * vec3(0.05);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef AO
|
||||
if (skymapMod < 0.505)
|
||||
color.rgb *= ambientOcclusion;
|
||||
#endif
|
||||
|
||||
#ifdef PROMO_OUTLINE
|
||||
PromoOutline(color.rgb, depthtex0);
|
||||
#endif
|
||||
|
||||
vec3 extra = vec3(0.0);
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
extra = netherSmoke;
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
extra = enderNebula;
|
||||
#endif
|
||||
|
||||
color.rgb = startFog(color.rgb, nViewPos, lViewPos, worldPos, extra, NdotU);
|
||||
|
||||
} else { /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/
|
||||
float NdotU = 0.0;
|
||||
|
||||
vec2 skyBlurOffset[4] = vec2[4](vec2( 0.0, 1.0),
|
||||
vec2( 0.0, -1.0),
|
||||
vec2( 1.0, 0.0),
|
||||
vec2(-1.0, 0.0));
|
||||
vec2 wh = vec2(viewWidth, viewHeight);
|
||||
vec3 skyBlurColor = color.rgb;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
vec2 texCoordM = texCoord + skyBlurOffset[i] / wh;
|
||||
float depth = texture2D(depthtex0, texCoordM).r;
|
||||
if (depth == 1.0) skyBlurColor += texture2DLod(colortex0, texCoordM, 0).rgb;
|
||||
else skyBlurColor += color.rgb;
|
||||
}
|
||||
color.rgb = skyBlurColor / 5.0;
|
||||
|
||||
#ifdef NETHER
|
||||
color.rgb = pow((netherCol * 2.5) / NETHER_I, vec3(2.2)) * 4;
|
||||
#ifdef NETHER_SMOKE
|
||||
color.rgb += netherSmoke;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
#ifdef ENDER_NEBULA
|
||||
color.rgb = enderNebula + nebulaStars;
|
||||
color.rgb += endCol * (0.035 + 0.02 * vsBrightness);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TWENTY
|
||||
color.rgb *= 0.1;
|
||||
#endif
|
||||
|
||||
#ifdef SEVEN
|
||||
NdotU = max(dot(normalize(viewPos.xyz), upVec), 0.0);
|
||||
|
||||
vec3 twilightPurple = vec3(0.005, 0.006, 0.018);
|
||||
vec3 twilightGreen = vec3(0.015, 0.03, 0.02);
|
||||
|
||||
#ifdef TWENTY
|
||||
twilightPurple = twilightGreen * 0.1;
|
||||
#endif
|
||||
|
||||
color.rgb = 2 * (twilightPurple * 2 * clamp(pow(NdotU, 0.7), 0.0, 1.0) + twilightGreen * (1-clamp(pow(NdotU, 0.7), 0.0, 1.0)));
|
||||
|
||||
#ifndef TWENTY
|
||||
vec3 stars = DrawStars(color.rgb, viewPos.xyz, NdotU);
|
||||
color.rgb += stars.rgb;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TWO
|
||||
NdotU = 1.0 - max(dot(normalize(viewPos.xyz), upVec), 0.0);
|
||||
NdotU *= NdotU;
|
||||
#ifndef ABYSS
|
||||
vec3 midnightPurple = vec3(0.0003, 0.0004, 0.002) * 1.25;
|
||||
vec3 midnightFogColor = fogColor * fogColor * 0.3;
|
||||
#else
|
||||
vec3 midnightPurple = skyColor * skyColor * 0.00075;
|
||||
vec3 midnightFogColor = fogColor * fogColor * 0.09;
|
||||
#endif
|
||||
color.rgb = mix(midnightPurple, midnightFogColor, NdotU);
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 1) {
|
||||
NdotU = max(dot(normalize(viewPos.xyz), upVec), 0.0);
|
||||
color.rgb = mix(color.rgb, 0.8 * pow(underwaterColor.rgb * (1.0 - blindFactor), vec3(2.0)), 1.0 - NdotU*NdotU);
|
||||
} else if (isEyeInWater == 2) {
|
||||
//duplicate 792763950
|
||||
#ifndef VANILLA_UNDERLAVA_COLOR
|
||||
vec3 lavaFogColor = vec3(0.6, 0.35, 0.15);
|
||||
#else
|
||||
vec3 lavaFogColor = pow(fogColor, vec3(2.2));
|
||||
#endif
|
||||
color.rgb = lavaFogColor;
|
||||
}
|
||||
if (blindFactor > 0.0) color.rgb *= 1.0 - blindFactor;
|
||||
}
|
||||
|
||||
#ifdef BLACK_OUTLINE
|
||||
float wFogMult = 1.0 + eBS;
|
||||
BlackOutline(color.rgb, depthtex0, wFogMult);
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
float sumlightAlbedo = max(lightAlbedo.r + lightAlbedo.g + lightAlbedo.b, 0.0001);
|
||||
vec3 lightAlbedoM = lightAlbedo / sumlightAlbedo;
|
||||
lightAlbedoM *= lightAlbedoM;
|
||||
lightAlbedoM *= BLOCKLIGHT_I * vec3(2.0, 1.8, 2.0);
|
||||
|
||||
float lightSpeed = 0.01;
|
||||
vec3 lightBufferM = mix(lightBuffer, blocklightCol, lightSpeed * 0.25);
|
||||
vec3 finalLight = mix(lightBufferM, lightAlbedoM, lightSpeed * float(sumlightAlbedo > 0.0002));
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:05*/
|
||||
gl_FragData[0] = color;
|
||||
gl_FragData[1] = vec4(pow(color.rgb, vec3(0.125)) * 0.5, 1.0);
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
/*DRAWBUFFERS:059*/
|
||||
gl_FragData[2] = vec4(finalLight, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform float viewHeight;
|
||||
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
lightAlbedo = texture2DLod(colortex8, texCoord, log2(viewHeight)).rgb;
|
||||
lightBuffer = texture2D(colortex9, texCoord).rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
#if THE_FORBIDDEN_OPTION > 0
|
||||
uniform float frameTimeCounter;
|
||||
#endif
|
||||
|
||||
#if defined GRAY_START || (defined WATERMARK && WATERMARK_DURATION < 900)
|
||||
uniform float starter;
|
||||
#endif
|
||||
|
||||
#ifdef WATERMARK
|
||||
uniform sampler2D depthtex2;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
/*
|
||||
const int colortex0Format = R11F_G11F_B10F; //main
|
||||
const int colortex1Format = RGB8; //raw albedo & raw translucent & water mask & vl & bloom
|
||||
const int colortex2Format = RGBA16; //temporal stuff
|
||||
const int colortex3Format = RGB8; //specular & skymapMod
|
||||
const int gaux1Format = R8; //half-res ao
|
||||
const int gaux2Format = RGBA8; //reflection
|
||||
const int gaux3Format = RG16; //normals
|
||||
const int gaux4Format = RGB8; //taa mask & galaxy image
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
const int colortex8Format = RGB16;
|
||||
const int colortex9Format = RGB16;
|
||||
#endif
|
||||
*/
|
||||
|
||||
const bool shadowHardwareFiltering = true;
|
||||
const float shadowDistanceRenderMul = 1.0;
|
||||
|
||||
const float entityShadowDistanceMul = 0.125; // Iris devs may bless us with their power
|
||||
|
||||
const int noiseTextureResolution = 512;
|
||||
|
||||
const float drynessHalflife = 300.0;
|
||||
const float wetnessHalflife = 300.0;
|
||||
|
||||
const float ambientOcclusionLevel = 1.0;
|
||||
|
||||
//Common Functions//
|
||||
#if SHARPEN > 0
|
||||
vec2 sharpenOffsets[4] = vec2[4](
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0, 1.0),
|
||||
vec2(-1.0, 0.0),
|
||||
vec2( 0.0, -1.0)
|
||||
);
|
||||
|
||||
void SharpenFilter(inout vec3 color, vec2 texCoord2) {
|
||||
float mult = SHARPEN * 0.025;
|
||||
vec2 view = 1.0 / vec2(viewWidth, viewHeight);
|
||||
|
||||
color *= SHARPEN * 0.1 + 1.0;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
vec2 offset = sharpenOffsets[i] * view;
|
||||
color -= texture2DLod(colortex1, texCoord2 + offset, 0).rgb * mult;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GRAY_START
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#ifndef OVERDRAW
|
||||
vec2 texCoord2 = texCoord;
|
||||
#else
|
||||
vec2 texCoord2 = (texCoord - vec2(0.5)) * (2.0 / 3.0) + vec2(0.5);
|
||||
#endif
|
||||
|
||||
/*
|
||||
vec2 wh = vec2(viewWidth, viewHeight);
|
||||
wh /= 32.0;
|
||||
texCoord2 = floor(texCoord2 * wh) / wh;
|
||||
*/
|
||||
|
||||
#if CHROMATIC_ABERRATION < 1
|
||||
vec3 color = texture2DLod(colortex1, texCoord2, 0).rgb;
|
||||
#else
|
||||
float midDistX = texCoord2.x - 0.5;
|
||||
float midDistY = texCoord2.y - 0.5;
|
||||
vec2 scale = vec2(1.0, viewHeight / viewWidth);
|
||||
vec2 aberration = vec2(midDistX, midDistY) * (2.0 / vec2(viewWidth, viewHeight)) * scale * CHROMATIC_ABERRATION;
|
||||
vec3 color = vec3(texture2DLod(colortex1, texCoord2 + aberration, 0).r,
|
||||
texture2DLod(colortex1, texCoord2, 0).g,
|
||||
texture2DLod(colortex1, texCoord2 - aberration, 0).b);
|
||||
#endif
|
||||
|
||||
#if SHARPEN > 0
|
||||
SharpenFilter(color, texCoord2);
|
||||
#endif
|
||||
|
||||
#if THE_FORBIDDEN_OPTION > 0
|
||||
#if THE_FORBIDDEN_OPTION < 3
|
||||
float fractTime = fract(frameTimeCounter*0.01);
|
||||
color = pow(vec3(1.0) - color, vec3(5.0));
|
||||
color = vec3(color.r + color.g + color.b)*0.5;
|
||||
color.g = 0.0;
|
||||
if (fractTime < 0.5) color.b *= fractTime, color.r *= 0.5 - fractTime;
|
||||
if (fractTime >= 0.5) color.b *= 1 - fractTime, color.r *= fractTime - 0.5;
|
||||
color = pow(color, vec3(1.8))*8;
|
||||
#else
|
||||
float colorM = dot(color, vec3(0.299, 0.587, 0.114));
|
||||
color = vec3(colorM);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WATERMARK
|
||||
#if WATERMARK_DURATION < 900
|
||||
if (starter < 0.99) {
|
||||
#endif
|
||||
vec2 textCoord = vec2(texCoord.x, 1.0 - texCoord.y);
|
||||
vec4 compText = texture2D(depthtex2, textCoord);
|
||||
//compText.rgb = pow(compText.rgb, vec3(2.2));
|
||||
#if WATERMARK_DURATION < 900
|
||||
float starterFactor = 1.0 - 2.0 * abs(starter - 0.5);
|
||||
starterFactor = max(starterFactor - 0.333333, 0.0) * 3.0;
|
||||
starterFactor = smoothstep(0.0, 1.0, starterFactor);
|
||||
#else
|
||||
float starterFactor = 1.0;
|
||||
#endif
|
||||
color.rgb = mix(color.rgb, compText.rgb, compText.a * starterFactor);
|
||||
#if WATERMARK_DURATION < 900
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GRAY_START
|
||||
float animation = min(starter, 0.1) * 10.0;
|
||||
vec3 grayStart = vec3(GetLuminance(color.rgb));
|
||||
color.rgb = mix(grayStart, color.rgb, animation);
|
||||
#endif
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord.xy) * color;
|
||||
|
||||
#if MC_VERSION >= 11500
|
||||
albedo.rgb = pow(albedo.rgb,vec3(1.6));
|
||||
albedo.rgb *= 0.25;
|
||||
#else
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2));
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(255.0, 85.0, 255.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 1.0;
|
||||
#endif
|
||||
|
||||
albedo.rgb *= GLINT_BRIGHTNESS;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main(){
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
if (gl_ProjectionMatrix[2][2] < -0.5) position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
if (HAND_SWAY > 0.001) {
|
||||
if (gl_ProjectionMatrix[2][2] > -0.5) {
|
||||
gl_Position.x += HAND_SWAY * (sin(frametime * 0.86)) / 256.0;
|
||||
gl_Position.y += HAND_SWAY * (cos(frametime * 1.5)) / 64.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined CLOUD_SHADOW) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
uniform int renderStage;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#if defined WATER_CAUSTICS && defined OVERWORLD
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#if SELECTION_MODE == 1
|
||||
#include "/lib/color/selectionColor.glsl"
|
||||
#endif
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = color;
|
||||
|
||||
float skymapMod = 0.0;
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = 1.0;
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
albedo.a = albedo.a * 0.5 + 0.5;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
if (albedo.a > 0.9) albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = clamp(dot(normal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(normal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU;
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPos, worldPos, lightmap, 1.0, NdotL, quarterNdotU,
|
||||
1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
if (renderStage == 14) {
|
||||
#else
|
||||
if (albedo.rgb == vec3(0.0) && albedo.a > 0.5) {
|
||||
#endif
|
||||
albedo.a = 1.0;
|
||||
#if SELECTION_MODE == 1 // Select Color
|
||||
albedo.rgb = selectionCol;
|
||||
#endif
|
||||
#if SELECTION_MODE == 2 // Versatile
|
||||
albedo.a = 0.1;
|
||||
skymapMod = 0.995;
|
||||
#endif
|
||||
#if SELECTION_MODE == 4 // Rainbow
|
||||
float posFactor = worldPos.x + worldPos.y + worldPos.z + cameraPosition.x + cameraPosition.y + cameraPosition.z;
|
||||
albedo.rgb = clamp(abs(mod(fract(frameTimeCounter*0.25 + posFactor*0.1) * 6.0 + vec3(0.0,4.0,2.0), 6.0) - 3.0)-1.0,
|
||||
0.0, 1.0);
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * SELECTION_I * SELECTION_I * 0.5;
|
||||
#endif
|
||||
#if SELECTION_MODE == 3 // Disabled
|
||||
albedo.a = 0.0;
|
||||
discard;
|
||||
#endif
|
||||
}
|
||||
} else discard;
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(85.0, 255.0, 85.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#if (defined ADV_MAT && defined REFLECTION_SPECULAR) || SELECTION_MODE == 2
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, skymapMod, 1.0);
|
||||
gl_FragData[2] = vec4(0.0, 0.0, float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#if AA > 1
|
||||
uniform int frameCounter;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
uniform int renderStage;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, 0.0, 1.0);
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifndef GBUFFERS_LINE
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
#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
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedoP = texture2D(texture, texCoord);
|
||||
vec4 albedo = albedoP * color;
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(2.0);
|
||||
#endif
|
||||
|
||||
float emissive = 0.0;
|
||||
|
||||
// duplicate 39582069
|
||||
#ifdef COMPBR
|
||||
emissive = length(albedoP.rgb);
|
||||
emissive *= emissive;
|
||||
emissive *= emissive;
|
||||
if (color.a < 0.9) emissive = pow2(emissive * emissive) * 0.01;
|
||||
else emissive = emissive * 0.1;
|
||||
#else
|
||||
emissive = dot(albedoP, albedoP) * 0.1;
|
||||
#endif
|
||||
|
||||
vec3 emissiveLighting = albedo.rgb * emissive * 20.0 * EMISSIVE_MULTIPLIER;
|
||||
albedo.rgb *= emissiveLighting;
|
||||
albedo.a *= albedo.a * albedo.a;
|
||||
|
||||
#if MC_VERSION < 10800
|
||||
albedo.a = max(albedo.a, 0.101);
|
||||
albedo.rgb *= 0.125;
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(0.0, 170.0, 170.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:03 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#if AA == 2 || AA == 3
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
if (gl_ProjectionMatrix[2][2] < -0.5) position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,579 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef END_PORTAL_REWORK
|
||||
varying vec3 eastVec;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11700 && !defined COMPATIBILITY_MODE
|
||||
varying float fullLightmap;
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
varying float dist;
|
||||
varying vec3 viewVector;
|
||||
#endif
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING || defined NOISY_TEXTURES
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vTexCoordAM;
|
||||
#ifdef COMPBR
|
||||
varying vec2 vTexCoordL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
varying vec3 binormal, tangent;
|
||||
#endif
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
uniform mat4 gbufferProjection;
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
varying float noiseVarying;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int blockEntityId;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
#if defined DYNAMIC_SHADER_LIGHT || SHOW_LIGHT_LEVELS == 1 || SHOW_LIGHT_LEVELS == 3
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined CLOUD_SHADOW) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT || defined NOISY_TEXTURES
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && !defined COMPBR
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
uniform ivec2 atlasSize;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && RP_SUPPORT > 2 || defined GENERATED_NORMALS || defined NOISY_TEXTURES
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef END_PORTAL_REWORK
|
||||
#include "/lib/util/dither.glsl"
|
||||
#endif
|
||||
|
||||
#if defined WATER_CAUSTICS && defined OVERWORLD
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
|
||||
#ifndef COMPBR
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
#include "/lib/surface/autoGenNormals.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
#include "/lib/surface/noiseCoatedTextures.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedoP = texture2D(texture, texCoord);
|
||||
vec4 albedo = albedoP * color;
|
||||
|
||||
vec3 newNormal = normal;
|
||||
|
||||
float skymapMod = 0.0;
|
||||
float emissive = 0.0;
|
||||
|
||||
float signBlockEntity = float(blockEntityId == 63);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
float smoothness = 0.0, metalData = 0.0, metalness = 0.0, f0 = 0.0;
|
||||
vec3 rawAlbedo = vec3(0.0);
|
||||
vec4 normalMap = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float skipParallax = signBlockEntity;
|
||||
float parallaxDepth = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipParallax < 0.5) {
|
||||
GetParallaxCoord(parallaxFade, newCoord, parallaxDepth);
|
||||
albedo = textureGrad(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = 1.0;
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
if (albedo.a > 0.99) albedo.a = 1.0;
|
||||
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float subsurface = float(blockEntityId == 983);
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
|
||||
float materialAO = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
#ifndef COMPBR
|
||||
GetMaterials(smoothness, metalness, f0, metalData, emissive, materialAO, normalMap, newCoord, dcdx, dcdy);
|
||||
#else
|
||||
if (blockEntityId == 12001) { // Conduit
|
||||
emissive = float(albedo.b > albedo.r) * pow2(length(albedo.rgb));
|
||||
if (CheckForColor(albedo.rgb, vec3(133, 122, 42))
|
||||
|| CheckForColor(albedo.rgb, vec3(117, 80, 37))
|
||||
|| CheckForColor(albedo.rgb, vec3(101, 36, 31))) { // Center Of The Eye
|
||||
emissive = 2.0;
|
||||
albedo.rgb = vec3(1.0, 0.2, 0.15) + 0.3 * albedo.rgb;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
#ifdef NOISY_TEXTURES
|
||||
float noiseVaryingM = noiseVarying;
|
||||
#endif
|
||||
#include "/lib/other/mipLevel.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
#ifdef GENERATED_NORMALS
|
||||
AutoGenerateNormals(normalMap, albedoP.rgb, delta);
|
||||
#endif
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
if (normalMap.x > -0.999 && normalMap.y > -0.999)
|
||||
newNormal = clamp(normalize(normalMap.xyz * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(newNormal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU * (subsurface > 0.5 ? 1.8 : 1.0);
|
||||
|
||||
#ifdef END_PORTAL_REWORK
|
||||
#include "/lib/other/endPortalEffect.glsl"
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
if (blockEntityId != 200)
|
||||
NoiseCoatTextures(albedo, smoothness, emissive, metalness, worldPos, miplevel, noiseVaryingM, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = clamp(dot(newNormal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
#ifdef COMPBR
|
||||
if (metalness > 0.80) {
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
}
|
||||
#else
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NdotL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NdotL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(parallaxFade, newCoord, lightVec, tbnMatrix, parallaxDepth, normalMap.a);
|
||||
NdotL *= parallaxShadow;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11500 && !defined COMPATIBILITY_MODE
|
||||
if (color.r + color.g + color.b <= 2.99 && signBlockEntity > 0.5) {
|
||||
#if MC_VERSION >= 11700
|
||||
if (fullLightmap < 0.5)
|
||||
#endif
|
||||
albedo.rgb *= 8.0;
|
||||
NdotL = 0.0;
|
||||
}
|
||||
#endif
|
||||
#ifdef COMPBR
|
||||
if (blockEntityId == 10364) { // Enchanting Table Book
|
||||
float ETBEF = albedo.r + albedo.g - albedo.b * 4.0;
|
||||
if (ETBEF > 0.75) {
|
||||
emissive = 0.25;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (blockEntityId == 11032) { // Beacon Beam
|
||||
lightmap = vec2(0.0, 0.0);
|
||||
// duplicate 39582069
|
||||
#ifdef COMPBR
|
||||
emissive = length(albedoP.rgb);
|
||||
emissive *= emissive;
|
||||
emissive *= emissive;
|
||||
if (color.a < 0.9) emissive = pow2(emissive * emissive) * 0.01;
|
||||
else emissive = emissive * 0.1;
|
||||
#else
|
||||
emissive = 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPos, worldPos, lightmap, color.a, NdotL, quarterNdotU,
|
||||
parallaxShadow, emissive, subsurface, 0.0, materialAO);
|
||||
|
||||
//albedo.rgb = vec3(lightmap.y);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightME = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 lightDayTint = lightDay * lightME * LIGHT_DI;
|
||||
vec3 lightDaySpec = mix(lightME, sqrt(lightDayTint), timeBrightness);
|
||||
vec3 specularColor = mix(sqrt(lightNight*0.3),
|
||||
lightDaySpec,
|
||||
sunVisibility);
|
||||
#ifdef WATER_CAUSTICS
|
||||
if (isEyeInWater == 1) specularColor *= underwaterColor.rgb * 8.0;
|
||||
#endif
|
||||
specularColor *= specularColor;
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
float skymapModM = lmCoord.y;
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
skymapModM = skymapModM * skymapModM;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
skymapModM = max(skymapModM - 0.80, 0.0) * 5.0;
|
||||
#else
|
||||
skymapModM = max(skymapModM - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
if (!(metalness <= 0.004 && metalness > 0.0)) skymapMod = max(skymapMod, skymapModM * 0.1);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef END
|
||||
vec3 specularColor = endCol;
|
||||
#endif
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
vec3 specularHighlight = GetSpecularHighlight(smoothness, metalness, f0, specularColor, rawAlbedo,
|
||||
shadow, newNormal, viewPos);
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING && defined SELF_SHADOW
|
||||
specularHighlight *= parallaxShadow;
|
||||
#endif
|
||||
#ifdef LIGHT_LEAK_FIX
|
||||
if (isEyeInWater == 0) specularHighlight *= pow(lightmap.y, 2.5);
|
||||
else specularHighlight *= 0.15 + 0.85 * pow(lightmap.y, 2.5);
|
||||
#endif
|
||||
if (!(blockEntityId == 200)) // No sun/moon reflection on end portals
|
||||
albedo.rgb += specularHighlight;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined COMPBR && defined REFLECTION_SPECULAR
|
||||
smoothness *= 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SHOW_LIGHT_LEVELS > 0
|
||||
#if SHOW_LIGHT_LEVELS == 1
|
||||
if (heldItemId == 13001 || heldItemId2 == 13001)
|
||||
#elif SHOW_LIGHT_LEVELS == 3
|
||||
if (heldBlockLightValue > 7.4 || heldBlockLightValue2 > 7.4)
|
||||
#endif
|
||||
if (dot(normal, upVec) > 0.99) {
|
||||
#include "/lib/other/indicateLightLevels.glsl"
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(170.0, 0.0, 170.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.2;
|
||||
#endif
|
||||
} else discard;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[1] = vec4(smoothness, metalData, skymapMod, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(rawAlbedo, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#if AA > 1
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
#if defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
uniform int blockEntityId;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
#ifdef ADV_MAT
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
#if MC_VERSION >= 11700 && !defined COMPATIBILITY_MODE
|
||||
fullLightmap = 0.0;
|
||||
if (lmCoord.x > 0.96) fullLightmap = 1.0;
|
||||
#endif
|
||||
lmCoord.x -= max(lmCoord.x - 0.825, 0.0) * 0.75;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#ifdef NORMAL_MAPPING
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
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;
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING || defined NOISY_TEXTURES
|
||||
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
|
||||
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
|
||||
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
|
||||
#ifdef COMPBR
|
||||
vTexCoordL = texMinMidCoord * 2;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef END_PORTAL_REWORK
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#if defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
#ifdef NOISY_TEXTURES
|
||||
noiseVarying = 0.65;
|
||||
#endif
|
||||
if (blockEntityId == 12005) { // Chests
|
||||
float worldPosYF = fract((gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex).y + cameraPosition.y);
|
||||
if (worldPosYF > 0.56 && 0.57 > worldPosYF) gl_Position.z -= 0.0001;
|
||||
}
|
||||
else if (blockEntityId == 12009) { // Shulker Boxes, Banners
|
||||
#ifdef NOISY_TEXTURES
|
||||
noiseVarying = 0.35;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
uniform int isEyeInWater;
|
||||
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float far;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if AA > 1
|
||||
uniform int frameCounter;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main(){
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
vec4 albedo = vec4(1.0, 1.0, 1.0, texture2D(texture, texCoord.xy).a);
|
||||
vec3 cloudTex = texture2D(texture, texCoord.xy).rgb;
|
||||
albedo.rgb = pow(albedo.rgb * cloudTex, vec3(2.2));
|
||||
|
||||
float timeBrightnessS = 1.0 - timeBrightness;
|
||||
timeBrightnessS = 1.0 - timeBrightnessS * timeBrightnessS;
|
||||
if (rainStrengthS < 1.0) albedo.rgb *= lightCol * sky_ColorSqrt * (0.5 + 0.15 * timeBrightnessS);
|
||||
float sunVisibility2 = sunVisibility * sunVisibility;
|
||||
if (rainStrengthS > 0.0) {
|
||||
vec3 rainColor = weatherCol*weatherCol * (0.002 + 0.03 * timeBrightnessS + 0.02 * sunVisibility2);
|
||||
albedo.rgb = mix(albedo.rgb, rainColor * cloudTex, rainStrengthS);
|
||||
}
|
||||
if (albedo.a > 0.1) {
|
||||
albedo.a = CLOUD_OPACITY;
|
||||
albedo.a *= albedo.a;
|
||||
}
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
|
||||
#ifdef FOG1
|
||||
float lWorldPos = max(abs(worldPos.x), abs(worldPos.z));
|
||||
float cloudDistance = 375.0;
|
||||
cloudDistance = clamp((cloudDistance - lWorldPos) / cloudDistance, 0.0, 1.0);
|
||||
if (cloudDistance < 0.00001) discard;
|
||||
albedo.a *= min(cloudDistance * 3.0, 1.0);
|
||||
#endif
|
||||
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
float cosS = dot(nViewPos, sunVec);
|
||||
|
||||
float scattering = 0.5 * sunVisibility2 * pow(cosS * 0.5 * (2.0 * sunVisibility - 1.0) + 0.5, 6.0);
|
||||
//scattering *= scattering;
|
||||
albedo.rgb *= 1.0 + scattering * (1.0 - rainStrengthS * 0.8);
|
||||
|
||||
float meFactorP = min((1.0 - min(moonBrightness, 0.6) / 0.6) * 0.115, 0.075);
|
||||
vec3 meColor = vec3(0.0);
|
||||
if (cosS > 0.0) {
|
||||
float meNdotU = 1.0 - abs(NdotU);
|
||||
float meFactor = meFactorP * meNdotU * cosS * meNdotU * 12.0 * (1.0 - rainStrengthS);
|
||||
meColor = mix(lightMorning, lightEvening, mefade);
|
||||
meColor *= meColor;
|
||||
meColor *= meColor;
|
||||
meColor *= meFactor * meFactor;
|
||||
}
|
||||
albedo.rgb += meColor * 0.25;
|
||||
|
||||
float height = worldPos.y + cameraPosition.y;
|
||||
float cloudHeightFactor = 0.0;
|
||||
bool doFancyClouds = false;
|
||||
if (height < 134.0) {
|
||||
cloudHeightFactor = clamp(height - 127.85, 0.0, 5.0) / 5.0;
|
||||
doFancyClouds = true;
|
||||
} else if (height < 199.0 && height > 190.0) {
|
||||
cloudHeightFactor = clamp(height - 191.85, 0.0, 5.0) / 5.0;
|
||||
doFancyClouds = true;
|
||||
}
|
||||
if (doFancyClouds) {
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
float shadowTime = abs(sunVisibility - 0.5) * 2.0;
|
||||
shadowTime *= shadowTime;
|
||||
lightVec *= shadowTime * shadowTime;
|
||||
float NdotL = clamp(dot(normal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
albedo.rgb *= 1.0 + NdotL * 0.5;
|
||||
|
||||
cloudHeightFactor = pow(cloudHeightFactor, 2.0 - NdotL);
|
||||
|
||||
cloudHeightFactor *= 1.0 + 3.0 * sqrt1(moonBrightness) * (1.0 - rainStrengthS);
|
||||
|
||||
float quarterNdotU = dot(normal, upVec);
|
||||
if (quarterNdotU > 0.0) albedo.rgb *= 1.0 - 0.25 * quarterNdotU;
|
||||
else albedo.rgb *= 1.0 + 0.15 * quarterNdotU;
|
||||
|
||||
albedo.rgb *= 0.5 + (0.25 + 0.75 * (1.0 - rainStrengthS) * sunVisibility2) * cloudHeightFactor;
|
||||
} else {
|
||||
float quarterNdotU = clamp(0.25 * dot(normal, upVec) + 0.75, 0.5, 1.0);
|
||||
albedo.rgb *= quarterNdotU;
|
||||
}
|
||||
|
||||
vec3 vlAlbedo = mix(vec3(1.0), albedo.rgb, sqrt1(albedo.a)) * (1.0 - pow(albedo.a, 64.0));
|
||||
#else
|
||||
discard;
|
||||
vec4 albedo = vec4(1.0);
|
||||
vec3 vlAlbedo = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(255.0, 255.0, 255.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 2.0;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:01 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(vlAlbedo, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
#if AA == 2 || AA == 3
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#endif
|
||||
#if AA == 4
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#endif
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
#ifdef OVERWORLD
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
float timeAngleM = 0.25;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main(){
|
||||
#if !defined CLOUDS && defined OVERWORLD
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.xz -= vec2(88.0);
|
||||
float height = position.y + cameraPosition.y;
|
||||
if (height > 193.0) position.y += 2.0;
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
#else
|
||||
gl_Position = vec4(0.0);
|
||||
return;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord.xy);
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 2.25;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(170.0, 170.0, 170.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#if AA == 2 || AA == 3
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,564 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
varying float dist;
|
||||
varying vec3 viewVector;
|
||||
#endif
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
varying vec4 vTexCoordAM;
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
varying vec3 binormal, tangent;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int entityId;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform vec4 entityColor;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined CLOUD_SHADOW) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && !defined COMPBR
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && RP_SUPPORT > 2
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
|
||||
#ifndef COMPBR
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
|
||||
vec3 newNormal = normal;
|
||||
|
||||
float smoothness = 0.0, metalData = 0.0, metalness = 0.0, f0 = 0.0, skymapMod = 0.0;
|
||||
vec3 rawAlbedo = vec3(0.0);
|
||||
vec4 normalMap = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
float itemFrameOrPainting = float(entityId == 18);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
vec2 coordDif = abs(newCoord - texCoord);
|
||||
float skipParallax = itemFrameOrPainting + 100000.0 * (coordDif.x + coordDif.y);
|
||||
float parallaxDepth = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipParallax < 0.5) {
|
||||
GetParallaxCoord(parallaxFade, newCoord, parallaxDepth);
|
||||
albedo = textureGrad(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENTITY_EFFECT
|
||||
float emissive = float(entityColor.a > 0.05) * 0.01;
|
||||
#else
|
||||
float emissive = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef LIGHTNING_BOLTS_FIX
|
||||
if (entityId == 10101) {
|
||||
albedo = vec4(0.8, 0.85, 0.9, 1.0);
|
||||
emissive = 0.25;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = 1.0; //needed for "Joy of Painting" mod support
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
if (albedo.a > 0.99) albedo.a = 1.0;
|
||||
|
||||
vec2 lightmap = lmCoord;
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
float lViewPosToLight = lViewPos;
|
||||
|
||||
float materialAO = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
#ifndef COMPBR
|
||||
GetMaterials(smoothness, metalness, f0, metalData, emissive, materialAO, normalMap, newCoord, dcdx, dcdy);
|
||||
#else
|
||||
if (entityId > 10200.5) {
|
||||
float lAlbedo = length(albedo.rgb);
|
||||
if (entityId < 10213.5) {
|
||||
if (entityId < 10206.5) {
|
||||
if (entityId < 10203.5) {
|
||||
if (entityId == 10201) { // End Crystal
|
||||
lightmap.x *= 0.85;
|
||||
metalness = 1.0;
|
||||
metalData = 1.0;
|
||||
emissive = 10.0 * float(albedo.r * 2.0 > albedo.b + albedo.g);
|
||||
}
|
||||
else if (entityId == 10202) { // Endermite
|
||||
emissive = float(albedo.r > albedo.b);
|
||||
}
|
||||
else if (entityId == 10203 && atlasSize.x < 900.0) { // Witch
|
||||
emissive = 0.35 * albedo.g * albedo.g * float(albedo.g * 1.5 > albedo.b + albedo.r);
|
||||
}
|
||||
} else {
|
||||
if (entityId == 10204) { // Blaze
|
||||
emissive = float(lAlbedo > 1.7);
|
||||
}
|
||||
else if (entityId == 10205) { // Wither, Wither Skull
|
||||
emissive = float(lAlbedo > 1.0);
|
||||
}
|
||||
else if (entityId == 10206) { // Magma Cube
|
||||
emissive = float(lAlbedo > 0.7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entityId < 10209.5) {
|
||||
if (entityId == 10207 && atlasSize.x < 900.0) { // Vex
|
||||
emissive = 0.5 * float(lAlbedo > 1.3);
|
||||
}
|
||||
else if (entityId == 10208) { // Charged Creeper
|
||||
if (albedo.b > albedo.g + 0.01) {
|
||||
albedo.rgb = lAlbedo * vec3(1.0, 1.25, 1.5);
|
||||
emissive = 0.05;
|
||||
lightmap = vec2(0.0);
|
||||
}
|
||||
}
|
||||
else if (entityId == 10209 && atlasSize.x < 900.0) { // Drowned
|
||||
if (
|
||||
CheckForColor(albedo.rgb, vec3(143, 241, 215)) ||
|
||||
CheckForColor(albedo.rgb, vec3( 49, 173, 183)) ||
|
||||
CheckForColor(albedo.rgb, vec3(101, 224, 221))
|
||||
)
|
||||
emissive = 1.0;
|
||||
}
|
||||
} else {
|
||||
if (entityId == 10210 && atlasSize.x < 900.0) { // Stray
|
||||
if (CheckForColor(albedo.rgb, vec3(230, 242, 246)))
|
||||
emissive = float(vTexCoord.y > 0.45);
|
||||
}
|
||||
else if (entityId == 10211) { // Ghast
|
||||
emissive = float(albedo.r > albedo.g + albedo.b + 0.1);
|
||||
}
|
||||
else if (entityId == 10212) { // Fireball, Dragon Fireball
|
||||
emissive = lAlbedo * lAlbedo * 0.25;
|
||||
}
|
||||
else if (entityId == 10213) { // Glow Squid
|
||||
lightmap.x *= 0.0;
|
||||
emissive = lAlbedo * lAlbedo * 0.25;
|
||||
emissive *= emissive;
|
||||
emissive *= emissive;
|
||||
emissive = max(emissive * 5.0, 0.01);
|
||||
|
||||
#ifdef PULSING_GLOW_SQUID
|
||||
if (emissive > 0.011) {
|
||||
float glowFactor = abs(fract(frameTimeCounter * 0.2 + worldPos.y * 0.0125) - 0.5) * 2.0;
|
||||
glowFactor = pow(glowFactor, 2.5);
|
||||
glowFactor = 0.002 + 0.998 * glowFactor;
|
||||
emissive *= glowFactor;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entityId == 10214) { // Allay
|
||||
if (atlasSize.x < 900) {
|
||||
lightmap = vec2(0.0);
|
||||
emissive = float(albedo.r > 0.9) * 0.7 + 0.02;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
if (entityId == 10001) { // Experience Orb
|
||||
emissive = 1.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
if (normalMap.x > -0.999 && normalMap.y > -0.999)
|
||||
newNormal = clamp(normalize(normalMap.xyz * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENTITY_EFFECT
|
||||
if (entityColor.a > 0.001) {
|
||||
albedo.rgb = mix(albedo.rgb, entityColor.rgb, entityColor.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = clamp(dot(newNormal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
if (itemFrameOrPainting > 0.5) {
|
||||
if (atlasSize.x < 5.0) { // Item Frame Map
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(0.875, 1.0));
|
||||
skymapMod = 0.51;
|
||||
lViewPosToLight += DYNAMIC_LIGHT_DISTANCE / 14.0;
|
||||
newNormal = upVec;
|
||||
NdotL = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES_GLOWING
|
||||
lViewPosToLight = 999999.0;
|
||||
#endif
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(newNormal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
#ifdef COMPBR
|
||||
if (metalness > 0.80) {
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
}
|
||||
#else
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NdotL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NdotL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(parallaxFade, newCoord, lightVec, tbnMatrix, parallaxDepth, normalMap.a);
|
||||
NdotL *= parallaxShadow;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPosToLight, worldPos, lightmap, 1.0, NdotL, quarterNdotU,
|
||||
parallaxShadow, emissive, 0.0, 0.0, materialAO);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightME = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 lightDayTint = lightDay * lightME * LIGHT_DI;
|
||||
vec3 lightDaySpec = mix(lightME, sqrt(lightDayTint), timeBrightness);
|
||||
vec3 specularColor = mix(sqrt(lightNight*0.3),
|
||||
lightDaySpec,
|
||||
sunVisibility);
|
||||
#ifdef WATER_CAUSTICS
|
||||
if (isEyeInWater == 1) specularColor *= underwaterColor.rgb * 8.0;
|
||||
#endif
|
||||
specularColor *= specularColor;
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
float skymapModM = lmCoord.y;
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
skymapModM = skymapModM * skymapModM;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
skymapModM = max(skymapModM - 0.80, 0.0) * 5.0;
|
||||
#else
|
||||
skymapModM = max(skymapModM - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
if (!(metalness <= 0.004 && metalness > 0.0)) skymapMod = max(skymapMod, skymapModM * 0.1);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef END
|
||||
vec3 specularColor = endCol;
|
||||
#endif
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
vec3 specularHighlight = GetSpecularHighlight(smoothness, metalness, f0, specularColor, rawAlbedo,
|
||||
shadow, newNormal, viewPos);
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING && defined SELF_SHADOW
|
||||
specularHighlight *= parallaxShadow;
|
||||
#endif
|
||||
#ifdef LIGHT_LEAK_FIX
|
||||
if (isEyeInWater == 0) specularHighlight *= pow(lightmap.y, 2.5);
|
||||
else specularHighlight *= 0.15 + 0.85 * pow(lightmap.y, 2.5);
|
||||
#endif
|
||||
albedo.rgb += specularHighlight;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined COMPBR && defined REFLECTION_SPECULAR
|
||||
smoothness *= 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(255.0, 85.0, 85.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES_GLOWING
|
||||
if (albedo.a > 0.99) skymapMod = 1.0;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:037 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(smoothness, metalData, skymapMod, 1.0);
|
||||
gl_FragData[2] = vec4(1.0);
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:03761 */
|
||||
gl_FragData[3] = vec4(EncodeNormal(newNormal), 0.0, 1.0);
|
||||
gl_FragData[4] = vec4(rawAlbedo, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int entityId;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
//Attributes//
|
||||
#ifdef ADV_MAT
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
lmCoord.x -= max(lmCoord.x - 0.825, 0.0) * 0.75;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined NORMAL_MAPPING
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
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;
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
vTexCoordAM.pq = abs(texMinMidCoord) * 2;
|
||||
vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#ifdef FLICKERING_FIX
|
||||
if (entityId == 18) { // Item Frame, Painting, 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;
|
||||
}
|
||||
}
|
||||
} else if (entityId == 19) { // Frog
|
||||
gl_Position.z -= 0.0001;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES_GLOWING
|
||||
if (color.a > 0.99) gl_Position.z *= 0.01;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,422 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
varying float dist;
|
||||
varying vec3 viewVector;
|
||||
#endif
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vTexCoordAM;
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
varying vec3 binormal, tangent;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int heldItemId, heldItemId2;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined CLOUD_SHADOW) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && !defined COMPBR
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && RP_SUPPORT > 2
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
|
||||
#ifndef COMPBR
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedoP = texture2D(texture, texCoord);
|
||||
vec4 albedo = albedoP * color;
|
||||
|
||||
vec3 newNormal = normal;
|
||||
float skymapMod = 0.0;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
float smoothness = 0.0, metalData = 0.0, metalness = 0.0, f0 = 0.0;
|
||||
vec3 rawAlbedo = vec3(0.0);
|
||||
vec4 normalMap = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
float skipParallax = float(heldItemId == 358 || heldItemId2 == 358);
|
||||
#ifdef COMPATIBILITY_MODE
|
||||
skipParallax += float(heldItemId > 2000 || heldItemId2 > 2000);
|
||||
#endif
|
||||
float parallaxDepth = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipParallax < 0.5) {
|
||||
GetParallaxCoord(0.0, newCoord, parallaxDepth);
|
||||
albedo = textureGrad(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = 1.0; //needed for "Joy of Painting" mod support + more
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
if (albedo.a > 0.99) albedo.a = 1.0;
|
||||
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float emissive = 0.0;
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z + 0.38);
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
|
||||
float materialAO = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
#ifndef COMPBR
|
||||
GetMaterials(smoothness, metalness, f0, metalData, emissive, materialAO, normalMap, newCoord, dcdx, dcdy);
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
if (normalMap.x > -0.999 && normalMap.y > -0.999)
|
||||
newNormal = clamp(normalize(normalMap.xyz * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = clamp(dot(newNormal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(newNormal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
#ifdef COMPBR
|
||||
if (metalness > 0.80) {
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
}
|
||||
#else
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NdotL > 0.0 && skipParallax < 0.5);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NdotL > 0.0 && skipParallax < 0.5);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(0.0, newCoord, lightVec, tbnMatrix, parallaxDepth, normalMap.a);
|
||||
NdotL *= parallaxShadow;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, 0.0, worldPos, lightmap, 1.0, NdotL, quarterNdotU,
|
||||
parallaxShadow, emissive, 0.0, 0.0, materialAO);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightME = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 lightDayTint = lightDay * lightME * LIGHT_DI;
|
||||
vec3 lightDaySpec = mix(lightME, sqrt(lightDayTint), timeBrightness);
|
||||
vec3 specularColor = mix(sqrt(lightNight*0.3),
|
||||
lightDaySpec,
|
||||
sunVisibility);
|
||||
#ifdef WATER_CAUSTICS
|
||||
if (isEyeInWater == 1) specularColor *= underwaterColor.rgb * 8.0;
|
||||
#endif
|
||||
specularColor *= specularColor;
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
float skymapModM = lmCoord.y;
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
skymapModM = skymapModM * skymapModM;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
skymapModM = max(skymapModM - 0.80, 0.0) * 5.0;
|
||||
#else
|
||||
skymapModM = max(skymapModM - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
if (!(metalness <= 0.004 && metalness > 0.0)) skymapMod = max(skymapMod, skymapModM * 0.1);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef END
|
||||
vec3 specularColor = endCol;
|
||||
#endif
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
vec3 specularHighlight = GetSpecularHighlight(smoothness, metalness, f0, specularColor, rawAlbedo,
|
||||
shadow, newNormal, viewPos);
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING && defined SELF_SHADOW
|
||||
specularHighlight *= parallaxShadow;
|
||||
#endif
|
||||
#ifdef LIGHT_LEAK_FIX
|
||||
if (isEyeInWater == 0) specularHighlight *= pow(lightmap.y, 2.5);
|
||||
else specularHighlight *= 0.15 + 0.85 * pow(lightmap.y, 2.5);
|
||||
#endif
|
||||
albedo.rgb += specularHighlight;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined COMPBR && defined REFLECTION_SPECULAR
|
||||
smoothness *= 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(0.0, 170.0, 0.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.2;
|
||||
#endif
|
||||
} else discard;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[1] = vec4(smoothness, metalData, skymapMod, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(rawAlbedo, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
lmCoord.x -= max(lmCoord.x - 0.825, 0.0) * 0.75;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined NORMAL_MAPPING
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
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;
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING
|
||||
vTexCoordAM.pq = abs(texMinMidCoord) * 2;
|
||||
vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord);
|
||||
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
if (gl_ProjectionMatrix[2][2] < -0.5) position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
if (HAND_SWAY > 0.001) {
|
||||
gl_Position.x += HAND_SWAY * (sin(frametime * 0.86)) / 256.0;
|
||||
gl_Position.y += HAND_SWAY * (cos(frametime * 1.5)) / 64.0;
|
||||
}
|
||||
|
||||
#if DOF == 1
|
||||
//gl_Position.x += pow2(1.0 - (gl_Position.x + 1.0) * 0.5);
|
||||
#endif
|
||||
|
||||
#ifdef OVERDRAW
|
||||
gl_Position.xy *= 0.6666666666666;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying float vanillaStars;
|
||||
|
||||
varying vec3 upVec, sunVec;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldDay;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
uniform float isEyeInCave;
|
||||
uniform float blindFactor;
|
||||
uniform float frameCounter;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 moonPosition;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef GALAXIES
|
||||
uniform sampler2D gaux4;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
uniform float isDry, isRainy, isSnowy;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 1
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
vec3 lightVec = sunVec * (1.0 - 2.0 * float(timeAngle > 0.5325 && timeAngle < 0.9675));
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
vec3 RoundSunMoon(vec3 nViewPos, vec3 sunColor, vec3 moonColor, float NdotU, float cosS) {
|
||||
float isMoon = float(cosS < 0.0);
|
||||
float sun = pow(abs(cosS), 2600.0 * isMoon + 1800.0 * (1 - isMoon));
|
||||
|
||||
if (isMoon > 0.0) {
|
||||
if (moonPhase >= 1) {
|
||||
float moonPhaseOffset = float(!(moonPhase == 4));
|
||||
if (moonPhase > 4) moonPhaseOffset *= -1.0;
|
||||
|
||||
float ang = fract(timeAngle - (0.25 + 0.0035 * 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 moonPhaseCosS = dot(nViewPos, normalize(rawSunVec2.xyz));
|
||||
moonPhaseCosS = pow(abs(moonPhaseCosS), 750.0);
|
||||
sun = mix(sun, 0.0, min(moonPhaseCosS * 2.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SUN_MOON_HORIZON
|
||||
float horizonFactor = clamp((NdotU+0.0025)*20, 0.0, 1.0);
|
||||
sun *= horizonFactor;
|
||||
moonColor *= 1.0 - sunVisibility;
|
||||
sunColor *= sunVisibility;
|
||||
#endif
|
||||
|
||||
vec3 sunMoonCol = mix(moonColor, sunColor, float(cosS > 0.0));
|
||||
|
||||
vec3 finalSunMoon = sun * sunMoonCol * 32.0;
|
||||
finalSunMoon = pow(finalSunMoon, vec3(2.0 - min(finalSunMoon.r + finalSunMoon.g + finalSunMoon.b, 1.0)));
|
||||
|
||||
return finalSunMoon;
|
||||
}
|
||||
|
||||
float GetStarNoise(vec2 pos) {
|
||||
return fract(sin(dot(pos, vec2(12.9898, 4.1414))) * 43758.54953);
|
||||
}
|
||||
|
||||
vec3 GetGalaxy(vec3 viewPos, float NdotU, float cosS, vec3 lightNight) {
|
||||
vec3 wpos = vec3(gbufferModelViewInverse * vec4(viewPos * 70.0, 1.0));
|
||||
vec3 planeCoord = wpos / (wpos.y + length(wpos.xz) * 0.5);
|
||||
|
||||
vec3 moonPos = vec3(gbufferModelViewInverse * vec4(- sunVec * 70.0, 1.0));
|
||||
vec3 moonCoord = moonPos / (moonPos.y + length(moonPos.xz));
|
||||
vec2 wind = vec2(frametime, 0.0);
|
||||
vec2 skyCoord = planeCoord.xz - moonCoord.xz;
|
||||
skyCoord *= 0.35;
|
||||
|
||||
#ifdef SHADER_STARS
|
||||
#if STAR_AMOUNT == 1
|
||||
float floorStar = 768.0;
|
||||
vec2 starCoord = floor(skyCoord * floorStar) / floorStar;
|
||||
|
||||
float star = 1.0;
|
||||
if (NdotU > 0.0) {
|
||||
star -= GetStarNoise(starCoord.xy+0.2);
|
||||
star -= GetStarNoise(starCoord.xy+0.3);
|
||||
star = pow(max(star, 0.0), 200.0) * 0.5;
|
||||
}
|
||||
#else
|
||||
float floorStar = 768.0;
|
||||
vec2 starCoord = floor(skyCoord * floorStar) / floorStar;
|
||||
float floorStar1 = 1024.0;
|
||||
vec2 starCoord1 = floor(skyCoord * floorStar1) / floorStar1;
|
||||
|
||||
float star = 1.0;
|
||||
float star1 = 1.0;
|
||||
if (NdotU > 0.0) {
|
||||
star -= GetStarNoise(starCoord.xy+0.2);
|
||||
star -= GetStarNoise(starCoord.xy+0.3);
|
||||
star1 -= GetStarNoise(starCoord1.xy);
|
||||
star1 -= GetStarNoise(starCoord1.xy+0.1);
|
||||
|
||||
float star1m = pow2(max(star1 - 0.925, 0.0));
|
||||
star = pow(max(star, 0.0), 200.0);
|
||||
star = star1m + star * 0.5;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
float star = vanillaStars * 0.05;
|
||||
#endif
|
||||
|
||||
float starDeletionTime = 1.0 - min(timeBrightness * 16.0, 1.0) * 0.15 - sunVisibility * 0.85;
|
||||
float starNdotU = pow2(pow2(clamp(NdotU * 3.0, 0.0, 1.0)));
|
||||
float starFactor = starNdotU * starDeletionTime;
|
||||
star *= starFactor * 32.0 * (1.0 - isEyeInCave) * STAR_BRIGHTNESS;
|
||||
|
||||
vec3 starColor = lightNight * lightNight * 30.0;
|
||||
vec3 starImage = starColor * star;
|
||||
|
||||
vec3 result = starImage;
|
||||
#ifndef SUNSET_STARS
|
||||
result *= 1.0 - sunVisibility;
|
||||
#endif
|
||||
|
||||
#ifdef GALAXIES
|
||||
if (sunVisibility < 1.0) {
|
||||
vec3 galaxy = texture2D(gaux4, skyCoord * 0.9 + 0.4).rgb;
|
||||
float lGalaxy = pow2(length(galaxy) + 0.3);
|
||||
galaxy *= lGalaxy;
|
||||
#ifdef SHADER_STARS
|
||||
#if STAR_AMOUNT == 1
|
||||
float floorStar1 = 1024.0;
|
||||
vec2 starCoord1 = floor(skyCoord * floorStar1) / floorStar1;
|
||||
float star1 = 1.0;
|
||||
if (NdotU > 0.0) {
|
||||
star1 -= GetStarNoise(starCoord1.xy);
|
||||
star1 -= GetStarNoise(starCoord1.xy+0.1);
|
||||
}
|
||||
#endif
|
||||
galaxy += max(star1 - 0.65, 0.0) * starColor * lGalaxy;
|
||||
#endif
|
||||
result += galaxy * galaxy * 0.015 * starNdotU * (1.0 - sunVisibility) * GALAXY_BRIGHTNESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
result *= clamp(1.0 - pow(abs(cosS) * 1.002, 100.0), 0.0, 1.0);
|
||||
|
||||
result *= pow2(pow2(1.0 - max(rainStrength, rainStrengthS)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/color/endColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
#ifdef AURORA
|
||||
#include "/lib/color/auroraColor.glsl"
|
||||
#endif
|
||||
|
||||
#if (defined CLOUDS || defined AURORA) && defined OVERWORLD
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#endif
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/sunGlare.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 albedo = vec3(0.0);
|
||||
|
||||
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 NdotU = dot(nViewPos, upVec);
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#if defined CLOUDS || defined AURORA
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
#endif
|
||||
#ifdef CLOUDS
|
||||
vec4 cloud = DrawCloud(viewPos.xyz * 1000000.0, dither, lightCol, ambientCol, NdotU, 6);
|
||||
float cloudMaskR = cloud.a / CLOUD_OPACITY;
|
||||
if (NdotU > 0.025) cloudMaskR /= pow2(pow2(1.0 - exp(- (10.0 - 8.2 * rainStrengthS) * NdotU))); //duplicate 78634
|
||||
#endif
|
||||
|
||||
albedo = GetSkyColor(lightCol, NdotU, nViewPos, false);
|
||||
|
||||
float cosS = dot(nViewPos, sunVec);
|
||||
|
||||
vec3 galaxy = GetGalaxy(viewPos.xyz, NdotU, cosS, lightNight);
|
||||
#ifdef CLOUDS
|
||||
galaxy *= smoothstep(0.0, 1.0, 1.0 - cloudMaskR);
|
||||
#endif
|
||||
albedo.rgb += galaxy;
|
||||
|
||||
#ifdef ROUND_SUN_MOON
|
||||
vec3 sunColor = vec3(0.9, 0.35, 0.05);
|
||||
if (isEyeInWater == 1) sunColor = 2.0 * normalize(underwaterColor.rgb);
|
||||
vec3 moonColor = vec3(12.0, 13.8, 15.9) / 35.7;
|
||||
|
||||
vec3 roundSunMoon = RoundSunMoon(nViewPos, sunColor, moonColor, NdotU, cosS);
|
||||
|
||||
#ifdef CLOUDS
|
||||
roundSunMoon *= pow2(pow2(pow2(pow2(pow2(1.0 - cloudMaskR * cloudMaskR * rainStrengthS)))));
|
||||
//This should still be faster than pow()
|
||||
|
||||
roundSunMoon *= pow2(1.0 - rainStrengthS);
|
||||
#else
|
||||
roundSunMoon *= 1.0 - max(rainStrength, rainStrengthS);
|
||||
#endif
|
||||
albedo.rgb += roundSunMoon;
|
||||
#endif
|
||||
|
||||
albedo = SunGlare(albedo, nViewPos, lightCol);
|
||||
|
||||
#ifdef AURORA
|
||||
vec3 aurora = DrawAurora(viewPos.xyz * 1000000.0, dither, 20, NdotU);
|
||||
#ifdef CLOUDS
|
||||
aurora *= 1.0 - cloudMaskR;
|
||||
#endif
|
||||
albedo.rgb += aurora;
|
||||
#endif
|
||||
|
||||
#if defined CLOUDS && THE_FORBIDDEN_OPTION == 0
|
||||
albedo.rgb = mix(albedo.rgb, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef SHADER_STARS
|
||||
float alpha = 1.0 - vanillaStars;
|
||||
#else
|
||||
#ifdef SUNSET_STARS
|
||||
float alpha = max(1.0 - vanillaStars * timeBrightness * 10.0, 0.0);
|
||||
#else
|
||||
float alpha = 1.0 - vanillaStars * sunVisibility;
|
||||
#endif
|
||||
float vanillaStarsM = vanillaStars * (1.0 - clamp(NdotU * 3.0, 0.0, 1.0));
|
||||
alpha = max(alpha - vanillaStarsM, 0.0);
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
if (isEyeInWater == 3 && blindFactor == 0) albedo.rgb = vec3(0.1, 0.15, 0.2);
|
||||
#endif
|
||||
|
||||
#if defined CAVE_SKY_FIX && defined OVERWORLD
|
||||
albedo.rgb *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
if (darknessFactor > 0.001) albedo.rgb = mix(albedo.rgb, darknessColor, darknessFactor);
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = vec4(albedo, alpha);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
vec3 rawSunVec = (gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz;
|
||||
sunVec = normalize(rawSunVec);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
vec3 color = gl_Color.rgb;
|
||||
|
||||
//Vanilla Star Dedection by Builderb0y
|
||||
vanillaStars = float(color.r == color.g && color.g == color.b && color.r > 0.0 && color.r < 0.51);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
#if defined END || (defined OVERWORLD && defined VANILLA_SKYBOX)
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
varying vec3 upVec, sunVec;
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float isEyeInCave;
|
||||
uniform float screenBrightness;
|
||||
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 fogColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
uniform int worldDay;
|
||||
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11700 && defined OVERWORLD && defined VANILLA_SKYBOX && defined SUN_MOON_HORIZON
|
||||
uniform int renderStage;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#endif
|
||||
#ifdef END
|
||||
#include "/lib/color/endColor.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
vec4 albedo = texture2D(texture, texCoord.xy);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef SUN_MOON_HORIZON
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
if (renderStage > 3)
|
||||
#endif
|
||||
albedo.a *= clamp((NdotU+0.02)*10, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
albedo *= color;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2 + sunVisibility * 2.2)) * (1.0 + sunVisibility * 4.0) * SKYBOX_BRIGHTNESS * albedo.a;
|
||||
#else
|
||||
vec4 albedo = vec4(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
albedo = vec4(endCol * (0.035 + 0.02 * vsBrightness), 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef TWO
|
||||
albedo = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(255.0, 255.0, 85.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
#if defined CAVE_SKY_FIX && defined OVERWORLD
|
||||
albedo.rgb *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if defined END || (defined OVERWORLD && defined VANILLA_SKYBOX)
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if defined END || (defined OVERWORLD && defined VANILLA_SKYBOX)
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
color = gl_Color;
|
||||
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD && defined VANILLA_SKYBOX
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
#else
|
||||
#if !defined END
|
||||
vec4 color = vec4(0.0);
|
||||
gl_Position = color;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord.xy) * color;
|
||||
|
||||
#ifdef COMPBR
|
||||
if (CheckForColor(albedo.rgb, vec3(224, 121, 250))) { // Enderman Eye Edges
|
||||
albedo.rgb = vec3(0.8, 0.25, 0.8);
|
||||
}
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow1_5(albedo.rgb);
|
||||
albedo.rgb *= pow2(1.0 + albedo.b + 0.5 * albedo.g) * 1.5;
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.35;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(2.0);
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(170.0, 0.0, 0.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
#ifdef WORLD_CURVATURE
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main(){
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
color = gl_Color;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,832 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
varying float mipmapDisabling, quarterNdotUfactor;
|
||||
varying float specB;
|
||||
|
||||
#ifdef COMPBR
|
||||
varying float specR, specG, extraSpecular;
|
||||
#endif
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef OLD_LIGHTING_FIX
|
||||
varying vec3 eastVec, northVec;
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
varying float dist;
|
||||
varying vec3 viewVector;
|
||||
#endif
|
||||
|
||||
varying vec4 vTexCoordAM;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING || defined NOISY_TEXTURES || defined SNOW_MODE
|
||||
varying vec2 vTexCoord;
|
||||
#if defined GENERATED_NORMALS || defined NOISY_TEXTURES
|
||||
varying vec2 vTexCoordL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined NORMAL_MAPPING || defined REFLECTION_RAIN
|
||||
varying vec3 binormal, tangent;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SNOW_MODE
|
||||
varying float noSnow;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
varying float lightVarying;
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
varying float noiseVarying;
|
||||
#endif
|
||||
|
||||
#if defined WORLD_CURVATURE && defined COMPBR
|
||||
varying vec3 oldPosition;
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
#if defined DYNAMIC_SHADER_LIGHT || SHOW_LIGHT_LEVELS == 1 || SHOW_LIGHT_LEVELS == 3
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined SNOW_MODE || defined CLOUD_SHADOW || defined REFLECTION_RAIN) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT || defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#ifndef COMPBR
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
uniform float wetness;
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
uniform int blockEntityId;
|
||||
#endif
|
||||
|
||||
#if defined NORMAL_MAPPING && defined GENERATED_NORMALS
|
||||
uniform mat4 gbufferProjection;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
uniform float isDry, isRainy, isSnowy;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform ivec2 eyeBrightness;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#ifdef COMPBR
|
||||
uniform ivec2 atlasSize;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && RP_SUPPORT > 2 || defined COMPBR
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
|
||||
#ifndef COMPBR
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_LIGHTMAP
|
||||
#include "/lib/surface/directionalLightmap.glsl"
|
||||
#endif
|
||||
|
||||
#if defined REFLECTION_RAIN && defined OVERWORLD
|
||||
#include "/lib/surface/rainPuddles.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
#include "/lib/surface/autoGenNormals.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
#include "/lib/surface/noiseCoatedTextures.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = vec4(0.0);
|
||||
if (mipmapDisabling < 0.25) {
|
||||
#if defined END && defined COMPATIBILITY_MODE && !defined SEVEN
|
||||
albedo.rgb = texture2D(texture, texCoord).rgb;
|
||||
albedo.a = texture2DLod(texture, texCoord, 0).a; // For BetterEnd compatibility
|
||||
#else
|
||||
albedo = texture2D(texture, texCoord);
|
||||
#endif
|
||||
} else {
|
||||
albedo = texture2DLod(texture, texCoord, 0);
|
||||
}
|
||||
vec3 albedoP = albedo.rgb;
|
||||
if (mat < 10000.0) albedo.rgb *= color.rgb;
|
||||
albedo.rgb = clamp(albedo.rgb, vec3(0.0), vec3(1.0));
|
||||
|
||||
float material = floor(mat); // Ah yes this is a floor mat
|
||||
vec3 newNormal = normal;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
#ifdef GREEN_SCREEN
|
||||
float greenScreen = 0.0;
|
||||
#endif
|
||||
#ifdef BLUE_SCREEN
|
||||
float blueScreen = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
float smoothness = 0.0, metalData = 0.0, metalness = 0.0, f0 = 0.0, skymapMod = 0.0;
|
||||
vec3 rawAlbedo = vec3(0.0);
|
||||
vec4 normalMap = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
#ifndef COMPBR
|
||||
vec2 newCoord = vTexCoord.xy * vTexCoordAM.zw + vTexCoordAM.xy;
|
||||
#endif
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float parallaxDepth = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef PARALLAX
|
||||
vec2 coordDif = abs(newCoord - texCoord);
|
||||
float skipParallax = 100000.0 * (coordDif.x + coordDif.y);
|
||||
if (skipParallax < 0.5) {
|
||||
GetParallaxCoord(parallaxFade, newCoord, parallaxDepth);
|
||||
if (mipmapDisabling < 0.25) albedo = textureGrad(texture, newCoord, dcdx, dcdy) * vec4(color.rgb, 1.0);
|
||||
else albedo = texture2DLod(texture, newCoord, 0) * vec4(color.rgb, 1.0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = albedo.a; // For BetterEndForge compatibility
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
float foliage = float(material == 1.0);
|
||||
float leaves = float(material == 2.0);
|
||||
|
||||
//Emission
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
float emissive = specB * 4.0;
|
||||
|
||||
//Subsurface Scattering
|
||||
#if SHADOW_SUBSURFACE == 0
|
||||
float subsurface = 0.0;
|
||||
#else
|
||||
float subsurface = foliage * SCATTERING_FOLIAGE + leaves * SCATTERING_LEAVES;
|
||||
#endif
|
||||
#ifndef SHADOWS
|
||||
if (leaves > 0.5) subsurface *= 0.5;
|
||||
else subsurface = pow2(subsurface * subsurface);
|
||||
#endif
|
||||
|
||||
#ifdef COMPBR
|
||||
float lAlbedoP = length(albedoP);
|
||||
float extraSpecularM = extraSpecular;
|
||||
|
||||
if (mat > 10000.0) { // More control over lAlbedoP at the cost of color.rgb
|
||||
if (mat < 19000.0) {
|
||||
if (mat < 16000) { // 15000 - Difference Based lAlbedoP
|
||||
vec3 averageAlbedo = texture2DLod(texture, texCoord, 100.0).rgb;
|
||||
lAlbedoP = sqrt2(length(albedoP.rgb - averageAlbedo) + color.r) * color.g * 20.0;
|
||||
#ifdef GREEN_SCREEN
|
||||
if (albedo.g * 1.4 > albedo.r + albedo.b && albedo.g > 0.6 && albedo.r * 2.0 > albedo.b)
|
||||
greenScreen = 1.0;
|
||||
#endif
|
||||
#ifdef BLUE_SCREEN
|
||||
if (albedo.b * 1.4 > albedo.r + albedo.g && albedo.b > 0.2 && abs(albedo.g - albedo.r) < 0.1)
|
||||
blueScreen = 1.0;
|
||||
#endif
|
||||
} else { // 17000 - Limited lAlbedoP
|
||||
lAlbedoP = min(lAlbedoP, color.r) * color.g;
|
||||
if (color.b < 2.0) albedo.b *= color.b;
|
||||
else albedo.g *= color.b - 2.0;
|
||||
}
|
||||
} else {
|
||||
if (mat < 25000.0) { // 20000 - Channel Controlled lAlbedoP
|
||||
lAlbedoP = length(albedoP * max(color.rgb, vec3(0.0)));
|
||||
if (color.g < -0.0001) lAlbedoP = max(lAlbedoP + color.g * albedo.g * 0.1, 0.0);
|
||||
} else { // 30000 - Inverted lAlbedoP
|
||||
lAlbedoP = max(1.73 - lAlbedoP, 0.0) * color.r + color.g;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Integrated Emission
|
||||
if (specB > 1.02) {
|
||||
emissive = pow(lAlbedoP, specB) * fract(specB) * 20.0;
|
||||
}
|
||||
|
||||
//Integrated Smoothness
|
||||
smoothness = specR;
|
||||
if (specR > 1.02) {
|
||||
float lAlbedoPsp = lAlbedoP;
|
||||
float spec = specR;
|
||||
if (spec > 1000.0) lAlbedoPsp = 2.0 - lAlbedoP, spec -= 1000.0;
|
||||
smoothness = pow(lAlbedoPsp, spec * 0.1) * fract(specR) * 5.0;
|
||||
smoothness = min(smoothness, 1.0);
|
||||
}
|
||||
|
||||
//Integrated Metalness+
|
||||
metalness = specG;
|
||||
if (specG > 10.0) {
|
||||
metalness = 3.0 - lAlbedoP * specG * 0.01;
|
||||
metalness = min(metalness, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Main
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
|
||||
float materialAO = 1.0;
|
||||
float cauldron = 0.0;
|
||||
float snowFactor = 0.0;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined REFLECTION_RAIN && defined RAIN_REF_BIOME_CHECK
|
||||
float noRain = float(material == 3.0);
|
||||
#endif
|
||||
|
||||
#ifndef COMPBR
|
||||
GetMaterials(smoothness, metalness, f0, metalData, emissive, materialAO, normalMap, newCoord, dcdx, dcdy);
|
||||
#else
|
||||
#include "/lib/ifchecks/terrainFragment.glsl"
|
||||
|
||||
#ifdef METALLIC_WORLD
|
||||
metalness = 1.0;
|
||||
smoothness = sqrt1(smoothness);
|
||||
#endif
|
||||
|
||||
f0 = 0.78 * metalness + 0.02;
|
||||
metalData = metalness;
|
||||
|
||||
if (material == 201.0) { // Diamond Block, Emerald Block
|
||||
f0 = smoothness;
|
||||
smoothness = 0.9 - f0 * 0.1;
|
||||
if (albedo.g > albedo.b * 1.1) { // Emerald Block
|
||||
f0 *= f0 * 1.2;
|
||||
f0 *= f0;
|
||||
f0 = clamp(f0 * f0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined NOISY_TEXTURES || defined GENERATED_NORMALS
|
||||
#include "/lib/other/mipLevel.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_MAPPING
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
if (cauldron < 0.5)
|
||||
AutoGenerateNormals(normalMap, albedoP, delta);
|
||||
|
||||
|
||||
if (normalMap != vec4(0.0, 0.0, 1.0, 1.0))
|
||||
#endif
|
||||
{
|
||||
if (normalMap.x > -0.999 && normalMap.y > -0.999)
|
||||
newNormal = clamp(normalize(normalMap.xyz * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef SNOW_MODE
|
||||
#ifdef OVERWORLD
|
||||
if (noSnow + cauldron < 0.5) {
|
||||
vec3 snowColor = vec3(0.5, 0.5, 0.65);
|
||||
vec2 snowCoord = vTexCoord.xy / 8.0;
|
||||
float snowNoise = texture2D(noisetex, snowCoord).r;
|
||||
snowColor *= 0.85 + 0.5 * snowNoise;
|
||||
float grassFactor = ((1.0 - abs(albedo.g - 0.3) * 4.0) - albedo.r * 2.0) * float(color.r < 0.999) * 2.0;
|
||||
snowFactor = clamp(dot(newNormal, upVec), 0.0, 1.0);
|
||||
//snowFactor *= snowFactor;
|
||||
if (grassFactor > 0.0) snowFactor = max(snowFactor * 0.75, grassFactor);
|
||||
snowFactor *= pow(lightmap.y, 16.0) * (1.0 - pow(lightmap.x + 0.1, 8.0) * 1.5);
|
||||
snowFactor = clamp(snowFactor, 0.0, 0.85);
|
||||
albedo.rgb = mix(albedo.rgb, snowColor, snowFactor);
|
||||
#ifdef ADV_MAT
|
||||
float snowFactor2 = snowFactor * (0.75 + 0.5 * snowNoise);
|
||||
smoothness = mix(smoothness, 0.45, snowFactor2);
|
||||
metalness = mix(metalness, 0.0, snowFactor2);
|
||||
//emissive = mix(emissive, 0.0, min(snowFactor2 * 5.0, 1.0));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_TEXTURES
|
||||
if (cauldron < 0.5)
|
||||
NoiseCoatTextures(albedo, smoothness, emissive, metalness, worldPos, miplevel, noiseVarying, snowFactor);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = clamp(dot(newNormal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float fullNdotU = dot(newNormal, upVec);
|
||||
float quarterNdotUp = clamp(0.25 * fullNdotU + 0.75, 0.5, 1.0);
|
||||
float quarterNdotU = quarterNdotUp * quarterNdotUp;
|
||||
if (quarterNdotUfactor < 0.5) quarterNdotU = 1.0;
|
||||
|
||||
float smoothLighting = color.a;
|
||||
#ifdef OLD_LIGHTING_FIX
|
||||
// Probably not worth the %4 fps loss
|
||||
// Don't forget to apply the same code to gbuffers_water if I end up making this an option
|
||||
if (smoothLighting < 0.9999999) {
|
||||
float absNdotE = abs(dot(newNormal, eastVec));
|
||||
float absNdotN = abs(dot(newNormal, northVec));
|
||||
float NdotD = abs(fullNdotU) * float(fullNdotU < 0.0);
|
||||
|
||||
smoothLighting += 0.4 * absNdotE;
|
||||
smoothLighting += 0.2 * absNdotN;
|
||||
smoothLighting += 0.502 * NdotD;
|
||||
|
||||
smoothLighting = clamp(smoothLighting, 0.0, 1.0);
|
||||
//albedo.rgb = mix(vec3(1, 0, 1), albedo.rgb, pow(smoothLighting, 10000.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADV_MAT
|
||||
rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
#ifdef COMPBR
|
||||
if (metalness > 0.801) {
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
}
|
||||
#else
|
||||
albedo.rgb *= (1.0 - metalness*0.65);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined SELF_SHADOW && defined NORMAL_MAPPING
|
||||
float doParallax = 0.0;
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NdotL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NdotL > 0.0);
|
||||
#endif
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(parallaxFade, newCoord, lightVec, tbnMatrix, parallaxDepth, normalMap.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_LIGHTMAP
|
||||
mat3 lightmapTBN = GetLightmapTBN(viewPos);
|
||||
lightmap.x = DirectionalLightmap(lightmap.x, lmCoord.x, newNormal, lightmapTBN);
|
||||
lightmap.y = DirectionalLightmap(lightmap.y, lmCoord.y, newNormal, lightmapTBN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPos, worldPos, lightmap, smoothLighting, NdotL, quarterNdotU,
|
||||
parallaxShadow, emissive, subsurface, leaves, materialAO);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifdef OVERWORLD
|
||||
#ifdef REFLECTION_RAIN
|
||||
if (quarterNdotUp > 0.85) {
|
||||
#ifdef RAIN_REF_BIOME_CHECK
|
||||
if (noRain < 0.1) {
|
||||
#endif
|
||||
vec2 rainPos = worldPos.xz + cameraPosition.xz;
|
||||
|
||||
skymapMod = max(lmCoord.y * 16.0 - 15.5, 0.0);
|
||||
|
||||
float puddleSize = 0.0025;
|
||||
skymapMod *= GetPuddles(rainPos * puddleSize);
|
||||
|
||||
float skymapModx2 = skymapMod * 2.0;
|
||||
smoothness = mix(smoothness, 0.8 , skymapModx2);
|
||||
metalness = mix(metalness , 0.0 , skymapModx2);
|
||||
metalData = mix(metalData , 0.0 , skymapModx2);
|
||||
f0 = mix(f0 , 0.02, skymapModx2);
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
rainPos *= 0.02;
|
||||
vec2 wind = vec2(frametime) * 0.01;
|
||||
vec3 pnormalMap = vec3(0.0, 0.0, 1.0);
|
||||
float pnormalMultiplier = 0.05;
|
||||
|
||||
vec2 pnormalCoord1 = rainPos + vec2(wind.x, wind.y);
|
||||
vec3 pnormalNoise1 = texture2D(noisetex, pnormalCoord1).rgb;
|
||||
vec2 pnormalCoord2 = rainPos + vec2(wind.x * -1.5, wind.y * -1.0);
|
||||
vec3 pnormalNoise2 = texture2D(noisetex, pnormalCoord2).rgb;
|
||||
|
||||
pnormalMap += (pnormalNoise1 - vec3(0.5)) * pnormalMultiplier;
|
||||
pnormalMap += (pnormalNoise2 - vec3(0.5)) * pnormalMultiplier;
|
||||
vec3 puddleNormal = clamp(normalize(pnormalMap * tbnMatrix),vec3(-1.0),vec3(1.0));
|
||||
|
||||
albedo.rgb *= 1.0 - sqrt(length(pnormalMap.xy)) * 0.8 * skymapModx2 * (rainStrengthS);
|
||||
|
||||
vec3 rainNormal = normalize(mix(newNormal, puddleNormal, rainStrengthS));
|
||||
|
||||
newNormal = mix(newNormal, rainNormal, skymapModx2);
|
||||
#ifdef RAIN_REF_BIOME_CHECK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 lightME = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 lightDayTint = lightDay * lightME * LIGHT_DI;
|
||||
vec3 lightDaySpec = mix(lightME, sqrt(lightDayTint), timeBrightness);
|
||||
vec3 specularColor = mix(sqrt(lightNight*0.3),
|
||||
lightDaySpec,
|
||||
sunVisibility);
|
||||
#ifdef WATER_CAUSTICS
|
||||
if (isEyeInWater == 1) specularColor *= underwaterColor.rgb * 8.0;
|
||||
#endif
|
||||
specularColor *= specularColor;
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
float skymapModM = lmCoord.y;
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
skymapModM = skymapModM * skymapModM;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
skymapModM = max(skymapModM - 0.80, 0.0) * 5.0;
|
||||
#else
|
||||
skymapModM = max(skymapModM - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
if (!(metalness <= 0.004 && metalness > 0.0)) skymapMod = max(skymapMod, skymapModM * 0.1);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef END
|
||||
vec3 specularColor = endCol;
|
||||
#ifdef COMPBR
|
||||
if (cauldron > 0.0) skymapMod = (min(length(shadow), 0.475) + 0.515) * float(smoothness > 0.9);
|
||||
else
|
||||
#endif
|
||||
skymapMod = min(length(shadow), 0.5);
|
||||
#endif
|
||||
|
||||
#ifdef SPECULAR_SKY_REF
|
||||
vec3 specularHighlight = vec3(0.0);
|
||||
specularHighlight = GetSpecularHighlight(smoothness - cauldron, metalness, f0, specularColor, rawAlbedo,
|
||||
shadow, newNormal, viewPos);
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING && defined SELF_SHADOW
|
||||
specularHighlight *= parallaxShadow;
|
||||
#endif
|
||||
#if defined LIGHT_LEAK_FIX && !defined END
|
||||
if (isEyeInWater == 0) specularHighlight *= pow(lightmap.y, 2.5);
|
||||
else specularHighlight *= 0.15 + 0.85 * pow(lightmap.y, 2.5);
|
||||
#endif
|
||||
albedo.rgb += specularHighlight;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined COMPBR && defined REFLECTION_SPECULAR
|
||||
smoothness *= 0.5;
|
||||
if (extraSpecularM > 0.5) smoothness += 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SHOW_LIGHT_LEVELS > 0
|
||||
#if SHOW_LIGHT_LEVELS == 1
|
||||
if (heldItemId == 13001 || heldItemId2 == 13001)
|
||||
#elif SHOW_LIGHT_LEVELS == 3
|
||||
if (heldBlockLightValue > 7.4 || heldBlockLightValue2 > 7.4)
|
||||
#endif
|
||||
if (dot(normal, upVec) > 0.99 && foliage + leaves < 0.1 && material != 162.0) {
|
||||
#include "/lib/other/indicateLightLevels.glsl"
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(1.0, 1.0, 170.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
#if THE_FORBIDDEN_OPTION > 1
|
||||
albedo = min(albedo, vec4(1.0));
|
||||
#endif
|
||||
|
||||
#ifdef GREEN_SCREEN
|
||||
if (greenScreen > 0.5) {
|
||||
albedo.rgb = vec3(0.0, 0.08, 0.0);
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
smoothness = 0.0;
|
||||
metalData = 0.0;
|
||||
skymapMod = 0.51;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef BLUE_SCREEN
|
||||
if (blueScreen > 0.5) {
|
||||
albedo.rgb = vec3(0.0, 0.0, 0.18);
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
smoothness = 0.0;
|
||||
metalData = 0.0;
|
||||
skymapMod = 0.51;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} else discard;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0361 */
|
||||
gl_FragData[1] = vec4(smoothness, metalData, skymapMod, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(rawAlbedo, 1.0);
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
/* DRAWBUFFERS:03618 */
|
||||
gl_FragData[4] = vec4(lightAlbedo, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#ifdef COLORED_LIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(lightAlbedo, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrengthS;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#if AA > 1
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
#ifdef ADV_MAT
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
#if THE_FORBIDDEN_OPTION > 1
|
||||
if (length(position.xz) > 0.0) {
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, 0.0, 1.0);
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#if defined NORMAL_MAPPING || defined REFLECTION_RAIN
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
|
||||
#if defined PARALLAX || defined SELF_SHADOW
|
||||
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;
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).xy;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
|
||||
vTexCoordAM.zw = abs(texMinMidCoord) * 2;
|
||||
|
||||
#if !defined COMPBR || defined NORMAL_MAPPING || defined NOISY_TEXTURES || defined SNOW_MODE
|
||||
vTexCoordAM.xy = min(texCoord, midCoord - texMinMidCoord);
|
||||
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
|
||||
#ifdef COMPBR
|
||||
vTexCoordL = texMinMidCoord * 2;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
if (color.a < 0.1) color.a = 1.0;
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef SNOW_MODE
|
||||
noSnow = 0.0;
|
||||
#endif
|
||||
#ifdef COLORED_LIGHT
|
||||
lightVarying = 0.0;
|
||||
#endif
|
||||
#ifdef NOISY_TEXTURES
|
||||
noiseVarying = 1.0;
|
||||
#endif
|
||||
|
||||
mat = 0.0; mipmapDisabling = 0.0; quarterNdotUfactor = 1.0; specB = 0.0;
|
||||
|
||||
#ifdef COMPBR
|
||||
specR = 0.0; specG = 0.0; extraSpecular = 0.0;
|
||||
#endif
|
||||
|
||||
#include "/lib/ifchecks/terrainVertex.glsl"
|
||||
|
||||
mat += 0.25;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
#ifdef OLD_LIGHTING_FIX
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
northVec = normalize(gbufferModelView[2].xyz);
|
||||
#endif
|
||||
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
vec3 wave = WavingBlocks(position.xyz, istopv, lmCoord.y);
|
||||
position.xyz += wave;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#ifdef COMPBR
|
||||
oldPosition = position.xyz;
|
||||
#endif
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
#ifndef NO_PARTICLES
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float isEyeInCave;
|
||||
uniform float blindFactor;
|
||||
uniform float far;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 fogColor;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#if ((defined WATER_CAUSTICS || defined CLOUD_SHADOW) && defined OVERWORLD) || defined RANDOM_BLOCKLIGHT || defined END || (defined NETHER && defined NETHER_SMOKE)
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if !defined COMPATIBILITY_MODE && MC_VERSION >= 11700
|
||||
uniform ivec4 blendFunc;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#if MC_VERSION >= 11500
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#endif
|
||||
|
||||
#if (defined END && defined ENDER_NEBULA) || (defined NETHER && defined NETHER_SMOKE)
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = vec4(0.0);
|
||||
vec3 vlAlbedo = vec3(1.0);
|
||||
|
||||
#ifndef SEVEN
|
||||
float textured = 1.0;
|
||||
#else
|
||||
float textured = 0.0;
|
||||
#endif
|
||||
|
||||
#ifndef NO_PARTICLES
|
||||
vec4 albedoP = texture2D(texture, texCoord);
|
||||
albedo = albedoP * color;
|
||||
|
||||
float skymapMod = 0.0;
|
||||
|
||||
if (albedo.a > 0.0) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
float lViewPos = length(viewPos);
|
||||
|
||||
#ifdef SEVEN
|
||||
textured = float(lViewPos < 10.0); // Fixes the Twilight Forest skybox messing with TAA
|
||||
#endif
|
||||
|
||||
float emissive = 0.0;
|
||||
#ifdef COMPBR
|
||||
if (atlasSize.x < 900.0) { // We don't want to detect particles from the block atlas
|
||||
float lAlbedo = length(albedo.rgb);
|
||||
vec3 gamePos = worldPos + cameraPosition;
|
||||
|
||||
if (albedo.b > 1.15 * (albedo.r + albedo.g) && albedo.g > albedo.r * 1.25 && albedo.g < 0.425 && albedo.b > 0.75) // Water Particle
|
||||
albedo.rgb = waterColorSqrt.rgb * 1.1 * lAlbedo;
|
||||
|
||||
else if (albedo.r == albedo.g && albedo.r - 0.5 * albedo.b < 0.06) { // Underwater Particle
|
||||
if (isEyeInWater == 1) {
|
||||
albedo.rgb = waterColorSqrt.rgb * 1.1 * lAlbedo;
|
||||
if (fract(gamePos.r + gamePos.g + gamePos.b) > 0.2) discard;
|
||||
}
|
||||
}
|
||||
|
||||
else if (color.a < 0.99 && lAlbedo < 1.0) // Campfire Smoke, World Border
|
||||
albedo.a *= 0.2, textured = 0.0;
|
||||
|
||||
else if (max(abs(albedoP.r - albedoP.b), abs(albedoP.b - albedoP.g)) < 0.001) { // Grayscale Particles
|
||||
if (lAlbedo > 0.5 && color.g < 0.5 && color.b > color.r * 1.1 && color.r > 0.3) // Ender Particle, Crying Obsidian Drop
|
||||
emissive = max(pow(albedo.r, 5.0), 0.1);
|
||||
if (lAlbedo > 0.5 && color.g < 0.5 && color.r > (color.g + color.b) * 3.0) // Redstone Particle
|
||||
lightmap = vec2(0.0), emissive = max(pow(albedo.r, 5.0), 0.1);
|
||||
}
|
||||
|
||||
//albedo.rgb = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined COMPATIBILITY_MODE && MC_VERSION >= 11700
|
||||
if (blendFunc == ivec4(770, 1, 1, 0)) { // World Border
|
||||
albedo.a = albedoP.a * color.a * 0.2;
|
||||
lightmap = vec2(1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXTRA_PARTICLE_EMISSION
|
||||
if (atlasSize.x < 900.0) {
|
||||
if (color.r + color.g + color.b < 2.99) {
|
||||
emissive = 1.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
float NdotL = 1.0;
|
||||
NdotL = clamp(dot(normal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(normal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU;
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPos, worldPos, lightmap, 1.0, NdotL, 1.0,
|
||||
1.0, emissive, 0.0, 0.0, 1.0);
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
albedo.rgb *= 2.0;
|
||||
#endif
|
||||
|
||||
#ifdef PARTICLE_VISIBILITY
|
||||
if (lViewPos < 2.0) albedo.a *= smoothstep(0.7, 2.0, lViewPos) + 0.0002;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11500
|
||||
vlAlbedo = mix(vec3(1.0), albedo.rgb, sqrt1(albedo.a)) * (1.0 - pow(albedo.a, 64.0));
|
||||
|
||||
if (atlasSize.x > 5.0) { // No Fog On Journey Map Waypoints
|
||||
vec3 extra = vec3(0.0);
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
extra = DrawNetherSmoke(viewPos.xyz, dither, pow((netherCol * 2.5) / NETHER_I, vec3(2.2)) * 4);
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 enderNebula = DrawEnderNebula(viewPos.xyz, dither, endCol, nebulaStars);
|
||||
enderNebula = pow(enderNebula, vec3(1.0 / 2.2));
|
||||
enderNebula *= pow(enderNebula, vec3(2.2));
|
||||
extra = enderNebula;
|
||||
#endif
|
||||
albedo.rgb = startFog(albedo.rgb, nViewPos, lViewPos, worldPos, extra, NdotU);
|
||||
}
|
||||
#endif
|
||||
} else discard;
|
||||
#endif
|
||||
|
||||
#if defined TWO && !defined PARTICLE_VISIBILITY
|
||||
albedo.a = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(255.0, 170.0, 0.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.2;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:017 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(vlAlbedo, 1.0);
|
||||
gl_FragData[2] = vec4(textured, 1.0, 1.0, 1.0);
|
||||
|
||||
#if defined ADV_MAT && defined REFLECTION_SPECULAR && MC_VERSION < 11500
|
||||
/* DRAWBUFFERS:01736 */
|
||||
gl_FragData[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_FragData[4] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
#ifndef NO_PARTICLES
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#ifndef NO_PARTICLES
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, 0.0, 1.0);
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#ifdef COMPBR
|
||||
if (mc_Entity.x == 12101) // Tripwire
|
||||
lmCoord.x *= 0.9;
|
||||
#endif
|
||||
|
||||
#ifdef FLICKERING_FIX
|
||||
gl_Position.z -= 0.000002;
|
||||
#endif
|
||||
|
||||
#else
|
||||
gl_Position = vec4(0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,851 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal, binormal, tangent;
|
||||
varying vec3 sunVec, upVec;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#if (defined ADV_MAT && defined NORMAL_MAPPING) || (FANCY_NETHER_PORTAL > 0 && defined COMPBR)
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
|
||||
#ifdef COMPBR
|
||||
varying vec2 vTexCoordL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldDay;
|
||||
uniform int moonPhase;
|
||||
#define UNIFORM_moonPhase
|
||||
|
||||
#if defined DYNAMIC_SHADER_LIGHT || SHOW_LIGHT_LEVELS == 1 || SHOW_LIGHT_LEVELS == 3
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float isEyeInCave;
|
||||
uniform float blindFactor;
|
||||
uniform float nightVision;
|
||||
uniform float far, near;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float eyeAltitude;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 skyColor;
|
||||
uniform vec3 fogColor;
|
||||
|
||||
uniform mat4 gbufferProjection, gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelView, gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D gaux2;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING && !defined COMPBR
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
uniform float isDry, isRainy, isSnowy;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_LIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessLightFactor;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && defined GENERATED_NORMALS
|
||||
uniform ivec2 atlasSize;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
#if WORLD_TIME_ANIMATION == 2
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 1
|
||||
int modifiedWorldDay = int(mod(worldDay, 100.0) + 5.0);
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = (worldTime + modifiedWorldDay * 24000) * 0.05 * ANIMATION_SPEED;
|
||||
#endif
|
||||
#if WORLD_TIME_ANIMATION == 0
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
float cloudtime = frametime;
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && defined NORMAL_MAPPING
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetWaterHeightMap(vec3 worldPos, vec3 nViewPos) {
|
||||
float verticalOffset = worldPos.y * 0.005;
|
||||
|
||||
vec2 wind = vec2(frametime) * 0.0015;
|
||||
wind *= WATER_SPEED;
|
||||
wind -= verticalOffset;
|
||||
|
||||
vec4 noiseS = vec4(0.5);
|
||||
noiseS.r = texture2D(noisetex, (worldPos.xz) / (1.0 * WATER_SIZE) - wind).g;
|
||||
noiseS.g = texture2D(noisetex, (worldPos.xz) / (0.6 * WATER_SIZE) + wind).g;
|
||||
noiseS.b = texture2D(noisetex, (worldPos.xz) / (0.35 * WATER_SIZE) + wind).g;
|
||||
noiseS.a = texture2D(noisetex, (worldPos.xz) / (0.3 * WATER_SIZE) - wind).g;
|
||||
noiseS *= - noiseS;
|
||||
float noise = noiseS.r * WATER_NOISE_1
|
||||
- noiseS.r * noiseS.g * WATER_NOISE_2
|
||||
+ noiseS.g * WATER_NOISE_3
|
||||
+ (noiseS.b - noiseS.a) * WATER_NOISE_4;
|
||||
|
||||
noise *= WATER_BUMP * (lmCoord.y*0.9 + 0.1) * 0.42;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
vec3 GetParallaxWaves(vec3 worldPos, vec3 nViewPos, vec3 viewVector, float lViewPos) {
|
||||
vec3 parallaxPos = worldPos;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
float height = (GetWaterHeightMap(parallaxPos, nViewPos) - 0.5);
|
||||
parallaxPos.xz += 0.2 * height * viewVector.xy / lViewPos;
|
||||
}
|
||||
return parallaxPos;
|
||||
}
|
||||
|
||||
vec3 GetWaterNormal(vec3 worldPos, vec3 nViewPos, vec3 viewVector, float lViewPos) {
|
||||
vec3 waterPos = worldPos + cameraPosition;
|
||||
#ifdef WATER_PARALLAX
|
||||
waterPos = GetParallaxWaves(waterPos, nViewPos, viewVector, lViewPos);
|
||||
#endif
|
||||
|
||||
float normalOffset = WATER_SHARPNESS;
|
||||
|
||||
float h1 = GetWaterHeightMap(waterPos + vec3( normalOffset, 0.0, 0.0), nViewPos);
|
||||
float h2 = GetWaterHeightMap(waterPos + vec3(-normalOffset, 0.0, 0.0), nViewPos);
|
||||
float h3 = GetWaterHeightMap(waterPos + vec3(0.0, 0.0, normalOffset), nViewPos);
|
||||
float h4 = GetWaterHeightMap(waterPos + vec3(0.0, 0.0, -normalOffset), nViewPos);
|
||||
|
||||
float xDelta = (h1 - h2) / normalOffset;
|
||||
float yDelta = (h3 - h4) / normalOffset;
|
||||
float aDelta = xDelta * xDelta + yDelta * yDelta;
|
||||
|
||||
vec3 normalMap = vec3(xDelta, yDelta, 1.0 - aDelta);
|
||||
|
||||
#if defined REFLECTION_ROUGH && WATER_TYPE == 2
|
||||
vec3 roughMap = texture2D(noisetex, texCoord * 2097152).rgb;
|
||||
normalMap = normalMap + 0.5 * (roughMap - vec3(0.5, 0.5, 1.0));
|
||||
#endif
|
||||
|
||||
vec3 normalClamp = vec3(1.75);
|
||||
normalMap = clamp(normalMap, normal - normalClamp, normal + normalClamp);
|
||||
normalMap = normalMap * 0.03 + vec3(0.0, 0.0, 0.75);
|
||||
|
||||
return normalMap;
|
||||
}
|
||||
|
||||
float GetWaterOpacity(float alpha, float difT, float fresnel, float lViewPos) {
|
||||
//Fake water fog
|
||||
float waterFogDist = 1.0 - min(difT / WATER_FOG, 1.0);
|
||||
waterFogDist *= waterFogDist;
|
||||
alpha = mix(0.97, alpha, min(waterFogDist, 1.0 - fresnel));
|
||||
|
||||
//Hide shadows not being good enough
|
||||
alpha = max(min(sqrt(lViewPos) * 0.075, 0.9), alpha);
|
||||
|
||||
alpha = min(alpha, 1.0 - nightVision * 0.2);
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/reflections/raytracewater.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/reflections/simpleReflections.glsl"
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#ifdef AURORA
|
||||
#include "/lib/color/auroraColor.glsl"
|
||||
#endif
|
||||
|
||||
#if defined CLOUDS || defined AURORA
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#endif
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#endif
|
||||
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#endif
|
||||
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
#include "/lib/atmospherics/skyboxEffects.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#if defined ADV_MAT && defined GENERATED_NORMALS
|
||||
#include "/lib/surface/autoGenNormals.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedoP = texture2D(texture, texCoord);
|
||||
if (albedoP.a == 0.0) discard; //needed for "Create" mod support
|
||||
vec4 albedo = albedoP * vec4(color.rgb, 1.0);
|
||||
|
||||
float emissive = 0.0;
|
||||
vec3 newNormal = normal;
|
||||
vec3 vlAlbedo = vec3(1.0);
|
||||
vec3 worldPos = vec3(0.0);
|
||||
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
float albedocheck = albedo.a;
|
||||
#else
|
||||
float albedocheck = albedo.a * 100000.0;
|
||||
#endif
|
||||
|
||||
if (albedocheck > 0.00001) {
|
||||
vec2 lightmap = lmCoord;
|
||||
|
||||
float water = float(mat > 0.98 && mat < 1.02);
|
||||
float translucent = float(mat > 1.98 && mat < 2.52);
|
||||
float tintedGlass = float(mat > 2.23 && mat < 2.27);
|
||||
float ice = float(mat > 2.48 && mat < 2.52);
|
||||
float netherPortal = float(mat > 2.98 && mat < 3.02);
|
||||
float moddedfluid = float(mat > 3.98 && mat < 5.02);
|
||||
float moddedfluidX = float(mat > 4.98 && mat < 5.02);
|
||||
|
||||
#ifndef REFLECTION_TRANSLUCENT
|
||||
translucent = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
worldPos = ViewToWorld(viewPos);
|
||||
float lViewPos = length(viewPos);
|
||||
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
#ifdef WATER_WAVES
|
||||
if (water + moddedfluidX > 0.5) {
|
||||
normalMap = GetWaterNormal(worldPos, nViewPos, viewVector, lViewPos);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
|
||||
// Iris' Broken Water Normal Workaround
|
||||
float VdotN = dot(nViewPos, normalize(normal));
|
||||
if (VdotN > 0.0) newNormal = -newNormal;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ADV_MAT
|
||||
#ifdef NORMAL_MAPPING
|
||||
if (water < 0.5) {
|
||||
#ifdef COMPBR
|
||||
#include "/lib/other/mipLevel.glsl"
|
||||
|
||||
vec4 normalMapV4 = vec4(normalMap, 1.0);
|
||||
|
||||
AutoGenerateNormals(normalMapV4, albedoP.rgb, delta);
|
||||
|
||||
normalMap = normalMapV4.xyz;
|
||||
|
||||
if (normalMap != vec3(0.0, 0.0, 1.0))
|
||||
#else
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
normalMap = textureGrad(normals, newCoord, dcdx, dcdy).xyz;
|
||||
normalMap += vec3(0.5, 0.5, 0.0);
|
||||
normalMap = pow(normalMap, vec3(NORMAL_MULTIPLIER));
|
||||
normalMap -= vec3(0.5, 0.5, 0.0);
|
||||
#if RP_SUPPORT == 4
|
||||
normalMap = normalMap * 2.0 - 1.0;
|
||||
#else
|
||||
normalMap = normalMap * 2.0 - 1.0;
|
||||
float normalCheck = normalMap.x + normalMap.y;
|
||||
if (normalCheck > -1.999) {
|
||||
if (length(normalMap.xy) > 1.0) normalMap.xy = normalize(normalMap.xy);
|
||||
normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy));
|
||||
normalMap = normalize(clamp(normalMap, vec3(-1.0), vec3(1.0)));
|
||||
} else {
|
||||
normalMap = vec3(0.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (normalMap.x > -0.999 && normalMap.y > -0.999)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined COMPBR && FANCY_NETHER_PORTAL > 0
|
||||
if (netherPortal > 0.5) {
|
||||
lightmap = vec2(0.0);
|
||||
#if AA > 1
|
||||
dither = fract(dither + frameTimeCounter * 16.0);
|
||||
int sampleCount = 24;
|
||||
#else
|
||||
int sampleCount = 48;
|
||||
#endif
|
||||
|
||||
float multiplier = 2.0 / (-viewVector.z * sampleCount);
|
||||
vec2 interval = viewVector.xy * multiplier;
|
||||
vec2 coord = vTexCoord.st;
|
||||
|
||||
vec4 albedoC = vec4(0.0);
|
||||
albedo *= 0.0;
|
||||
for (int i = 1; i <= sampleCount; i++) {
|
||||
float portalStep = (i - 1.0 + dither) / sampleCount;
|
||||
coord += interval * portalStep;
|
||||
vec4 psample = texture2DLod(texture, fract(coord) * vTexCoordAM.pq + vTexCoordAM.st, 0);
|
||||
psample *= sqrt(1.0 - portalStep);
|
||||
|
||||
albedoC = max(albedoC, psample);
|
||||
|
||||
psample.rb *= vec2(1.5, 0.92);
|
||||
psample.a = sqrt2(psample.a) * 0.925;
|
||||
|
||||
albedo += psample;
|
||||
}
|
||||
albedo /= sampleCount;
|
||||
|
||||
emissive = albedoC.r * albedoC.r;
|
||||
emissive *= emissive;
|
||||
emissive *= emissive;
|
||||
emissive = clamp(emissive * 120.0, 0.03, 1.2);
|
||||
|
||||
#if FANCY_NETHER_PORTAL > 1
|
||||
vec2 portalCoord = abs(vTexCoord.xy - 0.5);
|
||||
portalCoord = vec2(frametime) * 0.013 + 0.0625 * length(portalCoord);
|
||||
float noise = texture2D(noisetex, portalCoord).r;
|
||||
noise *= noise;
|
||||
noise *= noise;
|
||||
emissive *= noise * 12.0;
|
||||
emissive += 0.01;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (moddedfluidX > 0.5) albedo = texture2DLod(texture, texCoord, 100.0) * vec4(color.rgb, 1.0);
|
||||
|
||||
if (water < 0.5) albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
float fresnel = clamp(1.0 + dot(newNormal, nViewPos), 0.0, 1.0);
|
||||
float fresnel2 = fresnel * fresnel;
|
||||
float fresnel4 = fresnel2 * fresnel2;
|
||||
|
||||
#if SKY_REF_FIX_1 == 1
|
||||
float skyLightFactor = lightmap.y * lightmap.y;
|
||||
#elif SKY_REF_FIX_1 == 2
|
||||
float skyLightFactor = max(lightmap.y - 0.7, 0.0) / 0.3;
|
||||
skyLightFactor *= skyLightFactor;
|
||||
#else
|
||||
float skyLightFactor = max(lightmap.y - 0.99, 0.0) * 100.0;
|
||||
#endif
|
||||
|
||||
float lViewPosT = 0.0;
|
||||
float difT = 0.0;
|
||||
vec3 terrainColor = vec3(0.0);
|
||||
vec3 combinedWaterColor = vec3(0.0);
|
||||
if (water > 0.5) {
|
||||
vec3 customWaterColor = vec3(waterColor.rgb * waterColor.rgb * 3.0 * waterColor.a);
|
||||
#if MC_VERSION >= 11300
|
||||
vec3 vanillaWaterColor = pow(color.rgb, vec3(2.2)) * waterColor.a;
|
||||
vec3 combinedWaterColor = mix(customWaterColor, vanillaWaterColor, WATER_V);
|
||||
#else
|
||||
vec3 combinedWaterColor = customWaterColor;
|
||||
#endif
|
||||
|
||||
#if WATER_TYPE == 0
|
||||
#if MC_VERSION >= 11300
|
||||
albedo.a = WATER_OPACITY;
|
||||
if (isEyeInWater == 1) {
|
||||
albedo.a = 1.0 - pow2(pow2(1.0 - albedo.a * min(fresnel2, 1.0)));
|
||||
albedo.a = max(albedo.a, 0.0002);
|
||||
}
|
||||
#else
|
||||
albedo.a = 0.5;
|
||||
#endif
|
||||
albedo.rgb = combinedWaterColor;
|
||||
#endif
|
||||
|
||||
#if WATER_TYPE == 1
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.7;
|
||||
albedo.a *= 1.0 - pow2(1.0 - WATER_OPACITY);
|
||||
#endif
|
||||
|
||||
#if WATER_TYPE == 2
|
||||
albedo.a *= length(albedo.rgb) * WATER_OPACITY * 1.5;
|
||||
float albedoPRTX = pow2(albedoP.r * albedoP.r);
|
||||
albedo.rgb = waterColor.rgb * albedoPRTX + 0.5 * waterColor.rgb * albedoPRTX;
|
||||
albedo.rgb = mix(albedo.rgb, albedo.rgb * color.rgb, 0.5);
|
||||
if (WATER_OPACITY > 0.82) albedo.rgb = min(albedo.rgb * (1.0 + length(albedo.rgb) * pow(WATER_OPACITY, 32.0) * 50.0), vec3(2.0));
|
||||
if (isEyeInWater == 1) albedo.a = 0.5;
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 0) {
|
||||
#ifdef WATER_ABSORPTION
|
||||
terrainColor = texture2D(gaux2, gl_FragCoord.xy / vec2(viewWidth, viewHeight)).rgb;
|
||||
#endif
|
||||
vec2 texCoordT = gl_FragCoord.xy / vec2(viewWidth, viewHeight);
|
||||
float depthT = texture2D(depthtex1, texCoordT).r;
|
||||
vec3 screenPosT = vec3(texCoordT, depthT);
|
||||
#if AA > 1
|
||||
vec3 viewPosT = ScreenToView(vec3(TAAJitter(screenPosT.xy, -0.5), screenPosT.z));
|
||||
#else
|
||||
vec3 viewPosT = ScreenToView(screenPosT);
|
||||
#endif
|
||||
lViewPosT = length(viewPosT);
|
||||
difT = (lViewPosT - lViewPos);
|
||||
albedo.a = GetWaterOpacity(albedo.a, difT, fresnel, lViewPos);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.5);
|
||||
#endif
|
||||
|
||||
if (water < 0.5) vlAlbedo = mix(vec3(1.0), albedo.rgb, sqrt1(albedo.a)) * (1.0 - pow(albedo.a, 64.0)) - vec3(0.002);
|
||||
else vlAlbedo = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
float NdotL = clamp(dot(newNormal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float quarterNdotU = clamp(0.25 * dot(newNormal, upVec) + 0.75, 0.5, 1.0);
|
||||
quarterNdotU*= quarterNdotU;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
float materialAO = 1.0;
|
||||
|
||||
float subsurface = 0.0;
|
||||
#if SHADOW_SUBSURFACE > 0
|
||||
if (translucent > 0.5 && ice < 0.5) {
|
||||
subsurface = 1.0 - albedo.a;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, lightAlbedo, viewPos, lViewPos, worldPos, lightmap, color.a, NdotL, quarterNdotU,
|
||||
parallaxShadow, emissive, subsurface, 0.0, materialAO);
|
||||
|
||||
#ifdef WATER_ABSORPTION
|
||||
if (water > 0.5 && isEyeInWater == 0) {
|
||||
terrainColor = terrainColor * 2.0;
|
||||
terrainColor *= terrainColor;
|
||||
vec3 absorbColor = (normalize(waterColor.rgb + vec3(0.01)) * sqrt(UNDERWATER_I)) * terrainColor * 1.92;
|
||||
float absorbDist = 1.0 - clamp(difT / 8.0, 0.0, 1.0);
|
||||
vec3 newAlbedo = mix(absorbColor * absorbColor, terrainColor * terrainColor, absorbDist * absorbDist);
|
||||
newAlbedo *= newAlbedo * 0.7;
|
||||
|
||||
//duplicate 307309760
|
||||
float fog2 = lViewPosT / pow(far, 0.25) * 0.035 * (1.0 - sunVisibility*0.25) * (3.2/FOG2_DISTANCE_M);
|
||||
fog2 = (1.0 - (exp(-50.0 * pow(fog2*0.125, 3.25) * eBS)));
|
||||
float fixAtmFog = max(1.0 - fog2, 0.0);
|
||||
fixAtmFog *= fixAtmFog;
|
||||
fixAtmFog *= fixAtmFog;
|
||||
fixAtmFog *= fixAtmFog;
|
||||
fixAtmFog *= 1.0 - rainStrengthS;
|
||||
|
||||
float absorb = (1.0 - albedo.a) * fixAtmFog * skyLightFactor;
|
||||
albedo.rgb = mix(albedo.rgb, newAlbedo / (1.0 - WATER_OPACITY), absorb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
//offset because consistency
|
||||
vec3 lightME = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 lightDayTint = lightDay * lightME * LIGHT_DI;
|
||||
vec3 lightDaySpec = mix(lightME, sqrt(lightDayTint), timeBrightness);
|
||||
vec3 specularColor = mix(sqrt(lightNight*0.3),
|
||||
lightDaySpec,
|
||||
sunVisibility);
|
||||
#ifdef WATER_CAUSTICS
|
||||
if (isEyeInWater == 1) specularColor *= underwaterColor.rgb * 8.0;
|
||||
#endif
|
||||
specularColor *= specularColor;
|
||||
#endif
|
||||
#if defined SEVEN || defined SEVEN_2
|
||||
vec3 specularColor = vec3(0.005, 0.006, 0.018);
|
||||
#endif
|
||||
|
||||
if (water > 0.5 || moddedfluid > 0.5 || (translucent > 0.5 && albedo.a < 0.95)) {
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
|
||||
fresnel = fresnel4 * 0.95 + 0.05;
|
||||
fresnel *= max(1.0 - isEyeInWater * 0.5 * water, 0.5);
|
||||
fresnel *= 1.0 - translucent * (1.0 - albedo.a);
|
||||
|
||||
#ifdef REFLECTION
|
||||
vec3 refNormal = mix(newNormal, normal, pow2(pow2(fresnel4)));
|
||||
reflection = SimpleReflection(viewPos, refNormal, dither, skyLightFactor);
|
||||
#endif
|
||||
|
||||
#ifdef WATER_TRANSLUCENT_SKY_REF
|
||||
if (reflection.a < 1.0) {
|
||||
vec3 skyReflectionPos = reflect(nViewPos, newNormal);
|
||||
float refNdotU = dot(skyReflectionPos, upVec);
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 gotTheSkyColor = vec3(0.0);
|
||||
if (isEyeInWater == 0) gotTheSkyColor = GetSkyColor(lightCol, refNdotU, skyReflectionPos, true);
|
||||
if (isEyeInWater == 1) gotTheSkyColor = 0.6 * pow(underwaterColor.rgb * (1.0 - blindFactor), vec3(2.0));
|
||||
skyReflection = gotTheSkyColor;
|
||||
#endif
|
||||
skyReflectionPos *= 1000000.0;
|
||||
#ifdef OVERWORLD
|
||||
float specular = 0.0;
|
||||
if (water > 0.5) {
|
||||
#if WATER_TYPE >= 1
|
||||
float waterSpecMult = SUN_MOON_WATER_REF;
|
||||
if (sunVisibility < 0.01) waterSpecMult *= MOON_WATER_REF;
|
||||
#if WATER_TYPE == 1
|
||||
float smoothnessRTX = albedoP.r * 0.5;
|
||||
waterSpecMult *= 0.7 - 0.7 * fresnel;
|
||||
#else
|
||||
float smoothnessRTX = albedoP.r * albedoP.r * 0.64;
|
||||
#endif
|
||||
specular = GGX(newNormal, nViewPos, lightVec, smoothnessRTX, 0.02, 0.025 * sunVisibility + 0.05);
|
||||
specular *= waterSpecMult * (0.15 + 0.85 * sunVisibility);
|
||||
#endif
|
||||
|
||||
#ifdef WATER_WAVES
|
||||
specular += stylisedGGX(newNormal, normal, nViewPos, lightVec, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_SHADOWS
|
||||
specular *= float(shadow.r + shadow.g + shadow.b > 2.3);
|
||||
#endif
|
||||
}
|
||||
#ifdef COMPBR
|
||||
if (ice > 0.5) {
|
||||
float smoothnessIce = length(albedoP.rgb);
|
||||
smoothnessIce = pow2(pow2(smoothnessIce)) * 0.12;
|
||||
specular = GGX(newNormal, nViewPos, lightVec, smoothnessIce, 0.02, 0.025 * sunVisibility + 0.05);
|
||||
}
|
||||
#endif
|
||||
specular *= sqrt1inv(rainStrengthS);
|
||||
#ifdef SHADOWS
|
||||
specular *= shadowFade;
|
||||
#endif
|
||||
|
||||
skyReflection *= skyLightFactor;
|
||||
#if defined CLOUDS || defined AURORA
|
||||
float cosT = dot(normalize(skyReflectionPos), upVec);
|
||||
#ifdef AURORA
|
||||
skyReflection += skyLightFactor * DrawAurora(skyReflectionPos, dither, 8, cosT);
|
||||
#endif
|
||||
float cloudFactor = 1.0;
|
||||
#ifdef CLOUDS
|
||||
if (isEyeInWater == 0) {
|
||||
vec4 cloud = DrawCloud(skyReflectionPos, dither, lightCol, ambientCol, cosT, 3);
|
||||
skyReflection = mix(skyReflection, cloud.rgb*skyLightFactor, cloud.a);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
skyReflection += (specular / fresnel) * specularColor * shadow * skyLightFactor;
|
||||
#endif
|
||||
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol * 0.005;
|
||||
#endif
|
||||
|
||||
#if defined END || defined SEVEN || defined SEVEN_2
|
||||
#if defined END
|
||||
skyReflection = endCol * 0.125;
|
||||
#ifdef ENDER_NEBULA
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 enderNebula = DrawEnderNebula(skyReflectionPos * 100.0, dither, endCol, nebulaStars);
|
||||
enderNebula += nebulaStars;
|
||||
skyReflection = enderNebula * shadow * 0.5;
|
||||
#endif
|
||||
#endif
|
||||
#if (defined SEVEN || defined SEVEN_2) && !defined TWENTY
|
||||
vec3 twilightPurple = vec3(0.005, 0.006, 0.018);
|
||||
vec3 twilightGreen = vec3(0.015, 0.03, 0.02);
|
||||
skyReflection = 2 * (twilightPurple * 2 * clamp(pow(refNdotU, 0.7), 0.0, 1.0) + twilightGreen * (1-clamp(pow(refNdotU, 0.7), 0.0, 1.0)));
|
||||
skyReflection *= lmCoord.y * float(isEyeInWater == 0);
|
||||
#endif
|
||||
|
||||
float specular = GGX(newNormal, nViewPos, lightVec, 0.4, 0.02, 0.025 * sunVisibility + 0.05);
|
||||
#endif
|
||||
|
||||
#ifdef TWENTY
|
||||
vec3 twilightGreen = vec3(0.015, 0.03, 0.02);
|
||||
vec3 twilightPurple = twilightGreen * 0.1;
|
||||
skyReflection = 2 * (twilightPurple * 2 * clamp(pow(refNdotU, 0.7), 0.0, 1.0) + twilightGreen * (1-clamp(pow(refNdotU, 0.7), 0.0, 1.0)));
|
||||
if (isEyeInWater > 0.5) skyReflection = pow(underwaterColor.rgb * (1.0 - blindFactor), vec3(2.0)) * fresnel;
|
||||
skyReflection *= pow2(lightmap.y * lightmap.y);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined REFLECTION || defined WATER_TRANSLUCENT_SKY_REF
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
|
||||
|
||||
albedo.rgb = mix(albedo.rgb, reflection.rgb, fresnel);
|
||||
#else
|
||||
albedo.rgb *= 1.0 + 2.0 * fresnel;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tintedGlass > 0.5) {
|
||||
albedo.a = sqrt1(albedo.a);
|
||||
}
|
||||
|
||||
vec3 extra = vec3(0.0);
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
extra = DrawNetherSmoke(viewPos.xyz, dither, pow((netherCol * 2.5) / NETHER_I, vec3(2.2)) * 4);
|
||||
#endif
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
vec3 nebulaStars = vec3(0.0);
|
||||
vec3 enderNebula = DrawEnderNebula(viewPos.xyz, dither, endCol, nebulaStars);
|
||||
enderNebula = pow(enderNebula, vec3(1.0 / 2.2));
|
||||
enderNebula *= pow(enderNebula, vec3(2.2));
|
||||
extra = enderNebula;
|
||||
#endif
|
||||
|
||||
albedo.rgb = startFog(albedo.rgb, nViewPos, lViewPos, worldPos, extra, NdotU);
|
||||
|
||||
#if SHOW_LIGHT_LEVELS > 0
|
||||
#if SHOW_LIGHT_LEVELS == 1
|
||||
if (heldItemId == 13001 || heldItemId2 == 13001)
|
||||
#elif SHOW_LIGHT_LEVELS == 3
|
||||
if (heldBlockLightValue > 7.4 || heldBlockLightValue2 > 7.4)
|
||||
#endif
|
||||
if (dot(normal, upVec) > 0.99 && (mat < 0.95 || mat > 1.05) && translucent < 0.5) {
|
||||
#include "/lib/other/indicateLightLevels.glsl"
|
||||
}
|
||||
#endif
|
||||
} else albedo.a = 0.0;
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(85.0, 255.0, 255.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:01 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(vlAlbedo, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrengthS;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#if AA > 1
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
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;
|
||||
|
||||
#if (defined ADV_MAT && defined NORMAL_MAPPING) || (FANCY_NETHER_PORTAL > 0 && defined COMPBR)
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
|
||||
vTexCoordAM.pq = abs(texMinMidCoord) * 2;
|
||||
vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord);
|
||||
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
|
||||
#ifdef COMPBR
|
||||
vTexCoordL = texMinMidCoord * 2;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
mat = 0.0;
|
||||
|
||||
if (mc_Entity.x == 79) mat = 2.0; // Stained Glass
|
||||
if (mc_Entity.x == 7978) mat = 2.25; // Tinted Glass
|
||||
if (mc_Entity.x == 7979) mat = 2.5; // Ice
|
||||
#if defined COMPBR && FANCY_NETHER_PORTAL > 0
|
||||
if (mc_Entity.x == 80) mat = 3.0;
|
||||
#endif
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
if (mc_Entity.x == 8) { // Water
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
lmCoord.x *= 0.6;
|
||||
#endif
|
||||
#ifdef WATER_DISPLACEMENT
|
||||
position.y += WavingWater(position.xyz, lmCoord.y);
|
||||
#endif
|
||||
mat = 1.0;
|
||||
}
|
||||
if (mc_Entity.x == 888) { // Modded Fluid With Vanilla Texture
|
||||
mat = 4.0;
|
||||
}
|
||||
if (mc_Entity.x == 889) { // Modded Fluid With Water Waves And No Texture
|
||||
#ifdef WATER_DISPLACEMENT
|
||||
position.y += WavingWater(position.xyz, lmCoord.y);
|
||||
#endif
|
||||
mat = 5.0;
|
||||
}
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
if (mat == 0.0) {
|
||||
gl_Position.z -= 0.00001;
|
||||
lmCoord = (lmCoord - 0.03125) * 1.06667;
|
||||
} else {
|
||||
lmCoord.y = (lmCoord.y - 0.03125) * 1.06667;
|
||||
lmCoord.x = smoothstep(0.0, 1.0, pow((lmCoord.x - 0.03125) * 0.55, 0.35));
|
||||
}
|
||||
lmCoord = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
#if AA > 1
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 upVec, sunVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
|
||||
uniform float nightVision;
|
||||
uniform float rainStrengthS;
|
||||
uniform float screenBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
uniform int heldItemId, heldItemId2;
|
||||
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot( sunVec,upVec) + 0.0625, 0.0, 0.125) * 8.0;
|
||||
float vsBrightness = clamp(screenBrightness, 0.0, 1.0);
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#if AA == 2 || AA == 3
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
#if AA == 4
|
||||
#include "/lib/util/jitter2.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord.xy);
|
||||
vec2 lightmap = lmCoord;
|
||||
|
||||
#ifdef OVERLAY_FIX
|
||||
if (color.r + color.g + color.b > 2.99999) {
|
||||
#endif
|
||||
if (albedo.a > 0.0) {
|
||||
#ifdef DYNAMIC_SHADER_LIGHT
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if AA > 1
|
||||
vec3 viewPos = ScreenToView(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ScreenToView(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ViewToWorld(viewPos);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
|
||||
float handLight = min(float(heldBlockLightValue2 + heldBlockLightValue), 15.0) / 15.0;
|
||||
|
||||
float handLightFactor = 1.0 - min(DYNAMIC_LIGHT_DISTANCE * handLight, lViewPos) / (DYNAMIC_LIGHT_DISTANCE * handLight);
|
||||
float finalHandLight = handLight * handLightFactor;
|
||||
lightmap.x = max(finalHandLight * 0.95, lightmap.x);
|
||||
#endif
|
||||
#ifndef COMPATIBILITY_MODE
|
||||
if (albedo.r <= 0.75) { // Rain
|
||||
albedo.a *= 0.15;
|
||||
albedo.rgb = sqrt(albedo.rgb);
|
||||
albedo.rgb *= (ambientCol + lightmap.x * lightmap.x * blocklightCol) * 0.75;
|
||||
} else { // Snow
|
||||
albedo.a *= 0.15;
|
||||
albedo.rgb = sqrt(albedo.rgb);
|
||||
albedo.rgb *= (ambientCol + lightmap.x * lightmap.x * blocklightCol) * 2.0;
|
||||
}
|
||||
#else
|
||||
albedo.a *= 0.15;
|
||||
albedo.rgb = sqrt(albedo.rgb);
|
||||
albedo.rgb *= (ambientCol + lightmap.x * lightmap.x * blocklightCol) * 0.75;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
albedo.rgb = vec3(85.0, 85.0, 85.0) / 255.0;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * 0.5;
|
||||
#endif
|
||||
#ifdef OVERLAY_FIX
|
||||
} else {
|
||||
albedo.rgb = pow(color.rgb, vec3(2.2)) * 2.0;
|
||||
albedo.rgb *= 0.25 + lightmap.x + lightmap.y * (1.0 + sunVisibility);
|
||||
if (texCoord.x == 0.0) albedo.a = pow2(color.a * color.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp(lmCoord * 2.0 - 1.0, 0.0, 1.0);
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
color = gl_Color;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
varying vec4 position;
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int blockEntityId;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
#else
|
||||
uniform float frameTimeCounter;
|
||||
#endif
|
||||
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
//Common Functions//
|
||||
void doWaterShadowCaustics(float dither) {
|
||||
#if defined WATER_CAUSTICS && defined OVERWORLD
|
||||
vec3 worldPos = position.xyz + cameraPosition.xyz;
|
||||
worldPos *= 0.5;
|
||||
float noise = 0.0;
|
||||
float mult = 0.5;
|
||||
|
||||
vec2 wind = vec2(frametime) * 0.3; //speed
|
||||
float verticalOffset = worldPos.y * 0.2;
|
||||
|
||||
if (mult > 0.01) {
|
||||
float lacunarity = 1.0 / 750.0, persistance = 1.0, weight = 0.0;
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
float windSign = mod(i,2) * 2.0 - 1.0;
|
||||
vec2 noiseCoord = worldPos.xz + wind * windSign - verticalOffset;
|
||||
if (i < 7) noise += texture2D(noisetex, noiseCoord * lacunarity).r * persistance;
|
||||
else {
|
||||
noise += texture2D(noisetex, noiseCoord * lacunarity * 0.125).r * persistance * 10.0;
|
||||
noise = -noise;
|
||||
float noisePlus = 1.0 + 0.125 * -noise;
|
||||
noisePlus *= noisePlus;
|
||||
noisePlus *= noisePlus;
|
||||
noise *= noisePlus;
|
||||
}
|
||||
|
||||
if (i == 0) noise = -noise;
|
||||
|
||||
weight += persistance;
|
||||
lacunarity *= 1.50;
|
||||
persistance *= 0.60;
|
||||
}
|
||||
noise *= mult / weight;
|
||||
}
|
||||
float noiseFactor = 1.1 + noise;
|
||||
noiseFactor = pow(noiseFactor, 10.0);
|
||||
if (noiseFactor > 1.0 - dither * 0.5) discard;
|
||||
#else
|
||||
discard;
|
||||
#endif
|
||||
}
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if MC_VERSION >= 11300
|
||||
if (blockEntityId == 138) discard;
|
||||
#endif
|
||||
|
||||
vec4 albedo = vec4(0.0);
|
||||
|
||||
#ifdef WRONG_MIPMAP_FIX
|
||||
#if !defined COLORED_SHADOWS || !defined OVERWORLD
|
||||
albedo.a = texture2DLod(tex, texCoord.xy, 0).a;
|
||||
#else
|
||||
albedo = texture2DLod(tex, texCoord.xy, 0);
|
||||
#endif
|
||||
#else
|
||||
#if !defined COLORED_SHADOWS || !defined OVERWORLD
|
||||
albedo.a = texture2D(tex, texCoord.xy).a;
|
||||
#else
|
||||
albedo = texture2D(tex, texCoord.xy);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (blockEntityId == 200) { // End Gateway Beam Fix
|
||||
if (color.r > 0.1) discard;
|
||||
}
|
||||
|
||||
if (albedo.a < 0.0001) discard;
|
||||
|
||||
float premult = float(mat > 0.95 && mat < 1.05);
|
||||
float water = float(mat > 1.95 && mat < 2.05);
|
||||
float ice = float(mat > 2.95 && mat < 3.05);
|
||||
|
||||
#ifdef NO_FOLIAGE_SHADOWS
|
||||
if (mat > 3.95 && mat < 4.05) discard;
|
||||
#endif
|
||||
|
||||
vec4 albedo0 = albedo;
|
||||
if (water > 0.5) {
|
||||
if (isEyeInWater < 0.5) {
|
||||
albedo0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
albedo = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
} else {
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
doWaterShadowCaustics(dither);
|
||||
}
|
||||
} else albedo0.rgb = vec3(0.0);
|
||||
|
||||
#if !defined COLORED_SHADOWS || !defined OVERWORLD
|
||||
if (premult > 0.5) {
|
||||
if (albedo.a < 0.51) discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
gl_FragData[0] = clamp(albedo0, vec4(0.0), vec4(1.0));
|
||||
|
||||
#if defined COLORED_SHADOWS && defined OVERWORLD
|
||||
vec4 albedoCS = albedo;
|
||||
albedoCS.rgb *= 1.0 - albedo.a * albedo.a;
|
||||
|
||||
#if defined PROJECTED_CAUSTICS && defined OVERWORLD
|
||||
if (ice > 0.5) albedoCS = (albedo * albedo) * (albedo * albedo);
|
||||
#else
|
||||
if (ice > 0.5) albedoCS = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
gl_FragData[1] = clamp(albedoCS, vec4(0.0), vec4(1.0));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
uniform float rainStrengthS;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 shadowProjection, shadowProjectionInverse;
|
||||
uniform mat4 shadowModelView, shadowModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
#if WORLD_TIME_ANIMATION < 2
|
||||
uniform float frameTimeCounter;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#if WORLD_TIME_ANIMATION >= 2
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
vec2 lmCoord = vec2(0.0);
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
color = gl_Color;
|
||||
|
||||
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, 0.0, 1.0);
|
||||
|
||||
position = shadowModelViewInverse * shadowProjectionInverse * ftransform();
|
||||
|
||||
mat = 0;
|
||||
if (mc_Entity.x == 79) mat = 1; //premult
|
||||
if (mc_Entity.x == 7979) mat = 3; //ice
|
||||
if (mc_Entity.x == 8) { //water
|
||||
#ifdef WATER_DISPLACEMENT
|
||||
position.y += WavingWater(position.xyz, lmCoord.y);
|
||||
#endif
|
||||
mat = 2;
|
||||
}
|
||||
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
position.xyz += WavingBlocks(position.xyz, istopv, lmCoord.y);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = shadowProjection * shadowModelView * position;
|
||||
|
||||
float dist = sqrt(gl_Position.x * gl_Position.x + gl_Position.y * gl_Position.y);
|
||||
float distortFactor = dist * shadowMapBias + (1.0 - shadowMapBias);
|
||||
|
||||
if (mc_Entity.x == 31 || mc_Entity.x == 6 || mc_Entity.x == 59 ||
|
||||
mc_Entity.x == 175 || mc_Entity.x == 176 || mc_Entity.x == 83 ||
|
||||
mc_Entity.x == 104 || mc_Entity.x == 105 || mc_Entity.x == 11019) { // Foliage
|
||||
#if !defined NO_FOLIAGE_SHADOWS && SHADOW_SUBSURFACE > 0
|
||||
// Counter Shadow Bias
|
||||
#ifdef OVERWORLD
|
||||
float timeAngleM = timeAngle;
|
||||
#else
|
||||
#if !defined SEVEN && !defined SEVEN_2
|
||||
float timeAngleM = 0.25;
|
||||
#else
|
||||
float timeAngleM = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngleM - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
vec3 sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
#ifdef OVERWORLD
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
#else
|
||||
vec3 lightVec = sunVec;
|
||||
#endif
|
||||
vec3 upVec = normalize(gbufferModelView[1].xyz);
|
||||
float NdotLm = clamp(dot(upVec, lightVec) * 1.01 - 0.01, 0.0, 1.0) * 0.99 + 0.01;
|
||||
|
||||
float distortBias = distortFactor * shadowDistance / 256.0;
|
||||
distortBias *= 8.0 * distortBias;
|
||||
float biasFactor = sqrt(1.0 - NdotLm * NdotLm) / NdotLm;
|
||||
float bias = (distortBias * biasFactor + 0.05) / shadowMapResolution;
|
||||
|
||||
#if PIXEL_SHADOWS > 0
|
||||
bias += 0.0025 / PIXEL_SHADOWS;
|
||||
#endif
|
||||
gl_Position.z -= bias * 11.0;
|
||||
#else
|
||||
mat = 4;
|
||||
#endif
|
||||
}
|
||||
|
||||
gl_Position.xy *= 1.0 / distortFactor;
|
||||
gl_Position.z = gl_Position.z * 0.2;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Complementary Shaders by EminGT, based on BSL Shaders by Capt Tatsu
|
||||
*/
|
||||
|
||||
//Common//
|
||||
#include "/lib/common.glsl"
|
||||
|
||||
//Varyings//
|
||||
|
||||
//////////Fragment Shader//////////Fragment Shader//////////Fragment Shader//////////
|
||||
#ifdef FSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
//Optifine Constants//
|
||||
|
||||
//Common Variables//
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////Vertex Shader//////////Vertex Shader//////////Vertex Shader//////////
|
||||
#ifdef VSH
|
||||
|
||||
//Uniforms//
|
||||
|
||||
//Attributes//
|
||||
|
||||
//Common Variables//
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user