first commit
This commit is contained in:
commit
0f859671ea
308 files changed
+18617
No files matched your search
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float darknessLightFactor;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
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_SHAFT
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#if REFRACTION > 0
|
||||
uniform sampler2D colortex6;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
uniform sampler2D gaux1;
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
uniform float dhFarPlane;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex5Clear = false;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
const bool colortex9Clear = false;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot(sunVec, upVec) + 0.05, 0.0, 0.1) * 10.0;
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#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 MULTICOLORED_BLOCKLIGHT
|
||||
vec2 Reprojection(vec3 pos) {
|
||||
pos = pos * 2.0 - 1.0;
|
||||
|
||||
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
|
||||
viewPosPrev /= viewPosPrev.w;
|
||||
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
|
||||
|
||||
vec3 cameraOffset = cameraPosition - previousCameraPosition;
|
||||
cameraOffset *= float(pos.z > 0.56);
|
||||
|
||||
vec4 previousPosition = viewPosPrev + vec4(cameraOffset, 0.0);
|
||||
previousPosition = gbufferPreviousModelView * previousPosition;
|
||||
previousPosition = gbufferPreviousProjection * previousPosition;
|
||||
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec2 OffsetDist(float x) {
|
||||
float n = fract(x * 8.0) * 6.283;
|
||||
return vec2(cos(n), sin(n)) * x * x;
|
||||
}
|
||||
|
||||
vec3 GetMultiColoredBlocklight(vec2 coord, float z, float dither) {
|
||||
vec2 prevCoord = Reprojection(vec3(coord, z));
|
||||
float lz = GetLinearDepth(z);
|
||||
|
||||
float distScale = clamp((far - near) * lz + near, 4.0, 128.0);
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
|
||||
vec2 blurstr = vec2(1.0 / aspectRatio, 1.0) * 2.5 * fovScale / distScale;
|
||||
|
||||
vec3 lightAlbedo = texture2D(colortex8, coord).rgb;
|
||||
vec3 previousColoredLight = vec3(0.0);
|
||||
|
||||
#ifdef MCBL_ANTI_BLEED
|
||||
float linearZ = GetLinearDepth(z);
|
||||
#endif
|
||||
|
||||
float mask = clamp(2.0 - 2.0 * max(abs(prevCoord.x - 0.5), abs(prevCoord.y - 0.5)), 0.0, 1.0);
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
vec2 offset = OffsetDist((dither + i) * 0.25) * blurstr;
|
||||
offset = floor(offset * vec2(viewWidth, viewHeight) + 0.5) / vec2(viewWidth, viewHeight);
|
||||
|
||||
#ifdef MCBL_ANTI_BLEED
|
||||
vec2 sampleZPos = coord + offset;
|
||||
float sampleZ0 = texture2D(depthtex0, sampleZPos).r;
|
||||
float sampleZ1 = texture2D(depthtex1, sampleZPos).r;
|
||||
float linearSampleZ = GetLinearDepth(sampleZ1 >= 1.0 ? sampleZ0 : sampleZ1);
|
||||
|
||||
float sampleWeight = clamp(abs(linearZ - linearSampleZ) * far / 16.0, 0.0, 1.0);
|
||||
sampleWeight = 1.0 - sampleWeight * sampleWeight;
|
||||
#else
|
||||
float sampleWeight = 1.0;
|
||||
#endif
|
||||
|
||||
previousColoredLight += texture2D(colortex9, prevCoord.xy + offset).rgb * sampleWeight;
|
||||
}
|
||||
|
||||
previousColoredLight *= 0.25;
|
||||
previousColoredLight *= previousColoredLight * mask;
|
||||
|
||||
return sqrt(mix(previousColoredLight, lightAlbedo * lightAlbedo / 0.1, 0.1));
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/atmospherics/waterFog.glsl"
|
||||
|
||||
#ifdef LIGHT_SHAFT
|
||||
#include "/lib/atmospherics/volumetricLight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/util/outlineOffset.glsl"
|
||||
#include "/lib/util/outlineDepth.glsl"
|
||||
#include "/lib/util/outlineMask.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#include "/lib/post/outline.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0, texCoord);
|
||||
vec3 translucent = texture2D(colortex1,texCoord).rgb;
|
||||
float z0 = texture2D(depthtex0, texCoord).r;
|
||||
float z1 = texture2D(depthtex1, texCoord).r;
|
||||
|
||||
vec4 screenPos = vec4(texCoord.x, texCoord.y, z0, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
#if REFRACTION > 0
|
||||
if (z1 > z0) {
|
||||
vec3 distort = texture2D(colortex6, texCoord).xyz;
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
distort.xy = distort.xy * 2.0 - 1.0;
|
||||
distort.xy *= vec2(1.0 / aspectRatio, 1.0) * fovScale / max(length(viewPos.xyz), 8.0);
|
||||
|
||||
vec2 newCoord = texCoord + distort.xy;
|
||||
#if MC_VERSION > 10800
|
||||
float distortMask = texture2D(colortex6, newCoord).b * distort.b;
|
||||
#else
|
||||
float distortMask = texture2DLod(colortex6, newCoord, 0).b * distort.b;
|
||||
#endif
|
||||
|
||||
if (distortMask == 1.0 && z0 > 0.56) {
|
||||
z0 = texture2D(depthtex0, newCoord).r;
|
||||
z1 = texture2D(depthtex1, newCoord).r;
|
||||
#if MC_VERSION > 10800
|
||||
color.rgb = texture2D(colortex0, newCoord).rgb;
|
||||
#else
|
||||
color.rgb = texture2DLod(colortex0, newCoord, 0).rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
screenPos = vec4(newCoord.x, newCoord.y, z0, 1.0);
|
||||
viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
color.rgb *= color.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
vec4 outerOutline = vec4(0.0), innerOutline = vec4(0.0);
|
||||
float outlineMask = GetOutlineMask();
|
||||
if (outlineMask > 0.5 || isEyeInWater > 0.5)
|
||||
Outline(color.rgb, true, outerOutline, innerOutline);
|
||||
|
||||
if(z1 > z0) {
|
||||
float worldDistance = length(viewPos.xyz) / far;
|
||||
float distantFade = 1.0 - smoothstep(0.6, 1.1, worldDistance);
|
||||
innerOutline.a *= distantFade;
|
||||
|
||||
color.rgb = mix(color.rgb, innerOutline.rgb, innerOutline.a);
|
||||
}
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
float outlineZ = z0;
|
||||
DepthOutline(outlineZ, depthtex0);
|
||||
|
||||
vec4 outlineViewPos = gbufferProjectionInverse * (vec4(texCoord, outlineZ, 1.0) * 2.0 - 1.0);
|
||||
outlineViewPos /= outlineViewPos.w;
|
||||
|
||||
float outlineViewLength = length(outlineViewPos.xyz);
|
||||
float cloudViewLength = texture2D(gaux1, screenPos.xy).r * (far * 2.0);
|
||||
outerOutline.a *= step(outlineViewLength, cloudViewLength);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 1.0) {
|
||||
vec4 waterFog = GetWaterFog(viewPos.xyz);
|
||||
waterFog.a = mix(waterAlpha * 0.5, 1.0, waterFog.a);
|
||||
color.rgb = mix(sqrt(color.rgb), sqrt(waterFog.rgb), waterFog.a);
|
||||
color.rgb *= color.rgb;
|
||||
}
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
color.rgb = mix(color.rgb, outerOutline.rgb, outerOutline.a);
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_SHAFT
|
||||
float blueNoise = texture2D(noisetex, gl_FragCoord.xy / 512.0).b;
|
||||
vec3 vl = GetLightShafts(z0, z1, translucent, blueNoise);
|
||||
#else
|
||||
vec3 vl = vec3(0.0);
|
||||
#endif
|
||||
|
||||
color.rgb *= clamp(1.0 - 2.0 * darknessLightFactor, 0.0, 1.0);
|
||||
|
||||
vec3 reflectionColor = pow(color.rgb, vec3(0.125)) * 0.5;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
float lightZ = z1 >= 1.0 ? z0 : z1;
|
||||
vec3 coloredLight = GetMultiColoredBlocklight(texCoord, lightZ, dither);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:01*/
|
||||
gl_FragData[0] = color;
|
||||
gl_FragData[1] = vec4(vl, 1.0);
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/*DRAWBUFFERS:019*/
|
||||
gl_FragData[2] = vec4(coloredLight, 1.0);
|
||||
|
||||
#ifdef REFLECTION_PREVIOUS
|
||||
/*DRAWBUFFERS:0195*/
|
||||
gl_FragData[3] = vec4(reflectionColor, float(z0 < 1.0));
|
||||
#endif
|
||||
#else
|
||||
#ifdef REFLECTION_PREVIOUS
|
||||
/*DRAWBUFFERS:015*/
|
||||
gl_FragData[2] = vec4(reflectionColor, float(z0 < 1.0));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//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(timeAngle - 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,102 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor;
|
||||
uniform float rainStrength;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot(sunVec, upVec) + 0.05, 0.0, 0.1) * 10.0;
|
||||
|
||||
vec2 vlOffsets[4] = vec2[4](
|
||||
vec2( 1.5, 0.5),
|
||||
vec2(-0.5, 1.5),
|
||||
vec2(-1.5, -0.5),
|
||||
vec2( 0.5, -1.5)
|
||||
);
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0, texCoord.xy);
|
||||
|
||||
vec3 vl = texture2D(colortex1, texCoord.xy + vlOffsets[0] / vec2(viewWidth, viewHeight)).rgb;
|
||||
vl+= texture2D(colortex1, texCoord.xy + vlOffsets[1] / vec2(viewWidth, viewHeight)).rgb;
|
||||
vl+= texture2D(colortex1, texCoord.xy + vlOffsets[2] / vec2(viewWidth, viewHeight)).rgb;
|
||||
vl+= texture2D(colortex1, texCoord.xy + vlOffsets[3] / vec2(viewWidth, viewHeight)).rgb;
|
||||
vl*= vl * 0.0625;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vl *= lightCol * 0.25;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
vl *= endCol.rgb * 0.1;
|
||||
#endif
|
||||
|
||||
vl *= LIGHT_SHAFT_STRENGTH * (1.0 - rainStrength * eBS * 0.875) * shadowFade *
|
||||
(1.0 - max(blindFactor, darknessFactor));
|
||||
|
||||
color.rgb += vl;
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = color;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//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(timeAngle - 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,109 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//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 * (1.5 + dither);
|
||||
for(int i = 0; i < 5; i++, coord += velocity) {
|
||||
vec2 sampleCoord = clamp(coord, doublePixel, 1.0 - doublePixel);
|
||||
float mask = float(texture2D(depthtex1, sampleCoord).r > 0.56);
|
||||
mblur += texture2DLod(colortex0, sampleCoord, 0.0).rgb * mask;
|
||||
mbwg += mask;
|
||||
}
|
||||
mblur /= max(mbwg, 1.0);
|
||||
|
||||
return mblur;
|
||||
}
|
||||
else return color;
|
||||
}
|
||||
|
||||
|
||||
//Includes//
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
#include "/lib/util/outlineOffset.glsl"
|
||||
#include "/lib/util/outlineDepth.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2DLod(colortex0, texCoord, 0.0).rgb;
|
||||
|
||||
#ifdef MOTION_BLUR
|
||||
float z = texture2D(depthtex1, texCoord.st).x;
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
DepthOutline(z, depthtex1);
|
||||
#endif
|
||||
|
||||
color = MotionBlur(color, z, dither);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = vec4(color,1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
uniform float centerDepthSmooth;
|
||||
|
||||
uniform mat4 gbufferProjection;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
|
||||
//Common Variables//
|
||||
vec2 dofOffsets[60] = vec2[60](
|
||||
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 ),
|
||||
vec2( 0 , 0.75 ),
|
||||
vec2(-0.2565 , 0.7048),
|
||||
vec2(-0.4821 , 0.5745),
|
||||
vec2(-0.51295, 0.375 ),
|
||||
vec2(-0.7386 , 0.1302),
|
||||
vec2(-0.7386 , -0.1302),
|
||||
vec2(-0.51295, -0.375 ),
|
||||
vec2(-0.4821 , -0.5745),
|
||||
vec2(-0.2565 , -0.7048),
|
||||
vec2(-0 , -0.75 ),
|
||||
vec2( 0.2565 , -0.7048),
|
||||
vec2( 0.4821 , -0.5745),
|
||||
vec2( 0.51295, -0.375 ),
|
||||
vec2( 0.7386 , -0.1302),
|
||||
vec2( 0.7386 , 0.1302),
|
||||
vec2( 0.51295, 0.375 ),
|
||||
vec2( 0.4821 , 0.5745),
|
||||
vec2( 0.2565 , 0.7048),
|
||||
vec2( 0 , 1 ),
|
||||
vec2(-0.2588 , 0.9659),
|
||||
vec2(-0.5 , 0.866 ),
|
||||
vec2(-0.7071 , 0.7071),
|
||||
vec2(-0.866 , 0.5 ),
|
||||
vec2(-0.9659 , 0.2588),
|
||||
vec2(-1 , 0 ),
|
||||
vec2(-0.9659 , -0.2588),
|
||||
vec2(-0.866 , -0.5 ),
|
||||
vec2(-0.7071 , -0.7071),
|
||||
vec2(-0.5 , -0.866 ),
|
||||
vec2(-0.2588 , -0.9659),
|
||||
vec2(-0 , -1 ),
|
||||
vec2( 0.2588 , -0.9659),
|
||||
vec2( 0.5 , -0.866 ),
|
||||
vec2( 0.7071 , -0.7071),
|
||||
vec2( 0.866 , -0.5 ),
|
||||
vec2( 0.9659 , -0.2588),
|
||||
vec2( 1 , 0 ),
|
||||
vec2( 0.9659 , 0.2588),
|
||||
vec2( 0.866 , 0.5 ),
|
||||
vec2( 0.7071 , 0.7071),
|
||||
vec2( 0.5 , 0.8660),
|
||||
vec2( 0.2588 , 0.9659)
|
||||
);
|
||||
|
||||
//Common Functions//
|
||||
vec3 DepthOfField(vec3 color, float z) {
|
||||
vec3 dof = vec3(0.0);
|
||||
float hand = float(z < 0.56);
|
||||
|
||||
float fovScale = gbufferProjection[1][1] / 1.37;
|
||||
float coc = max(abs(z - centerDepthSmooth) * DOF_STRENGTH - 0.01, 0.0);
|
||||
coc = coc / sqrt(coc * coc + 0.1);
|
||||
|
||||
if (coc > 0.0 && hand < 0.5) {
|
||||
for(int i = 0; i < 60; i++) {
|
||||
vec2 offset = dofOffsets[i] * coc * 0.015 * fovScale * vec2(1.0 / aspectRatio, 1.0);
|
||||
float lod = log2(viewHeight * aspectRatio * coc * fovScale / 320.0);
|
||||
dof += texture2DLod(colortex0, texCoord + offset, lod).rgb;
|
||||
}
|
||||
dof /= 60.0;
|
||||
}
|
||||
else dof = color;
|
||||
return dof;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#ifdef OUTLINE_OUTER
|
||||
#include "/lib/util/outlineOffset.glsl"
|
||||
#include "/lib/util/outlineDepth.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2DLod(colortex0, texCoord, 0.0).rgb;
|
||||
|
||||
#ifdef DOF
|
||||
float z = texture2D(depthtex1, texCoord.st).x;
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
DepthOutline(z, depthtex1);
|
||||
#endif
|
||||
|
||||
color = DepthOfField(color, z);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:0*/
|
||||
gl_FragData[0] = vec4(color,1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
|
||||
//Common Variables//
|
||||
float ph = 0.8 / min(360.0, viewHeight);
|
||||
float pw = ph / aspectRatio;
|
||||
vec2 view = vec2(1.0 / viewWidth, 1.0 / viewHeight);
|
||||
|
||||
float weight[6] = float[6](0.0556, 0.1667, 0.2777, 0.2777, 0.1667, 0.0556);
|
||||
|
||||
//Common Functions//
|
||||
vec3 BloomTile(float lod, vec2 coord, vec2 offset) {
|
||||
vec3 bloom = vec3(0.0), temp = vec3(0.0);
|
||||
float scale = exp2(lod);
|
||||
coord = (coord - offset) * scale;
|
||||
vec2 padding = vec2(0.5) + 2.0 * view * scale;
|
||||
|
||||
if (abs(coord.x - 0.5) < padding.x && abs(coord.y - 0.5) < padding.y) {
|
||||
for(int i = 0; i < 6; i++) {
|
||||
for(int j = 0; j < 6; j++) {
|
||||
float wg = weight[i] * weight[j];
|
||||
vec2 pixelOffset = vec2((float(i) - 2.5) * pw, (float(j) - 2.5) * ph);
|
||||
vec2 sampleCoord = coord + pixelOffset * scale;
|
||||
bloom += texture2D(colortex0, sampleCoord).rgb * wg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bloom;
|
||||
}
|
||||
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec2 bloomCoord = texCoord * viewHeight * 0.8 / min(360.0, viewHeight);
|
||||
vec3 blur = BloomTile(1.0, bloomCoord, vec2(0.0 , 0.0 ));
|
||||
blur += BloomTile(2.0, bloomCoord, vec2(0.50 , 0.0 ) + vec2( 4.0, 0.0) * view);
|
||||
blur += BloomTile(3.0, bloomCoord, vec2(0.50 , 0.25 ) + vec2( 4.0, 4.0) * view);
|
||||
blur += BloomTile(4.0, bloomCoord, vec2(0.625 , 0.25 ) + vec2( 8.0, 4.0) * view);
|
||||
blur += BloomTile(5.0, bloomCoord, vec2(0.6875 , 0.25 ) + vec2(12.0, 4.0) * view);
|
||||
blur += BloomTile(6.0, bloomCoord, vec2(0.625 , 0.3125) + vec2( 8.0, 8.0) * view);
|
||||
blur += BloomTile(7.0, bloomCoord, vec2(0.640625 , 0.3125) + vec2(12.0, 8.0) * view);
|
||||
|
||||
blur = pow(blur / 32.0, vec3(0.25));
|
||||
|
||||
blur = clamp(blur + (Bayer8(gl_FragCoord.xy) - 0.5) / 384.0, vec3(0.0), vec3(1.0));
|
||||
|
||||
/* DRAWBUFFERS:1 */
|
||||
gl_FragData[0] = vec4(blur, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
#ifdef DIRTY_LENS
|
||||
uniform sampler2D depthtex2;
|
||||
#endif
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
uniform vec3 sunPosition;
|
||||
uniform mat4 gbufferProjection;
|
||||
#endif
|
||||
|
||||
#ifdef UNDERGROUND_SKY
|
||||
uniform vec3 cameraPosition;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
const bool colortex2Clear = false;
|
||||
|
||||
#ifdef AUTO_EXPOSURE
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
const bool colortex9MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 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;
|
||||
|
||||
texCoord += vec2(
|
||||
cos(texCoord.y * 32.0 + frameTimeCounter * 3.0),
|
||||
sin(texCoord.x * 32.0 + frameTimeCounter * 1.7)
|
||||
) * 0.0005;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void RetroDither(inout vec3 color, float dither) {
|
||||
color.rgb = pow(color.rgb, vec3(0.25));
|
||||
float lenColor = length(color);
|
||||
vec3 normColor = color / lenColor;
|
||||
|
||||
dither = mix(dither, 0.5, exp(-2.0 * lenColor)) - 0.25;
|
||||
color = normColor * floor(lenColor * 16.0 + dither * 1.7) / 16.0;
|
||||
|
||||
color = max(pow(color.rgb, vec3(4.0)), vec3(0.0));
|
||||
}
|
||||
|
||||
vec3 GetBloomTile(float lod, vec2 coord, vec2 offset) {
|
||||
float scale = exp2(lod);
|
||||
float resScale = 1.25 * min(360.0, viewHeight) / viewHeight;
|
||||
vec3 bloom = texture2D(colortex1, (coord / scale + offset) * resScale).rgb;
|
||||
bloom *= bloom; bloom *= bloom * 32.0;
|
||||
return bloom;
|
||||
}
|
||||
|
||||
void Bloom(inout vec3 color, vec2 coord) {
|
||||
vec2 view = vec2(1.0 / viewWidth, 1.0 / viewHeight);
|
||||
vec3 blur1 = GetBloomTile(1.0, coord, vec2(0.0 , 0.0 ) + vec2( 0.5, 0.0) * view);
|
||||
vec3 blur2 = GetBloomTile(2.0, coord, vec2(0.50 , 0.0 ) + vec2( 4.5, 0.0) * view);
|
||||
vec3 blur3 = GetBloomTile(3.0, coord, vec2(0.50 , 0.25 ) + vec2( 4.5, 4.0) * view);
|
||||
vec3 blur4 = GetBloomTile(4.0, coord, vec2(0.625 , 0.25 ) + vec2( 8.5, 4.0) * view);
|
||||
vec3 blur5 = GetBloomTile(5.0, coord, vec2(0.6875 , 0.25 ) + vec2(12.5, 4.0) * view);
|
||||
vec3 blur6 = GetBloomTile(6.0, coord, vec2(0.625 , 0.3125) + vec2( 8.5, 8.0) * view);
|
||||
vec3 blur7 = GetBloomTile(7.0, coord, vec2(0.640625 , 0.3125) + vec2(12.5, 8.0) * view);
|
||||
|
||||
#ifdef DIRTY_LENS
|
||||
float newAspectRatio = 1.777777777777778 / aspectRatio;
|
||||
vec2 scale = vec2(max(newAspectRatio, 1.0), max(1.0 / newAspectRatio, 1.0));
|
||||
float dirt = texture2D(depthtex2, (coord - 0.5) / scale + 0.5).r;
|
||||
dirt *= length(blur6 / (1.0 + blur6));
|
||||
blur3 *= dirt * 2.0 + 1.0;
|
||||
blur4 *= dirt * 4.0 + 1.0;
|
||||
blur5 *= dirt * 8.0 + 1.0;
|
||||
blur6 *= dirt * 16.0 + 1.0;
|
||||
blur7 *= dirt * 32.0 + 1.0;
|
||||
#endif
|
||||
|
||||
#if BLOOM_RADIUS == 1
|
||||
vec3 blur = blur1;
|
||||
#elif BLOOM_RADIUS == 2
|
||||
vec3 blur = (blur1 * 1.23 + blur2) / 2.23;
|
||||
#elif BLOOM_RADIUS == 3
|
||||
vec3 blur = (blur1 * 1.71 + blur2 * 1.52 + blur3) / 4.23;
|
||||
#elif BLOOM_RADIUS == 4
|
||||
vec3 blur = (blur1 * 2.46 + blur2 * 2.25 + blur3 * 1.71 + blur4) / 7.42;
|
||||
#elif BLOOM_RADIUS == 5
|
||||
vec3 blur = (blur1 * 3.58 + blur2 * 3.35 + blur3 * 2.72 + blur4 * 1.87 + blur5) / 12.52;
|
||||
#elif BLOOM_RADIUS == 6
|
||||
vec3 blur = (blur1 * 5.25 + blur2 * 4.97 + blur3 * 4.20 + blur4 * 3.13 + blur5 * 2.00 + blur6) / 20.55;
|
||||
#elif BLOOM_RADIUS == 7
|
||||
vec3 blur = (blur1 * 7.76 + blur2 * 7.41 + blur3 * 6.43 + blur4 * 5.04 + blur5 * 3.51 + blur6 * 2.11 + blur7) / 33.26;
|
||||
#endif
|
||||
|
||||
#if BLOOM_CONTRAST == 0
|
||||
color = mix(color, blur, 0.2 * BLOOM_STRENGTH);
|
||||
#else
|
||||
vec3 bloomContrast = vec3(exp2(BLOOM_CONTRAST * 0.25));
|
||||
color = pow(color, bloomContrast);
|
||||
blur = pow(blur, bloomContrast);
|
||||
vec3 bloomStrength = pow(vec3(0.2 * BLOOM_STRENGTH), bloomContrast);
|
||||
color = mix(color, blur, bloomStrength);
|
||||
color = pow(color, 1.0 / bloomContrast);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void AutoExposure(inout vec3 color, inout float exposure, float tempExposure) {
|
||||
float exposureLod = log2(viewHeight * AUTO_EXPOSURE_RADIUS);
|
||||
|
||||
exposure = length(texture2DLod(colortex0, vec2(0.5), exposureLod).rgb);
|
||||
exposure = max(exposure, 0.0001);
|
||||
|
||||
color /= 2.0 * tempExposure + 0.125;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
vec3 RGB2HSV(vec3 c){
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 HSV2RGB(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
void Notorious6Test(inout vec3 color) {
|
||||
vec2 testCoord = texCoord * vec2(8.0,6.0) - vec2(3.5, 1.0);
|
||||
|
||||
// if (testCoord.x > 0 && testCoord.x < 1 && testCoord.y > 0 && testCoord.y < 1){
|
||||
// float h = floor((1.0 - testCoord.y) * 18.0) / 18.0;
|
||||
|
||||
// color = pow(HSV2RGB(vec3(h, 1.0, 1.0)), vec3(2.2));
|
||||
// color *= exp2(floor(testCoord.x * 20.0) - 10.0);
|
||||
|
||||
// color /= exp2(2.0 + EXPOSURE);
|
||||
// }
|
||||
|
||||
if (testCoord.x > -2 && testCoord.x < 3 && testCoord.y > 0 && testCoord.y < 1){
|
||||
float h = floor((1.0 - testCoord.y) * 18.0) / 18.0;
|
||||
float s = pow(floor(testCoord.x) * 0.25 + 0.5, 0.5);
|
||||
|
||||
color = pow(HSV2RGB(vec3(h, s, 1.0)), vec3(2.2));
|
||||
color *= exp2(floor(fract(testCoord.x) * 20.0) - 10.0);
|
||||
|
||||
color /= exp2(2.0 + EXPOSURE);
|
||||
}
|
||||
}
|
||||
|
||||
mat3 inverseMatrix(mat3 m) {
|
||||
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
|
||||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
|
||||
|
||||
float b01 = a22 * a11 - a12 * a21;
|
||||
float b11 = -a22 * a10 + a12 * a20;
|
||||
float b21 = a21 * a10 - a11 * a20;
|
||||
|
||||
float det = a00 * b01 + a01 * b11 + a02 * b21;
|
||||
|
||||
return mat3(
|
||||
b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
|
||||
b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
|
||||
b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)
|
||||
) / det;
|
||||
}
|
||||
|
||||
void BSLTonemap(inout vec3 color) {
|
||||
color *= exp2(2.0 + EXPOSURE);
|
||||
|
||||
float s = TONEMAP_WHITE_PATH;
|
||||
|
||||
float a = 0.03 * s;
|
||||
float b = 0.01 * s;
|
||||
float c = 1.0 - (a + b);
|
||||
float d = 1.0 - (a + a);
|
||||
|
||||
mat3 desatMatrix = mat3(
|
||||
vec3(c, a, b),
|
||||
vec3(a, d, a),
|
||||
vec3(b, a, c)
|
||||
);
|
||||
|
||||
mat3 satMatrix = inverseMatrix(desatMatrix);
|
||||
|
||||
color *= desatMatrix;
|
||||
|
||||
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)));
|
||||
|
||||
color *= satMatrix;
|
||||
|
||||
color = clamp(color, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
void ColorSaturation(inout vec3 color) {
|
||||
float grayVibrance = (color.r + color.g + color.b) / 3.0;
|
||||
float 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 RETRO_FILTER
|
||||
#include "/lib/util/dither.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec2 newTexCoord = texCoord;
|
||||
|
||||
#ifdef UNDERWATER_DISTORTION
|
||||
if (isEyeInWater == 1.0) UnderwaterDistort(newTexCoord);
|
||||
#endif
|
||||
|
||||
vec3 color = texture2D(colortex0, newTexCoord).rgb;
|
||||
|
||||
#ifdef AUTO_EXPOSURE
|
||||
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);
|
||||
#ifdef TAA
|
||||
temporalColor = texture2D(colortex2, texCoord).gba;
|
||||
#endif
|
||||
|
||||
#ifdef RETRO_FILTER
|
||||
float dither = Bayer8(gl_FragCoord.xy / RETRO_FILTER_SIZE);
|
||||
RetroDither(color.rgb, dither);
|
||||
#endif
|
||||
|
||||
#ifdef BLOOM
|
||||
Bloom(color, newTexCoord);
|
||||
#endif
|
||||
|
||||
#ifdef AUTO_EXPOSURE
|
||||
float exposure = 1.0;
|
||||
AutoExposure(color, exposure, tempExposure);
|
||||
#endif
|
||||
|
||||
// Notorious6Test(color);
|
||||
|
||||
#ifdef COLOR_GRADING
|
||||
ColorGrading(color);
|
||||
#endif
|
||||
|
||||
#ifdef VIGNETTE
|
||||
float screenDist = length(texCoord - 0.5);
|
||||
screenDist *= screenDist * 0.3535 + 0.75;
|
||||
color *= 1.0 - screenDist * VIGNETTE_STRENGTH;
|
||||
#endif
|
||||
|
||||
BSLTonemap(color);
|
||||
|
||||
#ifdef LENS_FLARE
|
||||
vec2 lightPos = GetLightPos();
|
||||
float truePos = sign(sunVec.z);
|
||||
|
||||
float visibleSun = float(texture2D(depthtex0, lightPos + 0.5).r >= 1.0);
|
||||
visibleSun *= max(1.0 - isEyeInWater, eBS) * (1.0 - max(blindFactor, darknessFactor)) * (1.0 - rainStrength);
|
||||
|
||||
#ifdef UNDERGROUND_SKY
|
||||
visibleSun *= mix(clamp((cameraPosition.y - 48.0) / 16.0, 0.0, 1.0), 1.0, eBS);
|
||||
#endif
|
||||
|
||||
float multiplier = tempVisibleSun * LENS_FLARE_STRENGTH * (length(color) * 0.25 + 0.25);
|
||||
|
||||
if (multiplier > 0.001) LensFlare(color, lightPos, truePos, multiplier);
|
||||
#endif
|
||||
|
||||
float temporalData = 0.0;
|
||||
|
||||
#ifdef AUTO_EXPOSURE
|
||||
if (texCoord.x < 2.0 * pw && texCoord.y < 2.0 * ph)
|
||||
temporalData = mix(tempExposure, sqrt(exposure), AUTO_EXPOSURE_SPEED);
|
||||
#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.125);
|
||||
#endif
|
||||
|
||||
color = pow(color, vec3(1.0 / 2.2));
|
||||
|
||||
ColorSaturation(color);
|
||||
|
||||
float filmGrain = texture2D(noisetex, texCoord * vec2(viewWidth, viewHeight) / 512.0).b;
|
||||
color += (filmGrain - 0.5) / 256.0;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
vec3 coloredLight = texture2DLod(colortex9, texCoord.xy, 2).rgb;
|
||||
coloredLight *= 0.99;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:12 */
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
gl_FragData[1] = vec4(temporalData,temporalColor);
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/*DRAWBUFFERS:129*/
|
||||
gl_FragData[2] = vec4(coloredLight, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//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(timeAngle - 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,61 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
//Optifine Constants//
|
||||
#ifdef LIGHT_SHAFT
|
||||
const bool colortex1MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/antialiasing/fxaa.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 color = texture2DLod(colortex1, texCoord, 0.0).rgb;
|
||||
|
||||
#ifdef FXAA
|
||||
color = FXAA311(color);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:1*/
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform vec3 cameraPosition, previousCameraPosition;
|
||||
|
||||
uniform mat4 gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex2;
|
||||
uniform sampler2D depthtex1;
|
||||
|
||||
#ifdef TAA_SELECTIVE
|
||||
uniform sampler2D colortex3;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
#ifdef LIGHT_SHAFT
|
||||
const bool colortex1MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/antialiasing/taa.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec2 newTexCoord = texCoord;
|
||||
#if defined TAA && TAA_MODE == 1
|
||||
vec2 offset = frameCounter % 2 == 0 ? vec2(0.5, 0.0) : vec2(0.0, 0.5);
|
||||
newTexCoord += offset / vec2(viewWidth, viewHeight);
|
||||
#endif
|
||||
|
||||
vec3 color = texture2DLod(colortex1, newTexCoord, 0.0).rgb;
|
||||
vec4 prev = vec4(texture2DLod(colortex2, texCoord, 0).r, 0.0, 0.0, 0.0);
|
||||
|
||||
#ifdef TAA
|
||||
prev = TemporalAA(color, prev.r);
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:12*/
|
||||
gl_FragData[0] = vec4(color, 1.0);
|
||||
gl_FragData[1] = vec4(prev);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform mat4 gbufferProjection;
|
||||
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
uniform float dhFarPlane, dhNearPlane;
|
||||
uniform sampler2D dhDepthTex0;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float GetDHLinearDepth(float depth) {
|
||||
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - depth * (dhFarPlane - dhNearPlane));
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/lighting/ambientOcclusion.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
float blueNoise = texture2D(noisetex, gl_FragCoord.xy / 512.0).b;
|
||||
float ao = AmbientOcclusion(blueNoise);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float z = texture2D(depthtex0, texCoord.xy).r;
|
||||
if (z == 1.0) {
|
||||
ao = DHAmbientOcclusion(blueNoise);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:4 */
|
||||
gl_FragData[0] = vec4(ao, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,545 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjection, gbufferPreviousProjection, gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelView, gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
uniform sampler2D colortex3;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef AO
|
||||
uniform sampler2D colortex4;
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex5;
|
||||
uniform sampler2D colortex6;
|
||||
uniform sampler2D colortex7;
|
||||
// uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
uniform float dhFarPlane, dhNearPlane;
|
||||
|
||||
uniform mat4 dhProjectionInverse;
|
||||
|
||||
uniform sampler2D dhDepthTex0;
|
||||
#endif
|
||||
|
||||
//Optifine Constants//
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
const bool colortex0MipmapEnabled = true;
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
const bool colortex6MipmapEnabled = true;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
vec2 aoSampleOffsets[4] = vec2[4](
|
||||
vec2( 1.5, 0.5),
|
||||
vec2(-0.5, 1.5),
|
||||
vec2(-1.5, -0.5),
|
||||
vec2( 0.5, -1.5)
|
||||
);
|
||||
|
||||
vec2 aoDepthOffsets[4] = vec2[4](
|
||||
vec2( 2.0, 1.0),
|
||||
vec2(-1.0, 2.0),
|
||||
vec2(-2.0, -1.0),
|
||||
vec2( 1.0, -2.0)
|
||||
);
|
||||
|
||||
vec2 glowOffsets[16] = vec2[16](
|
||||
vec2( 0.0, -1.0),
|
||||
vec2(-1.0, 0.0),
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0, 1.0),
|
||||
vec2(-1.0, -2.0),
|
||||
vec2( 0.0, -2.0),
|
||||
vec2( 1.0, -2.0),
|
||||
vec2(-2.0, -1.0),
|
||||
vec2( 2.0, -1.0),
|
||||
vec2(-2.0, 0.0),
|
||||
vec2( 2.0, 0.0),
|
||||
vec2(-2.0, 1.0),
|
||||
vec2( 2.0, 1.0),
|
||||
vec2(-1.0, 2.0),
|
||||
vec2( 0.0, 2.0),
|
||||
vec2( 1.0, 2.0)
|
||||
);
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
vec3 moonPhaseVecs[8] = vec3[8](
|
||||
vec3( 0.0 , 0.0 , 1.0 ),
|
||||
vec3( 0.0 , -0.89, 0.45),
|
||||
vec3( 0.0 , -1.0 , 0.0 ),
|
||||
vec3( 0.0 , -0.45, -0.89),
|
||||
vec3( 0.0 , 0.0 , -1.0 ),
|
||||
vec3( 0.0 , 0.45, -0.89),
|
||||
vec3( 0.0 , 1.0 , 0.0 ),
|
||||
vec3( 0.0 , 0.89, 0.45)
|
||||
);
|
||||
|
||||
vec2 moonDiffuse[8] = vec2[8](
|
||||
vec2( 0.0 , 0.0 ),
|
||||
vec2(-0.125, 1.0 ),
|
||||
vec2(-0.2 , 0.625),
|
||||
vec2(-0.8 , 0.375),
|
||||
vec2(-0.75 , -0.25 ),
|
||||
vec2(-0.8 , 0.375),
|
||||
vec2(-0.2 , 0.625),
|
||||
vec2(-0.125, 1.0 )
|
||||
);
|
||||
|
||||
//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
|
||||
float GetAmbientOcclusion(float z){
|
||||
float ao = 0.0;
|
||||
float tw = 0.0;
|
||||
float lz = GetLinearDepth(z);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
vec2 sampleOffset = aoSampleOffsets[i] / vec2(viewWidth, viewHeight);
|
||||
vec2 depthOffset = aoDepthOffsets[i] / vec2(viewWidth, viewHeight);
|
||||
float samplez = GetLinearDepth(texture2D(depthtex0, texCoord + depthOffset).r);
|
||||
float wg = max(1.0 - 2.0 * far * abs(lz - samplez), 0.00001);
|
||||
ao += texture2D(colortex4, texCoord + sampleOffset).r * wg;
|
||||
tw += wg;
|
||||
}
|
||||
ao /= tw;
|
||||
if(tw < 0.0001) ao = texture2D(colortex4, texCoord).r;
|
||||
|
||||
return pow(ao, AO_STRENGTH);
|
||||
}
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float GetDHLinearDepth(float depth) {
|
||||
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - depth * (dhFarPlane - dhNearPlane));
|
||||
}
|
||||
|
||||
float GetDHAmbientOcclusion(float dhZ){
|
||||
float ao = 0.0;
|
||||
float tw = 0.0;
|
||||
float lz = GetDHLinearDepth(dhZ);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
vec2 sampleOffset = aoSampleOffsets[i] / vec2(viewWidth, viewHeight);
|
||||
vec2 depthOffset = aoDepthOffsets[i] / vec2(viewWidth, viewHeight);
|
||||
float samplez = GetDHLinearDepth(texture2D(dhDepthTex0, texCoord + depthOffset).r);
|
||||
float wg = max(1.0 - 2.0 * far * abs(lz - samplez), 0.00001);
|
||||
ao += texture2D(colortex4, texCoord + sampleOffset).r * wg;
|
||||
tw += wg;
|
||||
}
|
||||
ao /= tw;
|
||||
if(tw < 0.0001) ao = texture2D(colortex4, texCoord).r;
|
||||
|
||||
return pow(ao, AO_STRENGTH + 1.0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void GlowOutline(inout vec3 color){
|
||||
for(int i = 0; i < 16; i++){
|
||||
vec2 glowOffset = glowOffsets[i] / vec2(viewWidth, viewHeight);
|
||||
float glowSample = texture2D(colortex3, texCoord.xy + glowOffset).b;
|
||||
if(glowSample < 0.5){
|
||||
if(i < 4) color.rgb = vec3(0.0);
|
||||
else color.rgb = vec3(0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#include "/lib/atmospherics/clouds.glsl"
|
||||
#include "/lib/atmospherics/sunmoon.glsl"
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
#include "/lib/util/outlineOffset.glsl"
|
||||
#include "/lib/util/outlineDepth.glsl"
|
||||
#include "/lib/atmospherics/waterFog.glsl"
|
||||
#include "/lib/post/outline.glsl"
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && 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
|
||||
|
||||
#ifdef END
|
||||
vec3 GetEndSkyColor(vec3 viewPos) {
|
||||
vec4 worldPos = gbufferModelViewInverse * vec4(viewPos.xyz, 1.0);
|
||||
worldPos.xyz /= worldPos.w;
|
||||
|
||||
worldPos = normalize(worldPos);
|
||||
|
||||
vec3 sky = vec3(0.0);
|
||||
vec3 absWorldPos = abs(worldPos.xyz);
|
||||
float maxViewDir = absWorldPos.x;
|
||||
sky = vec3(worldPos.yz, 0.0);
|
||||
if (absWorldPos.y > maxViewDir) {
|
||||
maxViewDir = absWorldPos.y;
|
||||
sky = vec3(worldPos.xz, 0.0);
|
||||
}
|
||||
if (absWorldPos.z > maxViewDir) {
|
||||
maxViewDir = absWorldPos.z;
|
||||
sky = vec3(worldPos.xy, 0.0);
|
||||
}
|
||||
vec2 skyUV = sky.xy * 2.0;
|
||||
skyUV = (floor(skyUV * 512.0) + 0.5) / 512.0;
|
||||
float noise = texture2D(noisetex, skyUV).b;
|
||||
sky = vec3(1.0) * pow(noise * 0.3 + 0.35, 2.0);
|
||||
sky *= sky;
|
||||
sky *= endCol.rgb * 0.03;
|
||||
return sky;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 color = texture2D(colortex0, texCoord);
|
||||
float z = texture2D(depthtex0, texCoord).r;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float dhZ = texture2D(dhDepthTex0, texCoord).r;
|
||||
#endif
|
||||
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
if (z == 1.0) color.rgb = max(color.rgb - dither / vec3(128.0), vec3(0.0));
|
||||
color.rgb *= color.rgb;
|
||||
#endif
|
||||
|
||||
vec4 screenPos = vec4(texCoord, z, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
vec4 outerOutline = vec4(0.0), innerOutline = vec4(0.0);
|
||||
Outline(color.rgb, false, outerOutline, innerOutline);
|
||||
|
||||
color.rgb = mix(color.rgb, innerOutline.rgb, innerOutline.a);
|
||||
#endif
|
||||
|
||||
if (z < 1.0) {
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
float smoothness = 0.0, skyOcclusion = 0.0;
|
||||
vec3 normal = vec3(0.0), fresnel3 = vec3(0.0);
|
||||
|
||||
GetMaterials(smoothness, skyOcclusion, normal, fresnel3, texCoord);
|
||||
|
||||
if (smoothness > 0.0) {
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
|
||||
float ssrMask = clamp(length(fresnel3) * 400.0 - 1.0, 0.0, 1.0);
|
||||
if(ssrMask > 0.0) reflection = RoughReflection(viewPos.xyz, normal, dither, smoothness);
|
||||
reflection.a *= ssrMask;
|
||||
|
||||
if (reflection.a < 1.0) {
|
||||
#ifdef OVERWORLD
|
||||
vec3 skyRefPos = reflect(normalize(viewPos.xyz), normal);
|
||||
skyReflection = GetSkyColor(skyRefPos, true);
|
||||
|
||||
#ifdef REFLECTION_ROUGH
|
||||
float cloudMixRate = smoothness * smoothness * (3.0 - 2.0 * smoothness);
|
||||
#else
|
||||
float cloudMixRate = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12) * cloudMixRate;
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 1
|
||||
vec4 cloud = DrawCloudSkybox(skyRefPos * 100.0, 1.0, dither, lightCol, ambientCol, false);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a * cloudMixRate);
|
||||
#endif
|
||||
#if CLOUDS == 2
|
||||
vec4 worldPos = gbufferModelViewInverse * vec4(viewPos.xyz, 1.0);
|
||||
worldPos.xyz /= worldPos.w;
|
||||
|
||||
vec3 cameraPos = GetReflectedCameraPos(worldPos.xyz, normal);
|
||||
float cloudViewLength = 0.0;
|
||||
|
||||
vec4 cloud = DrawCloudVolumetric(skyRefPos * 8192.0, cameraPos, 1.0, dither, lightCol, ambientCol, cloudViewLength, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a * cloudMixRate);
|
||||
#endif
|
||||
|
||||
float NoU = clamp(dot(normal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(normal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) +
|
||||
(0.5 - abs(NoE)) * (1.0 - abs(NoU)) * 0.1;
|
||||
vanillaDiffuse *= vanillaDiffuse;
|
||||
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
skyReflection *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
|
||||
skyReflection = mix(vanillaDiffuse * minLightCol, skyReflection, skyOcclusion);
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol.rgb * 0.04;
|
||||
#endif
|
||||
#ifdef END
|
||||
skyReflection = endCol.rgb * 0.025;
|
||||
#endif
|
||||
}
|
||||
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
|
||||
|
||||
color.rgb += reflection.rgb * fresnel3;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef AO
|
||||
color.rgb *= GetAmbientOcclusion(z);
|
||||
#endif
|
||||
|
||||
Fog(color.rgb, viewPos.xyz);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
} else if (dhZ < 1.0) {
|
||||
z = 1.0 - 1e-5;
|
||||
|
||||
vec4 dhScreenPos = vec4(texCoord, dhZ, 1.0);
|
||||
viewPos = dhProjectionInverse * (dhScreenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
#ifdef AO
|
||||
color.rgb *= GetDHAmbientOcclusion(dhZ);
|
||||
#endif
|
||||
|
||||
Fog(color.rgb, viewPos.xyz);
|
||||
#endif
|
||||
} else {
|
||||
#if defined OVERWORLD && defined SKY_DEFERRED
|
||||
color.rgb += GetSkyColor(viewPos.xyz, false);
|
||||
|
||||
#ifdef ROUND_SUN_MOON
|
||||
vec3 lightMA = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 sunColor = mix(lightMA, sqrt(lightDay * lightMA * LIGHT_DI), timeBrightness);
|
||||
vec3 moonColor = sqrt(lightNight);
|
||||
|
||||
RoundSunMoon(color.rgb, viewPos.xyz, sunColor, moonColor);
|
||||
#endif
|
||||
|
||||
#ifdef STARS
|
||||
if (moonVisibility > 0.0) DrawStars(color.rgb, viewPos.xyz);
|
||||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
color.rgb += DrawAurora(viewPos.xyz, dither, 24);
|
||||
#endif
|
||||
|
||||
SunGlare(color.rgb, viewPos.xyz, lightCol);
|
||||
|
||||
color.rgb *= 1.0 + nightVision;
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
color.rgb *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
color.rgb = netherCol.rgb * 0.0425;
|
||||
#endif
|
||||
#ifdef END
|
||||
#ifdef SHADER_END_SKY
|
||||
color.rgb = GetEndSkyColor(viewPos.xyz);
|
||||
#endif
|
||||
|
||||
#ifndef LIGHT_SHAFT
|
||||
float VoL = dot(normalize(viewPos.xyz), lightVec);
|
||||
VoL = pow(VoL * 0.5 + 0.5, 16.0) * 0.75 + 0.25;
|
||||
color.rgb += endCol.rgb * 0.04 * VoL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 2) {
|
||||
#ifdef EMISSIVE_RECOLOR
|
||||
color.rgb = pow(blocklightCol / BLOCKLIGHT_I, vec3(4.0)) * 2.0;
|
||||
#else
|
||||
color.rgb = vec3(1.0, 0.3, 0.01);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (blindFactor > 0.0 || darknessFactor > 0.0) color.rgb *= 1.0 - max(blindFactor, darknessFactor);
|
||||
}
|
||||
|
||||
vec4 cloud = vec4(0.0);
|
||||
float cloudDither = BayerCloud8(gl_FragCoord.xy);
|
||||
|
||||
float cloudMaxDistance = 2.0 * far;
|
||||
#ifdef DISTANT_HORIZONS
|
||||
cloudMaxDistance = max(cloudMaxDistance, dhFarPlane);
|
||||
#endif
|
||||
|
||||
float cloudViewLength = cloudMaxDistance;
|
||||
float cloudSampleZ = z;
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
DepthOutline(cloudSampleZ, depthtex0);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#if CLOUDS == 1
|
||||
cloud = DrawCloudSkybox(viewPos.xyz, cloudSampleZ, cloudDither, lightCol, ambientCol, false);
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 2
|
||||
vec4 cloudViewPos = viewPos;
|
||||
|
||||
#ifdef OUTLINE_OUTER
|
||||
cloudViewPos = gbufferProjectionInverse * (vec4(texCoord, cloudSampleZ, 1.0) * 2.0 - 1.0);
|
||||
cloudViewPos /= cloudViewPos.w;
|
||||
#endif
|
||||
|
||||
cloud = DrawCloudVolumetric(cloudViewPos.xyz, cameraPosition, cloudSampleZ, cloudDither, lightCol, ambientCol, cloudViewLength, false);
|
||||
#endif
|
||||
|
||||
#ifndef LIGHT_SHAFT
|
||||
SunGlare(cloud.rgb, viewPos.xyz, lightCol);
|
||||
#endif
|
||||
|
||||
color.rgb = mix(color.rgb, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
cloudViewLength /= cloudMaxDistance;
|
||||
|
||||
#ifdef OUTLINE_ENABLED
|
||||
outerOutline.rgb = mix(outerOutline.rgb, cloud.rgb, cloud.a);
|
||||
color.rgb = mix(color.rgb, outerOutline.rgb, outerOutline.a);
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 10900 && !defined IS_IRIS
|
||||
float isGlowing = texture2D(colortex3, texCoord).b;
|
||||
if (isGlowing > 0.5) GlowOutline(color.rgb);
|
||||
#endif
|
||||
|
||||
vec3 reflectionColor = pow(color.rgb, vec3(0.125)) * 0.5;
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
color.rgb = sqrt(max(color.rgb, vec3(0.0)));
|
||||
#endif
|
||||
|
||||
float reflectionMask = float(z < 1.0);
|
||||
#ifdef DISTANT_HORIZONS
|
||||
reflectionMask = max(reflectionMask, float(dhZ < 1.0));
|
||||
#endif
|
||||
|
||||
/*DRAWBUFFERS:04 */
|
||||
gl_FragData[0] = color;
|
||||
gl_FragData[1] = vec4(cloudViewLength, 0.0, 0.0, 1.0);
|
||||
|
||||
#if !defined REFLECTION_PREVIOUS && REFRACTION == 0
|
||||
/*DRAWBUFFERS:045*/
|
||||
gl_FragData[2] = vec4(reflectionColor, reflectionMask);
|
||||
#elif defined REFLECTION_PREVIOUS && REFRACTION > 0
|
||||
/*DRAWBUFFERS:046*/
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#elif !defined REFLECTION_PREVIOUS && REFRACTION > 0
|
||||
/*DRAWBUFFERS:0456*/
|
||||
gl_FragData[2] = vec4(reflectionColor, reflectionMask);
|
||||
gl_FragData[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//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(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float far;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 dhProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
mat4 gbufferProjectionInverse = dhProjectionInverse;
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetBlueNoise3D(vec3 pos, vec3 normal) {
|
||||
pos = (floor(pos + 0.01) + 0.5) / 512.0;
|
||||
|
||||
vec3 worldNormal = (gbufferModelViewInverse * vec4(normal, 0.0)).xyz;
|
||||
vec3 noise3D = vec3(
|
||||
texture2D(noisetex, pos.yz).b,
|
||||
texture2D(noisetex, pos.xz).b,
|
||||
texture2D(noisetex, pos.xy).b
|
||||
);
|
||||
|
||||
float noiseX = noise3D.x * abs(worldNormal.x);
|
||||
float noiseY = noise3D.y * abs(worldNormal.y);
|
||||
float noiseZ = noise3D.z * abs(worldNormal.z);
|
||||
float noise = noiseX + noiseY + noiseZ;
|
||||
|
||||
return noise - 0.5;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/specularColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = color;
|
||||
vec3 newNormal = normal;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float foliage = float(mat > 0.98 && mat < 1.02);
|
||||
float leaves = float(mat > 1.98 && mat < 2.02);
|
||||
float emissive = float(mat > 2.98 && mat < 3.02);
|
||||
float lava = float(mat > 3.98 && mat < 4.02);
|
||||
float candle = float(mat > 4.98 && mat < 5.02);
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = emissive + lava;
|
||||
float subsurface = 0.0;
|
||||
float basicSubsurface = leaves * 0.5;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
float viewLength = length(viewPos);
|
||||
float minDist = (dither - 1.0) * 16.0 + far;
|
||||
if (viewLength < minDist) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec3 noisePos = (worldPos + cameraPosition) * 4.0;
|
||||
float albedoLuma = GetLuminance(albedo.rgb);
|
||||
float noiseAmount = (1.0 - albedoLuma * albedoLuma) * 0.05;
|
||||
float albedoNoise = GetBlueNoise3D(noisePos, normal);
|
||||
albedo.rgb = clamp(albedo.rgb + albedoNoise * noiseAmount, vec3(0.0), vec3(1.0));
|
||||
// albedo.rgb = vec3(albedoNoise + 0.5);
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lmCoord * 14.999) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
vec3 outNormal = newNormal;
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
#ifndef NORMAL_PLANTS
|
||||
if (foliage > 0.5) vanillaDiffuse *= 1.8;
|
||||
#endif
|
||||
if (leaves > 0.5) {
|
||||
float halfNoL = dot(newNormal, lightVec) * 0.5 + 0.5;
|
||||
basicSubsurface *= halfNoL * step(length(albedo.rgb), 1.7);
|
||||
}
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
} else albedo.a = 0.0;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 dhProjection;
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
int blockID = dhMaterialId;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
mat = 0.0;
|
||||
|
||||
if (blockID == DH_BLOCK_LEAVES){
|
||||
mat = 2.0;
|
||||
color.rgb *= 1.3;
|
||||
}
|
||||
if (blockID == DH_BLOCK_ILLUMINATED)
|
||||
mat = 3.0;
|
||||
if (blockID == DH_BLOCK_LAVA) {
|
||||
mat = 4.0;
|
||||
lmCoord.x += 0.0667;
|
||||
}
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = dhProjection * gbufferModelView * position;
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,535 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
varying float dist;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal, binormal, tangent;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float dhFarPlane;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition, previousCameraPosition;
|
||||
|
||||
uniform mat4 dhProjection, dhPreviousProjection, dhProjectionInverse;
|
||||
uniform mat4 gbufferModelView, gbufferPreviousModelView, gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D gaux2;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D depthtex2;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#if CLOUDS == 2
|
||||
uniform sampler2D gaux1;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
mat4 gbufferProjection = dhProjection;
|
||||
mat4 gbufferPreviousProjection = dhPreviousProjection;
|
||||
mat4 gbufferProjectionInverse = dhProjectionInverse;
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
|
||||
float noise = 0.0;
|
||||
|
||||
vec2 wind = vec2(frametime) * 0.5 * WATER_SPEED;
|
||||
|
||||
worldPos.xz += worldPos.y * 0.2;
|
||||
|
||||
#if WATER_NORMALS == 1
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).g;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 48.0 + offset).g;
|
||||
#elif WATER_NORMALS == 2
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).r;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 96.0 + offset).r;
|
||||
noiseA *= noiseA; noiseB *= noiseB;
|
||||
#endif
|
||||
|
||||
#if WATER_NORMALS > 0
|
||||
noise = mix(noiseA, noiseB, WATER_DETAIL);
|
||||
#endif
|
||||
|
||||
return noise * WATER_BUMP;
|
||||
}
|
||||
|
||||
vec3 GetParallaxWaves(vec3 worldPos, vec3 viewVector) {
|
||||
vec3 parallaxPos = worldPos;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
float height = -1.25 * GetWaterHeightMap(parallaxPos, vec2(0.0)) + 0.25;
|
||||
parallaxPos.xz += height * viewVector.xy / dist;
|
||||
}
|
||||
return parallaxPos;
|
||||
}
|
||||
|
||||
vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
|
||||
vec3 waterPos = worldPos + cameraPosition;
|
||||
|
||||
#if WATER_PIXEL > 0
|
||||
waterPos = floor(waterPos * WATER_PIXEL) / WATER_PIXEL;
|
||||
#endif
|
||||
|
||||
#ifdef WATER_PARALLAX
|
||||
waterPos = GetParallaxWaves(waterPos, viewVector);
|
||||
#endif
|
||||
|
||||
float normalOffset = WATER_SHARPNESS;
|
||||
|
||||
float fresnel = pow(clamp(1.0 + dot(normalize(normal), normalize(viewPos)), 0.0, 1.0), 8.0);
|
||||
float normalStrength = 0.35 * (1.0 - fresnel);
|
||||
|
||||
float h1 = GetWaterHeightMap(waterPos, vec2( normalOffset, 0.0));
|
||||
float h2 = GetWaterHeightMap(waterPos, vec2(-normalOffset, 0.0));
|
||||
float h3 = GetWaterHeightMap(waterPos, vec2(0.0, normalOffset));
|
||||
float h4 = GetWaterHeightMap(waterPos, vec2(0.0, -normalOffset));
|
||||
|
||||
float xDelta = (h2 - h1) / normalOffset;
|
||||
float yDelta = (h4 - h3) / normalOffset;
|
||||
|
||||
vec3 normalMap = vec3(xDelta, yDelta, 1.0 - (xDelta * xDelta + yDelta * yDelta));
|
||||
return normalMap * normalStrength + vec3(0.0, 0.0, 1.0 - normalStrength);
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/specularColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/clouds.glsl"
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#include "/lib/atmospherics/waterFog.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/reflections/raytrace.glsl"
|
||||
#include "/lib/reflections/simpleReflections.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
|
||||
float opaqueDepth = texture2D(depthtex1, screenPos.xy).r;
|
||||
if (opaqueDepth < 1.0) discard;
|
||||
|
||||
vec4 albedo = color;
|
||||
vec3 newNormal = normal;
|
||||
float smoothness = 0.0;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
|
||||
vec3 vlAlbedo = vec3(1.0);
|
||||
vec3 refraction = vec3(0.0);
|
||||
|
||||
float cloudBlendOpacity = 1.0;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float water = float(mat > 0.98 && mat < 1.02);
|
||||
float glass = float(mat > 1.98 && mat < 2.02);
|
||||
float translucent = float(mat > 2.98 && mat < 3.02);
|
||||
float portal = float(mat > 3.98 && mat < 4.02);
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = portal;
|
||||
float subsurface = 0.0;
|
||||
float basicSubsurface = water;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
|
||||
|
||||
#ifndef REFLECTION_TRANSLUCENT
|
||||
glass = 0.0;
|
||||
translucent = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
float viewLength = length(viewPos);
|
||||
float minDist = (dither - 1.0) * 16.0 + far;
|
||||
if (viewLength < minDist) {
|
||||
discard;
|
||||
}
|
||||
|
||||
#if CLOUDS == 2
|
||||
float cloudMaxDistance = 2.0 * far;
|
||||
#ifdef DISTANT_HORIZONS
|
||||
cloudMaxDistance = max(cloudMaxDistance, dhFarPlane);
|
||||
#endif
|
||||
|
||||
float cloudViewLength = texture2D(gaux1, screenPos.xy).r * cloudMaxDistance;
|
||||
|
||||
cloudBlendOpacity = step(viewLength, cloudViewLength);
|
||||
|
||||
if (cloudBlendOpacity == 0) {
|
||||
discard;
|
||||
}
|
||||
// albedo.rgb *= fract(viewLength);
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#if WATER_NORMALS == 1 || WATER_NORMALS == 2
|
||||
if (water > 0.5) {
|
||||
normalMap = GetWaterNormal(worldPos, viewPos, viewVector);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if REFRACTION == 1
|
||||
refraction = vec3((newNormal.xy - normal.xy) * 0.5 + 0.5, float(albedo.a < 0.95) * water);
|
||||
#elif REFRACTION == 2
|
||||
refraction = vec3((newNormal.xy - normal.xy) * 0.5 + 0.5, float(albedo.a < 0.95));
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lmCoord * 14.999) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
vlAlbedo = albedo.rgb;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
if (water > 0.5) {
|
||||
#if WATER_MODE == 0
|
||||
albedo.rgb = waterColor.rgb * waterColor.a;
|
||||
#elif WATER_MODE == 1
|
||||
// do nothing
|
||||
#elif WATER_MODE == 2
|
||||
float waterLuma = length(albedo.rgb / pow(color.rgb, vec3(2.2))) * 2.0;
|
||||
albedo.rgb = waterLuma * waterColor.rgb * waterColor.a;
|
||||
#elif WATER_MODE == 3
|
||||
albedo.rgb = color.rgb * color.rgb * 0.35;
|
||||
#endif
|
||||
#if WATER_ALPHA_MODE == 0
|
||||
albedo.a = waterAlpha;
|
||||
#endif
|
||||
vlAlbedo = sqrt(albedo.rgb);
|
||||
baseReflectance = vec3(0.02);
|
||||
}
|
||||
|
||||
vlAlbedo = mix(vec3(1.0), vlAlbedo, sqrt(albedo.a)) * (1.0 - pow(albedo.a, 64.0));
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, color.a, NoL,
|
||||
vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface);
|
||||
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos)), 0.0, 1.0), 5.0);
|
||||
|
||||
if (water > 0.5 || ((translucent + glass) > 0.5 && albedo.a < 0.95)) {
|
||||
#if REFLECTION > 0
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
float reflectionMask = 0.0;
|
||||
|
||||
fresnel = fresnel * 0.98 + 0.02;
|
||||
fresnel*= max(1.0 - isEyeInWater * 0.5 * water, 0.5);
|
||||
// fresnel = 1.0;
|
||||
|
||||
#if REFLECTION == 2
|
||||
reflection = DHReflection(viewPos, newNormal, dither, reflectionMask);
|
||||
reflection.rgb = pow(reflection.rgb * 2.0, vec3(8.0));
|
||||
#endif
|
||||
|
||||
if (reflection.a < 1.0) {
|
||||
#ifdef OVERWORLD
|
||||
vec3 skyRefPos = reflect(normalize(viewPos), newNormal);
|
||||
skyReflection = GetSkyColor(skyRefPos, true);
|
||||
|
||||
#ifdef AURORA
|
||||
skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12);
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 1
|
||||
vec4 cloud = DrawCloudSkybox(skyRefPos * 100.0, 1.0, dither, lightCol, ambientCol, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
#if CLOUDS == 2
|
||||
vec3 cameraPos = GetReflectedCameraPos(worldPos, newNormal);
|
||||
float cloudViewLength = 0.0;
|
||||
|
||||
vec4 cloud = DrawCloudVolumetric(skyRefPos * 8192.0, cameraPos, 1.0, dither, lightCol, ambientCol, cloudViewLength, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
skyReflection *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
|
||||
float waterSkyOcclusion = lightmap.y;
|
||||
#if REFLECTION_SKY_FALLOFF > 1
|
||||
waterSkyOcclusion = clamp(1.0 - (1.0 - waterSkyOcclusion) * REFLECTION_SKY_FALLOFF, 0.0, 1.0);
|
||||
#endif
|
||||
waterSkyOcclusion *= waterSkyOcclusion;
|
||||
skyReflection *= waterSkyOcclusion;
|
||||
#endif
|
||||
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol.rgb * 0.04;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
skyReflection = endCol.rgb * 0.01;
|
||||
#endif
|
||||
|
||||
skyReflection *= clamp(1.0 - isEyeInWater, 0.0, 1.0);
|
||||
}
|
||||
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
|
||||
|
||||
#if defined OVERWORLD || defined END
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, 0.0, vec3(1.0));
|
||||
|
||||
vec3 specular = GetSpecularHighlight(newNormal, viewPos, 0.9, vec3(0.02),
|
||||
specularColor, shadow, color.a);
|
||||
#if ALPHA_BLEND == 0
|
||||
float specularAlpha = pow(mix(albedo.a, 1.0, fresnel), 2.2) * fresnel;
|
||||
#else
|
||||
float specularAlpha = mix(albedo.a , 1.0, fresnel) * fresnel;
|
||||
#endif
|
||||
|
||||
reflection.rgb += specular * (1.0 - reflectionMask) / specularAlpha;
|
||||
#endif
|
||||
|
||||
albedo.rgb = mix(albedo.rgb, reflection.rgb, fresnel);
|
||||
albedo.a = mix(albedo.a, 1.0, fresnel);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WATER_FOG == 1
|
||||
if((isEyeInWater == 0 && water > 0.5) || (isEyeInWater == 1 && water < 0.5)) {
|
||||
float opaqueDepth = texture2D(depthtex1, screenPos.xy).r;
|
||||
vec3 opaqueScreenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), opaqueDepth);
|
||||
#ifdef TAA
|
||||
vec3 opaqueViewPos = ToNDC(vec3(TAAJitter(opaqueScreenPos.xy, -0.5), opaqueScreenPos.z));
|
||||
#else
|
||||
vec3 opaqueViewPos = ToNDC(opaqueScreenPos);
|
||||
#endif
|
||||
|
||||
vec4 waterFog = GetWaterFog(opaqueViewPos - viewPos.xyz);
|
||||
albedo = mix(waterFog, vec4(albedo.rgb, 1.0), albedo.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
Fog(albedo.rgb, viewPos);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
albedo.a *= cloudBlendOpacity;
|
||||
|
||||
/* DRAWBUFFERS:01 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(vlAlbedo, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
varying float dist;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal, binormal, tangent;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float WavingWater(vec3 worldPos) {
|
||||
worldPos += cameraPosition;
|
||||
float fractY = fract(worldPos.y + 0.005);
|
||||
|
||||
float wave = sin(6.2831854 * (frametime * 0.7 + worldPos.x * 0.14 + worldPos.z * 0.07)) +
|
||||
sin(6.2831854 * (frametime * 0.5 + worldPos.x * 0.10 + worldPos.z * 0.20));
|
||||
if (fractY > 0.01) return wave * 0.0125;
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
int blockID = dhMaterialId;
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
binormal = normalize(gbufferModelView[2].xyz);
|
||||
tangent = normalize(gbufferModelView[0].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;
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
mat = 0.0;
|
||||
|
||||
if (blockID == DH_BLOCK_WATER) mat = 1.0;
|
||||
|
||||
const vec2 sunRotationData = vec2(
|
||||
cos(sunPathRotation * 0.01745329251994),
|
||||
-sin(sunPathRotation * 0.01745329251994)
|
||||
);
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = tangent;
|
||||
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
#ifdef WAVING_WATER
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
if (blockID == 300 || blockID == 302 || blockID == 304) position.y += WavingWater(position.xyz);
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
if (mat == 0.0) gl_Position.z -= 0.00001;
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D colortex1;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
uniform float aspectRatio, frameTimeCounter;
|
||||
|
||||
//Optifine Constants//
|
||||
/*
|
||||
const int colortex0Format = R11F_G11F_B10F; //main scene
|
||||
const int colortex1Format = RGB8; //raw translucent, vl, bloom, final scene
|
||||
const int colortex2Format = RGBA16; //temporal data
|
||||
const int colortex3Format = RGB8; //smoothness, sky occlusion, entity mask
|
||||
const int gaux1Format = R8; //cloud alpha, ao
|
||||
const int gaux2Format = RGB10_A2; //reflection image
|
||||
const int gaux3Format = RGBA16; //opaque normals, refraction vector
|
||||
const int gaux4Format = RGBA16; //fresnel
|
||||
const int colortex8Format = RGB8; //colored light
|
||||
const int colortex9Format = RGB16F; //colored light
|
||||
*/
|
||||
|
||||
const bool shadowHardwareFiltering = true;
|
||||
const float shadowDistanceRenderMul = 1.0;
|
||||
|
||||
const int noiseTextureResolution = 512;
|
||||
|
||||
const float drynessHalflife = 5.0;
|
||||
const float wetnessHalflife = 30.0;
|
||||
|
||||
//Common Functions//
|
||||
#ifdef TAA
|
||||
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 coord) {
|
||||
float mult = MC_RENDER_QUALITY * 0.0625;
|
||||
vec2 view = 1.0 / vec2(viewWidth, viewHeight);
|
||||
|
||||
vec3 mincolor = color;
|
||||
vec3 maxcolor = color;
|
||||
|
||||
color *= mult * 4.0 + 1.0;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
vec2 offset = sharpenOffsets[i] * view;
|
||||
vec3 colorSample = texture2DLod(colortex1, coord + offset, 0).rgb;
|
||||
color -= colorSample * mult;
|
||||
|
||||
mincolor = min(mincolor, colorSample);
|
||||
maxcolor = max(maxcolor, colorSample);
|
||||
}
|
||||
|
||||
color = clamp(color, mincolor, maxcolor);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SHADOW
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec2 newTexCoord = texCoord;
|
||||
|
||||
#ifdef RETRO_FILTER
|
||||
vec2 view = vec2(viewWidth, viewHeight) / float(RETRO_FILTER_SIZE);
|
||||
float offset = (ceil(RETRO_FILTER_SIZE * 0.5) - 0.5) / float(RETRO_FILTER_SIZE);
|
||||
newTexCoord = (floor(newTexCoord * view) + offset) / view;
|
||||
#endif
|
||||
|
||||
vec3 color = texture2DLod(colortex1, newTexCoord, 0).rgb;
|
||||
|
||||
#if CHROMATIC_ABERRATION > 0
|
||||
float caStrength = 0.004 * CHROMATIC_ABERRATION;
|
||||
vec2 caScale = vec2(1.0 / aspectRatio, 1.0);
|
||||
color *= vec3(0.0,1.0,0.0);
|
||||
color += texture2DLod(colortex1, mix(newTexCoord, vec2(0.5), caScale * -caStrength), 0).rgb * vec3(1.0,0.0,0.0);
|
||||
color += texture2DLod(colortex1, mix(newTexCoord, vec2(0.5), caScale * -caStrength * 0.5), 0).rgb * vec3(0.5,0.5,0.0);
|
||||
color += texture2DLod(colortex1, mix(newTexCoord, vec2(0.5), caScale * caStrength * 0.5), 0).rgb * vec3(0.0,0.5,0.5);
|
||||
color += texture2DLod(colortex1, mix(newTexCoord, vec2(0.5), caScale* caStrength), 0).rgb * vec3(0.0,0.0,1.0);
|
||||
|
||||
color /= vec3(1.5,2.0,1.5);
|
||||
#endif
|
||||
|
||||
#if defined FXAA && defined TAA
|
||||
SharpenFilter(color, newTexCoord);
|
||||
#endif
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2)) / (4.0 - 3.0 * eBS);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.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 defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//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/lighting/forwardLighting.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = color;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
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.35);
|
||||
#endif
|
||||
|
||||
float NoL = clamp(dot(normal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(normal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(normal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, 1.0, 0.0, 0.0, 0.0);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(0.0, 0.0, float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[4] = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 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
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 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(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
vec4 position = gbufferModelViewInverse * gbufferProjectionInverse * ftransform();
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
|
||||
#ifdef EMISSIVE_RECOLOR
|
||||
if (dot(color.rgb, vec3(1.0)) > 2.66) {
|
||||
float ec = length(albedo.rgb);
|
||||
albedo.rgb = blocklightCol * (ec * 0.63 / BLOCKLIGHT_I) + ec * 0.07;
|
||||
}
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2)) * 4.0;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(2.0);
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
albedo.a = sqrt(albedo.a);
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 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/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.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
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/util/commonFunctions.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
|
||||
flat varying vec2 absMidCoordPos;
|
||||
varying vec2 signMidCoordPos;
|
||||
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int blockEntityId;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight, aspectRatio;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
uniform ivec2 atlasSize;
|
||||
vec2 atlasSizeM = atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
|
||||
vec2 mipx;
|
||||
vec2 mipy;
|
||||
float mipDelta;
|
||||
float miplevel;
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
#if defined GENERATED_NORMALS
|
||||
mat3 tbnMatrix = mat3(
|
||||
tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z
|
||||
);
|
||||
|
||||
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
||||
#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/color/specularColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
#include "/lib/surface/generatedNormals.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
#ifdef GENERATED_NORMALS
|
||||
vec3 colorP = albedo.rgb;
|
||||
#endif
|
||||
vec3 newNormal = normal, geoNormal = normal, shadowMult = vec3(1.0);
|
||||
float smoothness = 0.0;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * absMidCoordPos + signMidCoordPos;
|
||||
float surfaceDepth = 1.0;
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
|
||||
#if MC_VERSION >= 11300
|
||||
float skipAdvMat = float(blockEntityId == 10400);
|
||||
#else
|
||||
float skipAdvMat = float(blockEntityId == 63 || blockEntityId == 68);
|
||||
#endif
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
|
||||
float skyOcclusion = 0.0;
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
#endif
|
||||
|
||||
if(blockEntityId == 10401) albedo.a = 0.0;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = float(blockEntityId == 10205);
|
||||
float subsurface = 0.0;
|
||||
float basicSubsurface = float(blockEntityId == 10109) * 0.5;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0);
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0;
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
#ifdef GENERATED_NORMALS
|
||||
#include "/lib/surface/materialHandling/blockEntityMaterials.glsl"
|
||||
#else
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
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);
|
||||
|
||||
if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#elif defined GENERATED_NORMALS
|
||||
GenerateNormals(newNormal, albedo.rgb);
|
||||
#endif
|
||||
|
||||
#ifdef EMISSIVE_RECOLOR
|
||||
if (blockEntityId == 10205 && dot(color.rgb, vec3(1.0)) > 2.66) {
|
||||
float ec = length(albedo.rgb);
|
||||
albedo.rgb = blocklightCol * (ec * 0.63 / BLOCKLIGHT_I) + ec * 0.07;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
lightAlbedo = albedo.rgb + 0.00001;
|
||||
lightAlbedo = sqrt(normalize(lightAlbedo) * emission);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NoL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NoL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
|
||||
tbnMatrix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, color.a, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, basicSubsurface);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
skyOcclusion = lightmap.y;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos.xyz)), 0.0, 1.0), 5.0);
|
||||
|
||||
fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 1
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared;
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
|
||||
#endif
|
||||
|
||||
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, color.a);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR && defined REFLECTION_ROUGH
|
||||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, smoothness);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
if(blockEntityId == 10205) albedo.a = sqrt(albedo.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(blockEntityId == 10401) {
|
||||
vec2 portalCoord = gl_FragCoord.xy / vec2(viewWidth, viewHeight);
|
||||
portalCoord = (portalCoord - 0.5) * vec2(aspectRatio, 1.0);
|
||||
|
||||
vec3 portColSqrt = vec3(END_R, END_G, END_B) / 255.0 * END_I;
|
||||
vec3 portCol = portColSqrt * portColSqrt * 0.05;
|
||||
vec2 wind = vec2(0, frametime * 0.025);
|
||||
|
||||
float portal = texture2D(noisetex, portalCoord * 0.1 + wind * 0.05).r * 0.25 + 0.375;
|
||||
|
||||
#ifdef END
|
||||
portal *= 0.5;
|
||||
#endif
|
||||
|
||||
portal+= texture2D(texture, portalCoord * 0.5 + wind).r * 1.4;
|
||||
portal+= texture2D(texture, portalCoord + wind + 0.15).r;
|
||||
portal+= texture2D(texture, portalCoord * 2.0 + wind + 0.30).r * 0.7;
|
||||
portal+= texture2D(texture, portalCoord * 4.0 + wind + 0.45).r * 0.5;
|
||||
|
||||
albedo.rgb = portal * portal * portCol.rgb;
|
||||
albedo.a = 1.0;
|
||||
|
||||
lightAlbedo = normalize(albedo.rgb * 20.0 + 0.00001);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(lightAlbedo, 1.0);
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(smoothness, skyOcclusion, 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[4] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 0.0, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec2 signMidCoordPos;
|
||||
flat varying vec2 absMidCoordPos;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
if (normal != normal) normal = -upVec; // Mod Fix: Fixes Better Nether Fireflies
|
||||
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
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;
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
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;
|
||||
|
||||
signMidCoordPos = sign(texMinMidCoord) * (5 + 5);
|
||||
absMidCoordPos = abs(texMinMidCoord);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
if(color.a < 0.1) color.a = 1.0;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].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 TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float rainStrength;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if CLOUDS != 3
|
||||
discard;
|
||||
#endif
|
||||
|
||||
vec4 albedo = texture2D(texture, texCoord);
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2));
|
||||
|
||||
float NoU = clamp(dot(normal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(normal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (-0.333 + abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse = mix(vanillaDiffuse, 0.75, rainStrength * 0.75);
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
albedo.rgb *= lightCol * vanillaDiffuse * CLOUD_BRIGHTNESS;
|
||||
albedo.rgb *= mix(0.4 - 0.25 * rainStrength, 0.5 - 0.425 * rainStrength, sunVisibility);
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#if FOG_VANILLA_CLOUD > 0
|
||||
#if FOG_VANILLA_CLOUD == 1
|
||||
float vanillaFogEnd = 4.0;
|
||||
#elif FOG_VANILLA_CLOUD == 2
|
||||
float vanillaFogEnd = 2.0;
|
||||
#else
|
||||
float vanillaFogEnd = 1.0;
|
||||
#endif
|
||||
|
||||
float worldDistance = length(worldPos.xz) / 256.0;
|
||||
float vanillaFog = 1.0 - smoothstep(0.5, vanillaFogEnd, worldDistance);
|
||||
|
||||
albedo.a *= color.a * vanillaFog;
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:0367 */
|
||||
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/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
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(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
//Texture
|
||||
vec4 albedo = texture2D(texture, texCoord);
|
||||
|
||||
#if ALPHA_BLEND == 1
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2)) * 2.25;
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
//Uniforms//
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.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
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,459 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int entityId;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform vec4 entityColor;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//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/color/specularColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
#if MC_VERSION <= 10710
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
vec3 newNormal = normal;
|
||||
float smoothness = 0.0;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float surfaceDepth = 1.0;
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float skipAdvMat = float(entityId == 10100);
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
|
||||
float skyOcclusion = 0.0;
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef ENTITY_FLASH
|
||||
albedo.rgb = mix(albedo.rgb, entityColor.rgb, entityColor.a);
|
||||
#endif
|
||||
|
||||
float lightningBolt = float(entityId == 10101);
|
||||
if(lightningBolt > 0.5) {
|
||||
#ifdef OVERWORLD
|
||||
albedo.rgb = weatherCol.rgb / weatherCol.a;
|
||||
albedo.rgb *= albedo.rgb * albedo.rgb;
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
albedo.rgb = sqrt(netherCol.rgb / netherCol.a);
|
||||
#endif
|
||||
#ifdef END
|
||||
albedo.rgb = endCol.rgb / endCol.a;
|
||||
#endif
|
||||
albedo.a = 1.0;
|
||||
}
|
||||
|
||||
if (albedo.a > 0.001 && lightningBolt < 0.5) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = float(entityColor.a > 0.05) * 0.125;
|
||||
float subsurface = 0.0;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= dot(albedo.rgb, albedo.rgb) * 0.333;
|
||||
|
||||
#ifndef ENTITY_FLASH
|
||||
emission = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0;
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
normalMap = vec3(0.0, 0.0, 1.0);
|
||||
#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) && viewVector == viewVector && skipAdvMat < 0.5)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NoL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NoL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
|
||||
tbnMatrix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
skyOcclusion = lightmap.y;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos.xyz)), 0.0, 1.0), 5.0);
|
||||
|
||||
fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 1
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared;
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
|
||||
#endif
|
||||
|
||||
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR && defined REFLECTION_ROUGH
|
||||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, smoothness);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
|
||||
/* DRAWBUFFERS:083 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(smoothness, skyOcclusion, 0.25, 1.0);
|
||||
gl_FragData[3] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[4] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
|
||||
/* DRAWBUFFERS:03 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 0.25, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].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
|
||||
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int entityId;
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform vec4 entityColor;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//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/color/specularColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
#if MC_VERSION <= 10710
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
vec3 newNormal = normal;
|
||||
float smoothness = 0.0;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float surfaceDepth = 1.0;
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float skipAdvMat = float(entityId == 10100);
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
|
||||
float skyOcclusion = 0.0;
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef ENTITY_FLASH
|
||||
albedo.rgb = mix(albedo.rgb, entityColor.rgb, entityColor.a);
|
||||
#endif
|
||||
|
||||
float lightningBolt = float(entityId == 10101);
|
||||
if(lightningBolt > 0.5) {
|
||||
#ifdef OVERWORLD
|
||||
albedo.rgb = weatherCol.rgb / weatherCol.a;
|
||||
albedo.rgb *= albedo.rgb * albedo.rgb;
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
albedo.rgb = sqrt(netherCol.rgb / netherCol.a);
|
||||
#endif
|
||||
#ifdef END
|
||||
albedo.rgb = endCol.rgb / endCol.a;
|
||||
#endif
|
||||
albedo.a = 1.0;
|
||||
}
|
||||
|
||||
if (albedo.a > 0.001 && lightningBolt < 0.5) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = float(entityColor.a > 0.05);
|
||||
float subsurface = 0.0;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.125;
|
||||
|
||||
#ifndef ENTITY_FLASH
|
||||
emission = 0.0;
|
||||
#endif
|
||||
|
||||
float correctedZ = (gl_FragCoord.z * 2.0 - 1.0) * 100.0 * 0.5 + 0.5;
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), correctedZ);
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0;
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
normalMap = vec3(0.0, 0.0, 1.0);
|
||||
#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) && viewVector == viewVector && skipAdvMat < 0.5)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NoL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NoL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
|
||||
tbnMatrix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
skyOcclusion = lightmap.y;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos.xyz)), 0.0, 1.0), 5.0);
|
||||
|
||||
fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 1
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared;
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
|
||||
#endif
|
||||
|
||||
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR && defined REFLECTION_ROUGH
|
||||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, smoothness);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:03 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:038 */
|
||||
gl_FragData[2] = vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:03867 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 1.0, 1.0);
|
||||
gl_FragData[3] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[4] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 1.0, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
|
||||
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].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
|
||||
|
||||
gl_Position.z *= 0.01;
|
||||
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,467 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float isMainHand;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int heldItemId, heldItemId2;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetHandItem(int id) {
|
||||
return float((heldItemId == id && isMainHand > 0.5) || (heldItemId2 == id && isMainHand < 0.5));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/specularColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
#undef PARALLAX
|
||||
#undef SELF_SHADOW
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
vec3 newNormal = normal;
|
||||
float smoothness = 0.0;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float surfaceDepth = 1.0;
|
||||
float skipAdvMat = float(heldItemId == 358 || (heldItemId2 == 358 && isMainHand < 0.5));
|
||||
|
||||
#ifdef PARALLAX
|
||||
if (skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, 0.0, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * color;
|
||||
}
|
||||
#endif
|
||||
|
||||
float skyOcclusion = 0.0;
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
#endif
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
#ifdef TOON_LIGHTMAP
|
||||
vec2 lightmap = floor(lmCoord * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#else
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
lightmap.x = max(lightmap.x, GetHandItem(213));
|
||||
|
||||
float emissive = (GetHandItem(50) + GetHandItem(89) + GetHandItem(213));
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = emissive;
|
||||
float subsurface = 0.0;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.25;
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z + 0.38);
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0;
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
|
||||
#ifdef NORMAL_SKIP
|
||||
normalMap = vec3(0.0, 0.0, 1.0);
|
||||
#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) && viewVector == viewVector)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp(heldLightValue / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
float doRecolor = GetHandItem(89) + GetHandItem(213);
|
||||
|
||||
float ec = GetLuminance(albedo.rgb) * 1.7;
|
||||
#ifdef EMISSIVE_RECOLOR
|
||||
if (doRecolor > 0.5) {
|
||||
albedo.rgb = blocklightCol * pow(ec, 1.5) / (BLOCKLIGHT_I * BLOCKLIGHT_I);
|
||||
albedo.rgb /= 0.7 * albedo.rgb + 0.7;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
lightAlbedo = albedo.rgb + 0.00001;
|
||||
lightAlbedo = sqrt(normalize(lightAlbedo) * emission * emissive);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao * ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && NoL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(NoL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5 && skipAdvMat < 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, 0.0, newCoord, lightVec, tbnMatrix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, vec3(0.0), lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
skyOcclusion = lightmap.y;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos.xyz)), 0.0, 1.0), 5.0);
|
||||
|
||||
fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 1
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared;
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
|
||||
#endif
|
||||
|
||||
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR && defined REFLECTION_ROUGH
|
||||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, smoothness);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(lightAlbedo,1.0);
|
||||
|
||||
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
|
||||
/* DRAWBUFFERS:083 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(smoothness, skyOcclusion, 0.25, 1.0);
|
||||
gl_FragData[3] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[4] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
|
||||
/* DRAWBUFFERS:03 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 0.25, 1.0);
|
||||
gl_FragData[2] = vec4(EncodeNormal(newNormal), float(gl_FragCoord.z < 1.0), 1.0);
|
||||
gl_FragData[3] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float isMainHand;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjection;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
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;
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
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;
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
isMainHand = float(gl_ModelViewMatrix[3][0] > 0.0);
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].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 defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
|
||||
#if MC_VERSION >= 11500
|
||||
isMainHand = float(gl_Position.x > 0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float star;
|
||||
|
||||
varying vec3 upVec, sunVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int moonPhase;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
vec3 lightVec = sunVec * (1.0 - 2.0 * float(timeAngle > 0.5325 && timeAngle < 0.9675));
|
||||
|
||||
vec3 moonPhaseVecs[8] = vec3[8](
|
||||
vec3( 0.0 , 0.0 , 1.0 ),
|
||||
vec3( 0.0 , -0.89, 0.45),
|
||||
vec3( 0.0 , -1.0 , 0.0 ),
|
||||
vec3( 0.0 , -0.45, -0.89),
|
||||
vec3( 0.0 , 0.0 , -1.0 ),
|
||||
vec3( 0.0 , 0.45, -0.89),
|
||||
vec3( 0.0 , 1.0 , 0.0 ),
|
||||
vec3( 0.0 , 0.89, 0.45)
|
||||
);
|
||||
|
||||
vec2 moonDiffuse[8] = vec2[8](
|
||||
vec2( 0.0 , 0.0 ),
|
||||
vec2(-0.125, 1.0 ),
|
||||
vec2(-0.2 , 0.625),
|
||||
vec2(-0.8 , 0.375),
|
||||
vec2(-0.75 , -0.25 ),
|
||||
vec2(-0.8 , 0.375),
|
||||
vec2(-0.2 , 0.625),
|
||||
vec2(-0.125, 1.0 )
|
||||
);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/clouds.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/sunmoon.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec3 albedo = vec3(0.0);
|
||||
|
||||
#if defined OVERWORLD && !defined SKY_DEFERRED
|
||||
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;
|
||||
|
||||
albedo = GetSkyColor(viewPos.xyz, false);
|
||||
|
||||
#ifdef ROUND_SUN_MOON
|
||||
vec3 lightMA = mix(lightMorning, lightEvening, mefade);
|
||||
vec3 sunColor = mix(lightMA, sqrt(lightDay * lightMA * LIGHT_DI), timeBrightness);
|
||||
vec3 moonColor = lightNight * 1.25;
|
||||
|
||||
RoundSunMoon(albedo, viewPos.xyz, sunColor, moonColor);
|
||||
#endif
|
||||
|
||||
#ifdef STARS
|
||||
if (moonVisibility > 0.0) DrawStars(albedo.rgb, viewPos.xyz);
|
||||
#endif
|
||||
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
#ifdef AURORA
|
||||
albedo.rgb += DrawAurora(viewPos.xyz, dither, 24);
|
||||
#endif
|
||||
|
||||
SunGlare(albedo, viewPos.xyz, lightCol);
|
||||
|
||||
albedo.rgb *= 1.0 + nightVision;
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
albedo.rgb *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
albedo.rgb = albedo.rgb + dither / vec3(128.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = vec4(albedo, 1.0 - star);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float star;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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();
|
||||
|
||||
star = float(gl_Color.r == gl_Color.g && gl_Color.g == gl_Color.b && gl_Color.r > 0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 upVec, sunVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int renderStage;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D gaux1;
|
||||
|
||||
#ifndef MC_RENDER_STAGE_SUN
|
||||
#define MC_RENDER_STAGE_SUN 1
|
||||
#endif
|
||||
|
||||
#ifndef MC_RENDER_STAGE_MOON
|
||||
#define MC_RENDER_STAGE_MOON 1
|
||||
#endif
|
||||
|
||||
#ifndef MC_RENDER_STAGE_CUSTOM_SKY
|
||||
#define MC_RENDER_STAGE_CUSTOM_SKY 1
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord);
|
||||
|
||||
#ifdef OVERWORLD
|
||||
albedo *= color;
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2)) * albedo.a;
|
||||
|
||||
#if MC_VERSION >= 11605
|
||||
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;
|
||||
|
||||
float VoU = dot(normalize(viewPos.xyz), upVec);
|
||||
|
||||
float sunFade = smoothstep(0.0, 1.0, 1.0 - pow(1.0 - max(VoU * 0.975 + 0.025, 0.0), 8.0));
|
||||
sunFade *= sunFade;
|
||||
|
||||
if (renderStage == MC_RENDER_STAGE_CUSTOM_SKY) {
|
||||
albedo.rgb *= SKYBOX_INTENSITY * SKYBOX_INTENSITY;
|
||||
albedo.a *= SKYBOX_OPACITY;
|
||||
}
|
||||
if (renderStage == MC_RENDER_STAGE_SUN) {
|
||||
albedo.rgb *= SUN_INTENSITY * SUN_INTENSITY * sunFade;
|
||||
}
|
||||
if (renderStage == MC_RENDER_STAGE_MOON) {
|
||||
albedo.rgb *= MOON_INTENSITY * MOON_INTENSITY * sunFade;
|
||||
}
|
||||
#else
|
||||
albedo.rgb *= SKYBOX_INTENSITY * SKYBOX_INTENSITY;
|
||||
albedo.a *= SKYBOX_OPACITY;
|
||||
#endif
|
||||
|
||||
#ifdef ROUND_SUN_MOON
|
||||
if (renderStage == MC_RENDER_STAGE_SUN || renderStage == MC_RENDER_STAGE_MOON) {
|
||||
albedo *= 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKY_DESATURATION
|
||||
vec3 desat = GetLuminance(albedo.rgb) * pow(lightNight, vec3(1.6)) * 4.0;
|
||||
albedo.rgb = mix(desat, albedo.rgb, sunVisibility);
|
||||
#endif
|
||||
|
||||
#ifdef UNDERGROUND_SKY
|
||||
albedo.rgb *= mix(clamp((cameraPosition.y - 48.0) / 16.0, 0.0, 1.0), 1.0, eBS);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef SKY_DESATURATION
|
||||
albedo.rgb = GetLuminance(albedo.rgb) * endCol.rgb;
|
||||
#endif
|
||||
|
||||
albedo.rgb *= SKYBOX_INTENSITY * 0.02 * 16.0 / 16.0;
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 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();
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform sampler2D texture;
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
albedo.rgb = pow(albedo.rgb,vec3(2.2)) * 4.0;
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(2.0);
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:0367 */
|
||||
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/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth;
|
||||
uniform float viewHeight;
|
||||
#include "/lib/util/jitter.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;
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,709 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat, recolor;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec, northVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
varying vec4 glColor;
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
varying float dist;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
|
||||
flat varying vec2 absMidCoordPos;
|
||||
varying vec2 signMidCoordPos;
|
||||
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
uniform ivec2 atlasSize;
|
||||
vec2 atlasSizeM = atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
uniform float wetness;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
|
||||
float NdotU = dot(normal, upVec);
|
||||
float NdotUmax0 = max(NdotU, 0.0);
|
||||
|
||||
const float OSIEBCA = 1.0 / 255.0;
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
vec4 debugNormals;
|
||||
|
||||
vec2 mipx;
|
||||
vec2 mipy;
|
||||
float mipDelta;
|
||||
float miplevel;
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
#if defined GENERATED_NORMALS
|
||||
mat3 tbnMatrix = mat3(
|
||||
tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z
|
||||
);
|
||||
|
||||
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float max0(float x) {
|
||||
return max(x, 0.0);
|
||||
}
|
||||
|
||||
float min1(float x) {
|
||||
return min(x, 1.0);
|
||||
}
|
||||
|
||||
float pow2(float x) {
|
||||
return x * x;
|
||||
}
|
||||
vec2 pow2(vec2 x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
vec3 pow2(vec3 x) {
|
||||
return x * x;
|
||||
}
|
||||
float pow1_5(float x) { // Faster pow(x, 1.5) approximation (that isn't accurate at all) if x is between 0 and 1
|
||||
return x - x * pow2(1.0 - x); // Thanks to SixthSurge
|
||||
}
|
||||
vec2 pow1_5(vec2 x) {
|
||||
return x - x * pow2(1.0 - x);
|
||||
}
|
||||
vec3 pow1_5(vec3 x) {
|
||||
return x - x * pow2(1.0 - x);
|
||||
}
|
||||
|
||||
bool CheckForColor(vec3 albedo, vec3 check) { // Thanks to Builderb0y
|
||||
vec3 dif = albedo - check * 0.003921568;
|
||||
return dif == clamp(dif, vec3(-0.001), vec3(0.001));
|
||||
}
|
||||
|
||||
float GetMaxColorDif(vec3 color) {
|
||||
vec3 dif = abs(vec3(color.r - color.g, color.g - color.b, color.r - color.b));
|
||||
return max(dif.r, max(dif.g, dif.b));
|
||||
}
|
||||
|
||||
float smoothstep1(float x) {
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
vec2 smoothstep1(vec2 x) {
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
vec3 smoothstep1(vec3 x) {
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
float sqrt1(float x) { // Faster sqrt() approximation (that isn't accurate at all) if x is between 0 and 1
|
||||
return x * (2.0 - x); // Thanks to Builderb0y
|
||||
}
|
||||
vec2 sqrt1(vec2 x) {
|
||||
return x * (2.0 - x);
|
||||
}
|
||||
vec3 sqrt1(vec3 x) {
|
||||
return x * (2.0 - x);
|
||||
}
|
||||
vec4 sqrt1(vec4 x) {
|
||||
return x * (2.0 - x);
|
||||
}
|
||||
vec3 ViewToPlayer(vec3 pos) {
|
||||
return mat3(gbufferModelViewInverse) * pos + gbufferModelViewInverse[3].xyz;
|
||||
}
|
||||
|
||||
float sqrt3(float x) {
|
||||
x = 1.0 - x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
return 1.0 - x;
|
||||
}
|
||||
vec2 sqrt3(vec2 x) {
|
||||
x = 1.0 - x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
return 1.0 - x;
|
||||
}
|
||||
vec3 sqrt3(vec3 x) {
|
||||
x = 1.0 - x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
return 1.0 - x;
|
||||
}
|
||||
vec4 sqrt3(vec4 x) {
|
||||
x = 1.0 - x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
x *= x;
|
||||
return 1.0 - x;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/specularColor.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
|
||||
#include "/lib/util/encode.glsl"
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/directionalLightmap.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
#include "/lib/surface/generatedNormals.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
#include "/lib/reflections/rainPuddles.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * vec4(color.rgb, 1.0);
|
||||
vec3 newNormal = normal;
|
||||
float smoothnessD = 0.0, materialMask = 0.0, skyLightFactor = 0.0;
|
||||
float smoothness = 0.0;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
int subsurfaceMode = 0;
|
||||
float smoothnessG = 0.0, highlightMult = 1.0, emission = 0.0;
|
||||
vec2 lmCoordM = lmCoord;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float surfaceDepth = 1.0;
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float skipAdvMat = float(mat > 3.98 && mat < 4.02);
|
||||
|
||||
#ifdef PARALLAX
|
||||
if(skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * vec4(color.rgb, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
float skyOcclusion = 0.0;
|
||||
vec3 fresnel3 = vec3(0.0);
|
||||
#endif
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float foliage = float(mat > 0.98 && mat < 1.02);
|
||||
float leaves = float(mat > 1.98 && mat < 2.02);
|
||||
float emissive = float(mat > 2.98 && mat < 3.02);
|
||||
float lava = float(mat > 3.98 && mat < 4.02);
|
||||
float candle = float(mat > 4.98 && mat < 5.02);
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = (emissive + candle + lava);
|
||||
float subsurface = 0.0;
|
||||
float basicSubsurface = (foliage + candle) * 0.5 + leaves;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
vec3 playerPos = ViewToPlayer(viewPos);
|
||||
float lViewPos = length(viewPos);
|
||||
|
||||
bool noSmoothLighting = false, noDirectionalShading = false, noVanillaAO = false, centerShadowBias = false, noGeneratedNormals = false, doTileRandomisation = true;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0;
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
#ifndef GENERATED_NORMALS
|
||||
if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
// #include "/lib/materials/materialHandling/terrainMaterials.glsl"
|
||||
GenerateNormals(newNormal, albedo.rgb);
|
||||
#endif
|
||||
debugNormals = vec4(newNormal , 1.0);
|
||||
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef EMISSIVE_RECOLOR
|
||||
float ec = GetLuminance(albedo.rgb) * 1.7;
|
||||
if (recolor > 0.5) {
|
||||
albedo.rgb = blocklightCol * pow(ec, 1.5) / (BLOCKLIGHT_I * BLOCKLIGHT_I);
|
||||
albedo.rgb /= 0.7 * albedo.rgb + 0.7;
|
||||
}
|
||||
if (lava > 0.5) {
|
||||
albedo.rgb = pow(blocklightCol * ec / BLOCKLIGHT_I, vec3(2.0));
|
||||
albedo.rgb /= 0.5 * albedo.rgb + 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
lightAlbedo = albedo.rgb + 0.00001;
|
||||
if (lava > 0.5) {
|
||||
#ifndef MCBL_LEGACY_COLOR
|
||||
lightAlbedo = pow(lightAlbedo, vec3(0.25));
|
||||
#else
|
||||
lightAlbedo = sqrt(lightAlbedo) * 0.98 + 0.02;
|
||||
#endif
|
||||
}
|
||||
lightAlbedo = sqrt(normalize(lightAlbedo) * emission);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
vec3 outNormal = newNormal;
|
||||
#ifdef NORMAL_PLANTS
|
||||
if (foliage > 0.5){
|
||||
newNormal = upVec;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
newNormal = normalize(mix(outNormal, newNormal, normalMap.z * normalMap.z));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
#ifndef NORMAL_PLANTS
|
||||
if (foliage > 0.5) vanillaDiffuse *= 1.8;
|
||||
#endif
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao * ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
float doParallax = 0.0;
|
||||
#ifdef SELF_SHADOW
|
||||
float parallaxNoL = dot(outNormal, lightVec);
|
||||
#ifdef OVERWORLD
|
||||
doParallax = float(lightmap.y > 0.0 && parallaxNoL > 0.0);
|
||||
#endif
|
||||
#ifdef END
|
||||
doParallax = float(parallaxNoL > 0.0);
|
||||
#endif
|
||||
|
||||
if (doParallax > 0.5 && skipAdvMat < 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
|
||||
tbnMatrix);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_LIGHTMAP
|
||||
mat3 lightmapTBN = GetLightmapTBN(viewPos);
|
||||
lightmap.x = DirectionalLightmap(lightmap.x, lmCoord.x, outNormal, lightmapTBN);
|
||||
lightmap.y = DirectionalLightmap(lightmap.y, lmCoord.y, outNormal, lightmapTBN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, color.a, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, basicSubsurface);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float puddles = 0.0;
|
||||
#ifdef REFLECTION_RAIN
|
||||
float puddlesNoU = dot(outNormal, upVec);
|
||||
|
||||
puddles = GetPuddles(worldPos, newCoord, lightmap.y, puddlesNoU, wetness);
|
||||
puddles *= 1.0 - lava;
|
||||
|
||||
ApplyPuddleToMaterial(puddles, albedo, smoothness, f0, porosity);
|
||||
|
||||
if (puddles > 0.001 && rainStrength > 0.001) {
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
vec3 puddleNormal = GetPuddleNormal(worldPos, viewPos, tbnMatrix);
|
||||
outNormal = normalize(
|
||||
mix(outNormal, puddleNormal, puddles * sqrt(1.0 - porosity) * rainStrength)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
skyOcclusion = lightmap.y;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
float fresnel = pow(clamp(1.0 + dot(outNormal, normalize(viewPos.xyz)), 0.0, 1.0), 5.0);
|
||||
|
||||
fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 1
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared;
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
|
||||
#endif
|
||||
|
||||
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, color.a);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR && defined REFLECTION_ROUGH
|
||||
// newNormal = outNormal;
|
||||
// if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector) {
|
||||
// normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, smoothness);
|
||||
// newNormal = mix(normalMap * tbnMatrix, newNormal, 1.0 - pow(1.0 - puddles, 4.0));
|
||||
// newNormal = clamp(normalize(newNormal), vec3(-1.0), vec3(1.0));
|
||||
// }
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
} else albedo.a = 0.0;
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(lightAlbedo, 1.0);
|
||||
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(smoothness, skyOcclusion, 0.0, 1.0);
|
||||
gl_FragData[3] = vec4(newNormal, 1.0);
|
||||
gl_FragData[4] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(smoothness, skyOcclusion, 0.0, 1.0);
|
||||
gl_FragData[2] = vec4(newNormal, 1.0);
|
||||
gl_FragData[3] = vec4(fresnel3, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat, recolor;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec, northVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying float dist;
|
||||
|
||||
varying vec2 signMidCoordPos;
|
||||
flat varying vec2 absMidCoordPos;
|
||||
|
||||
varying vec3 binormal, tangent;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
attribute vec4 at_tangent;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
vec3 GetSunVector() {
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
#ifdef OVERWORLD
|
||||
float ang = fract(timeAngle - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
return normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
|
||||
#elif defined END
|
||||
float ang = 0.0;
|
||||
return normalize((gbufferModelView * vec4(vec3(0.0, sunRotationData * 2000.0), 1.0)).xyz);
|
||||
#else
|
||||
return vec3(0.0);
|
||||
#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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
int blockID = int(mod(max(mc_Entity.x - 10000, 0), 10000));
|
||||
|
||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
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 (mc_Entity.x == 0)
|
||||
viewVector /= 0.0;
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
vec2 texMinMidCoord = texCoord - midCoord;
|
||||
|
||||
vTexCoordAM.pq = abs(texMinMidCoord) * 2;
|
||||
vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord);
|
||||
signMidCoordPos = sign(texMinMidCoord);
|
||||
absMidCoordPos = abs(texMinMidCoord);
|
||||
|
||||
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
mat = 0.0; recolor = 0.0;
|
||||
|
||||
if (blockID >= 100 && blockID < 200)
|
||||
mat = 1.0;
|
||||
if (blockID == 105 || blockID == 106){
|
||||
mat = 2.0;
|
||||
color.rgb *= 1.225;
|
||||
}
|
||||
if (blockID >= 200 && blockID < 300)
|
||||
mat = 3.0;
|
||||
if (blockID == 203){
|
||||
mat = 4.0;
|
||||
lmCoord.x += 0.0667;
|
||||
}
|
||||
if (blockID == 208)
|
||||
mat = 5.0;
|
||||
|
||||
if (blockID == 201 || blockID == 205 || blockID == 206)
|
||||
recolor = 1.0;
|
||||
|
||||
if (blockID == 202)
|
||||
lmCoord.x -= 0.0667;
|
||||
|
||||
if (color.a < 0.1)
|
||||
color.a = 1.0;
|
||||
|
||||
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
|
||||
float ang = fract(timeAngle - 0.25);
|
||||
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
|
||||
sunVec = GetSunVector();
|
||||
|
||||
upVec = normalize(gbufferModelView[1].xyz);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
northVec = normalize(gbufferModelView[2].xyz);
|
||||
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
position.xyz = WavingBlocks(position.xyz, blockID, istopv);
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection;
|
||||
uniform mat4 shadowModelView;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef SOFT_PARTICLES
|
||||
uniform sampler2D depthtex0;
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform vec3 previousCameraPosition;
|
||||
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
uniform float dhFarPlane;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
#ifdef SOFT_PARTICLES
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * color;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
float NoL = 1.0;
|
||||
//NoL = clamp(dot(normal, lightVec) * 1.01 - 0.01, 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(normal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(normal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
1.0, 1.0, 0.0, 0.0, 0.0);
|
||||
|
||||
#if defined FOG && MC_VERSION >= 11500
|
||||
Fog(albedo.rgb, viewPos);
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SOFT_PARTICLES
|
||||
float linearZ = GetLinearDepth(gl_FragCoord.z) * (far - near);
|
||||
float backZ = texture2D(depthtex0, gl_FragCoord.xy / vec2(viewWidth, viewHeight)).r;
|
||||
float linearBackZ = GetLinearDepth(backZ) * (far - near);
|
||||
|
||||
float difference = clamp(linearBackZ - linearZ, 0.0, 1.0);
|
||||
difference = difference * difference * (3.0 - 2.0 * difference);
|
||||
|
||||
float opaqueThreshold = fract(Bayer8(gl_FragCoord.xy) + frameTimeCounter * 8.0);
|
||||
|
||||
if (albedo.a > 0.999) albedo.a *= float(difference > opaqueThreshold);
|
||||
else albedo.a *= difference;
|
||||
#endif
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:08 */
|
||||
gl_FragData[1] = vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
#if defined TAA_SELECTIVE && !defined ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:083 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:08367 */
|
||||
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
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
|
||||
#else
|
||||
#if defined TAA_SELECTIVE && !defined ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:03 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
/* DRAWBUFFERS:0367 */
|
||||
gl_FragData[1] = vec4(0.0, 0.0, 0.25, 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
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
#ifdef SOFT_PARTICLES
|
||||
uniform float far, near;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
#ifdef SOFT_PARTICLES
|
||||
float GetLinearDepth(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
}
|
||||
|
||||
float GetLogarithmicDepth(float depth) {
|
||||
return -(2.0 * near / depth - (far + near)) / (far - near);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 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(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].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 SOFT_PARTICLES
|
||||
gl_Position.z = GetLinearDepth(gl_Position.z / gl_Position.w) * (far - near);
|
||||
gl_Position.z -= 0.25;
|
||||
gl_Position.z = GetLogarithmicDepth(gl_Position.z / (far - near)) * gl_Position.w;
|
||||
#endif
|
||||
|
||||
#if defined TAA && !defined TAA_SELECTIVE
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,775 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
varying float dist;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal, binormal, tangent;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int frameCounter;
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float blindFactor, darknessFactor, nightVision;
|
||||
uniform float far, near;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float rainStrength;
|
||||
uniform float screenBrightness;
|
||||
uniform float shadowFade, voidFade;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform vec3 cameraPosition, previousCameraPosition;
|
||||
|
||||
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 depthtex2;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
uniform ivec2 atlasSize;
|
||||
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
uniform float wetness;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
uniform int heldBlockLightValue;
|
||||
uniform int heldBlockLightValue2;
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 2
|
||||
uniform sampler2D gaux1;
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
uniform float dhFarPlane;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
|
||||
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 dcdx = dFdx(texCoord);
|
||||
vec2 dcdy = dFdy(texCoord);
|
||||
#endif
|
||||
|
||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||
|
||||
//Common Functions//
|
||||
float GetLuminance(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
|
||||
float noise = 0.0;
|
||||
|
||||
vec2 wind = vec2(frametime) * 0.5 * WATER_SPEED;
|
||||
|
||||
worldPos.xz += worldPos.y * 0.2;
|
||||
|
||||
#if WATER_NORMALS == 1
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).g;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 48.0 + offset).g;
|
||||
#elif WATER_NORMALS == 2
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).r;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 96.0 + offset).r;
|
||||
noiseA *= noiseA; noiseB *= noiseB;
|
||||
#endif
|
||||
|
||||
#if WATER_NORMALS > 0
|
||||
noise = mix(noiseA, noiseB, WATER_DETAIL);
|
||||
#endif
|
||||
|
||||
return noise * WATER_BUMP;
|
||||
}
|
||||
|
||||
vec3 GetParallaxWaves(vec3 worldPos, vec3 viewVector) {
|
||||
vec3 parallaxPos = worldPos;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
float height = -1.25 * GetWaterHeightMap(parallaxPos, vec2(0.0)) + 0.25;
|
||||
parallaxPos.xz += height * viewVector.xy / dist;
|
||||
}
|
||||
return parallaxPos;
|
||||
}
|
||||
|
||||
vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
|
||||
vec3 waterPos = worldPos + cameraPosition;
|
||||
|
||||
#if WATER_PIXEL > 0
|
||||
waterPos = floor(waterPos * WATER_PIXEL) / WATER_PIXEL;
|
||||
#endif
|
||||
|
||||
#ifdef WATER_PARALLAX
|
||||
waterPos = GetParallaxWaves(waterPos, viewVector);
|
||||
#endif
|
||||
|
||||
float normalOffset = WATER_SHARPNESS;
|
||||
|
||||
float fresnel = pow(clamp(1.0 + dot(normalize(normal), normalize(viewPos)), 0.0, 1.0), 8.0);
|
||||
float normalStrength = 0.35 * (1.0 - fresnel);
|
||||
|
||||
float h1 = GetWaterHeightMap(waterPos, vec2( normalOffset, 0.0));
|
||||
float h2 = GetWaterHeightMap(waterPos, vec2(-normalOffset, 0.0));
|
||||
float h3 = GetWaterHeightMap(waterPos, vec2(0.0, normalOffset));
|
||||
float h4 = GetWaterHeightMap(waterPos, vec2(0.0, -normalOffset));
|
||||
|
||||
float xDelta = (h2 - h1) / normalOffset;
|
||||
float yDelta = (h4 - h3) / normalOffset;
|
||||
|
||||
vec3 normalMap = vec3(xDelta, yDelta, 1.0 - (xDelta * xDelta + yDelta * yDelta));
|
||||
return normalMap * normalStrength + vec3(0.0, 0.0, 1.0 - normalStrength);
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/color/dimensionColor.glsl"
|
||||
#include "/lib/color/skyColor.glsl"
|
||||
#include "/lib/color/specularColor.glsl"
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#include "/lib/util/dither.glsl"
|
||||
#include "/lib/util/spaceConversion.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/atmospherics/clouds.glsl"
|
||||
#include "/lib/atmospherics/fog.glsl"
|
||||
#include "/lib/atmospherics/waterFog.glsl"
|
||||
#include "/lib/lighting/forwardLighting.glsl"
|
||||
#include "/lib/reflections/raytrace.glsl"
|
||||
#include "/lib/reflections/simpleReflections.glsl"
|
||||
#include "/lib/surface/ggx.glsl"
|
||||
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
#include "/lib/reflections/complexFresnel.glsl"
|
||||
#include "/lib/surface/directionalLightmap.glsl"
|
||||
#include "/lib/surface/materialGbuffers.glsl"
|
||||
#include "/lib/surface/parallax.glsl"
|
||||
|
||||
#ifdef REFLECTION_RAIN
|
||||
#include "/lib/reflections/rainPuddles.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
#include "/lib/lighting/coloredBlocklight.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
vec4 albedo = texture2D(texture, texCoord) * vec4(color.rgb, 1.0);
|
||||
vec3 newNormal = normal;
|
||||
float smoothness = 0.0;
|
||||
vec3 lightAlbedo = vec3(0.0);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float surfaceDepth = 1.0;
|
||||
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
|
||||
float skipAdvMat = float(mat > 0.98 && mat < 1.02);
|
||||
|
||||
#ifdef PARALLAX
|
||||
if(skipAdvMat < 0.5) {
|
||||
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
|
||||
albedo = texture2DGradARB(texture, newCoord, dcdx, dcdy) * vec4(color.rgb, 1.0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 vlAlbedo = vec3(1.0);
|
||||
vec3 refraction = vec3(0.0);
|
||||
|
||||
float cloudBlendOpacity = 1.0;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
|
||||
|
||||
float water = float(mat > 0.98 && mat < 1.02);
|
||||
float glass = float(mat > 1.98 && mat < 2.02);
|
||||
float translucent = float(mat > 2.98 && mat < 3.02);
|
||||
float portal = float(mat > 3.98 && mat < 4.02);
|
||||
|
||||
float metalness = 0.0;
|
||||
float emission = portal;
|
||||
float subsurface = 0.0;
|
||||
float basicSubsurface = water;
|
||||
vec3 baseReflectance = vec3(0.04);
|
||||
|
||||
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
|
||||
|
||||
#ifndef REFLECTION_TRANSLUCENT
|
||||
glass = 0.0;
|
||||
translucent = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
#ifdef TAA
|
||||
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
|
||||
#else
|
||||
vec3 viewPos = ToNDC(screenPos);
|
||||
#endif
|
||||
vec3 worldPos = ToWorld(viewPos);
|
||||
|
||||
float dither = Bayer8(gl_FragCoord.xy);
|
||||
|
||||
#if CLOUDS == 2
|
||||
float cloudViewLength = texture2D(gaux1, screenPos.xy).r * (far * 2.0);
|
||||
|
||||
float viewLength = length(viewPos);
|
||||
cloudBlendOpacity = step(viewLength, cloudViewLength);
|
||||
|
||||
if (cloudBlendOpacity == 0) {
|
||||
discard;
|
||||
}
|
||||
// albedo.rgb *= fract(viewLength);
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#if WATER_NORMALS == 1 || WATER_NORMALS == 2
|
||||
if (water > 0.5) {
|
||||
normalMap = GetWaterNormal(worldPos, viewPos, viewVector);
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float f0 = 0.0, porosity = 0.5, ao = 1.0, skyOcclusion = 0.0;
|
||||
if (water < 0.5) {
|
||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||
newCoord, dcdx, dcdy);
|
||||
|
||||
if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector)
|
||||
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if REFRACTION == 1
|
||||
refraction = vec3((newNormal.xy - normal.xy) * 0.5 + 0.5, float(albedo.a < 0.95) * water);
|
||||
#elif REFRACTION == 2
|
||||
refraction = vec3((newNormal.xy - normal.xy) * 0.5 + 0.5, float(albedo.a < 0.95));
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMIC_HANDLIGHT
|
||||
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
|
||||
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
|
||||
lightmap.x = max(lightmap.x, handlight);
|
||||
#endif
|
||||
|
||||
#ifdef TOON_LIGHTMAP
|
||||
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
|
||||
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
|
||||
#endif
|
||||
|
||||
albedo.rgb = pow(albedo.rgb, vec3(2.2));
|
||||
|
||||
vlAlbedo = albedo.rgb;
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
vec3 opaquelightAlbedo = texture2D(colortex8, screenPos.xy).rgb;
|
||||
if (water < 0.5) {
|
||||
opaquelightAlbedo *= vlAlbedo;
|
||||
}
|
||||
lightAlbedo = albedo.rgb + 0.00001;
|
||||
|
||||
if (portal > 0.5) {
|
||||
lightAlbedo = lightAlbedo * 0.95 + 0.05;
|
||||
}
|
||||
|
||||
lightAlbedo = normalize(lightAlbedo + 0.00001) * emission;
|
||||
lightAlbedo = mix(opaquelightAlbedo, sqrt(lightAlbedo), albedo.a);
|
||||
#endif
|
||||
|
||||
#ifdef WHITE_WORLD
|
||||
albedo.rgb = vec3(0.35);
|
||||
#endif
|
||||
|
||||
if (water > 0.5) {
|
||||
#if WATER_MODE == 0
|
||||
albedo.rgb = waterColor.rgb * waterColor.a;
|
||||
#elif WATER_MODE == 1
|
||||
// do nothing
|
||||
#elif WATER_MODE == 2
|
||||
float waterLuma = length(albedo.rgb / pow(color.rgb, vec3(2.2))) * 2.0;
|
||||
albedo.rgb = waterLuma * waterColor.rgb * waterColor.a;
|
||||
#elif WATER_MODE == 3
|
||||
albedo.rgb = color.rgb * color.rgb * 0.35;
|
||||
#endif
|
||||
#if WATER_ALPHA_MODE == 0
|
||||
albedo.a = waterAlpha;
|
||||
#endif
|
||||
vlAlbedo = sqrt(albedo.rgb);
|
||||
baseReflectance = vec3(0.02);
|
||||
}
|
||||
|
||||
vlAlbedo = mix(vec3(1.0), vlAlbedo, sqrt(albedo.a)) * (1.0 - pow(albedo.a, 64.0));
|
||||
|
||||
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
|
||||
|
||||
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
|
||||
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
|
||||
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
|
||||
vanillaDiffuse*= vanillaDiffuse;
|
||||
|
||||
float parallaxShadow = 1.0;
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
vec3 rawAlbedo = albedo.rgb * 0.999 + 0.001;
|
||||
albedo.rgb *= ao;
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
albedo.rgb *= 1.0 - metalness * smoothness;
|
||||
#endif
|
||||
|
||||
#ifdef SELF_SHADOW
|
||||
if (lightmap.y > 0.0 && NoL > 0.0 && water < 0.5) {
|
||||
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
|
||||
tbnMatrix);
|
||||
}
|
||||
#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
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
|
||||
#endif
|
||||
|
||||
vec3 shadow = vec3(0.0);
|
||||
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
|
||||
vanillaDiffuse, parallaxShadow, emission, subsurface, basicSubsurface);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
float puddles = 0.0;
|
||||
#ifdef REFLECTION_RAIN
|
||||
if (water < 0.5) {
|
||||
puddles = GetPuddles(worldPos, newCoord, lightmap.y, NoU, wetness);
|
||||
}
|
||||
|
||||
ApplyPuddleToMaterial(puddles, albedo, smoothness, f0, porosity);
|
||||
|
||||
if (puddles > 0.001 && rainStrength > 0.001) {
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
vec3 puddleNormal = GetPuddleNormal(worldPos, viewPos, tbnMatrix);
|
||||
newNormal = normalize(
|
||||
mix(newNormal, puddleNormal, puddles * sqrt(1.0 - porosity) * rainStrength)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos)), 0.0, 1.0), 5.0);
|
||||
|
||||
if (water > 0.5 || ((translucent + glass) > 0.5 && albedo.a < 0.95)) {
|
||||
#if REFLECTION > 0
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
float reflectionMask = 0.0;
|
||||
|
||||
fresnel = fresnel * 0.98 + 0.02;
|
||||
fresnel*= max(1.0 - isEyeInWater * 0.5 * water, 0.5);
|
||||
// fresnel = 1.0;
|
||||
|
||||
#if REFLECTION == 2
|
||||
reflection = SimpleReflection(viewPos, newNormal, dither, reflectionMask);
|
||||
reflection.rgb = pow(reflection.rgb * 2.0, vec3(8.0));
|
||||
#endif
|
||||
|
||||
if (reflection.a < 1.0) {
|
||||
#ifdef OVERWORLD
|
||||
vec3 skyRefPos = reflect(normalize(viewPos), newNormal);
|
||||
skyReflection = GetSkyColor(skyRefPos, true);
|
||||
|
||||
#ifdef AURORA
|
||||
skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12);
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 1
|
||||
vec4 cloud = DrawCloudSkybox(skyRefPos * 100.0, 1.0, dither, lightCol, ambientCol, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
#if CLOUDS == 2
|
||||
vec3 cameraPos = GetReflectedCameraPos(worldPos, newNormal);
|
||||
float cloudViewLength = 0.0;
|
||||
|
||||
vec4 cloud = DrawCloudVolumetric(skyRefPos * 8192.0, cameraPos, 1.0, dither, lightCol, ambientCol, cloudViewLength, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
skyReflection *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
|
||||
float waterSkyOcclusion = lightmap.y;
|
||||
#if REFLECTION_SKY_FALLOFF > 1
|
||||
waterSkyOcclusion = clamp(1.0 - (1.0 - waterSkyOcclusion) * REFLECTION_SKY_FALLOFF, 0.0, 1.0);
|
||||
#endif
|
||||
waterSkyOcclusion *= waterSkyOcclusion;
|
||||
skyReflection *= waterSkyOcclusion;
|
||||
#endif
|
||||
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol.rgb * 0.04;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
skyReflection = endCol.rgb * 0.01;
|
||||
#endif
|
||||
|
||||
skyReflection *= clamp(1.0 - isEyeInWater, 0.0, 1.0);
|
||||
}
|
||||
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
|
||||
|
||||
#if defined OVERWORLD || defined END
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, 0.0, vec3(1.0));
|
||||
|
||||
vec3 specular = GetSpecularHighlight(newNormal, viewPos, 0.9, vec3(0.02),
|
||||
specularColor, shadow, color.a);
|
||||
#if ALPHA_BLEND == 0
|
||||
float specularAlpha = pow(mix(albedo.a, 1.0, fresnel), 2.2) * fresnel;
|
||||
#else
|
||||
float specularAlpha = mix(albedo.a , 1.0, fresnel) * fresnel;
|
||||
#endif
|
||||
|
||||
reflection.rgb += specular * (1.0 - reflectionMask) / specularAlpha;
|
||||
#endif
|
||||
|
||||
albedo.rgb = mix(albedo.rgb, reflection.rgb, fresnel);
|
||||
albedo.a = mix(albedo.a, 1.0, fresnel);
|
||||
#endif
|
||||
}else{
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
skyOcclusion = lightmap.y;
|
||||
#if REFLECTION_SKY_FALLOFF > 1
|
||||
skyOcclusion = clamp(1.0 - (1.0 - skyOcclusion) * REFLECTION_SKY_FALLOFF, 0.0, 1.0);
|
||||
#endif
|
||||
skyOcclusion *= skyOcclusion;
|
||||
|
||||
baseReflectance = mix(vec3(f0), rawAlbedo, metalness);
|
||||
|
||||
#ifdef REFLECTION_SPECULAR
|
||||
vec3 fresnel3 = mix(baseReflectance, vec3(1.0), fresnel);
|
||||
#if MATERIAL_FORMAT == 0
|
||||
if (f0 >= 0.9 && f0 < 1.0) {
|
||||
baseReflectance = GetMetalCol(f0);
|
||||
fresnel3 = ComplexFresnel(pow(fresnel, 0.2), f0);
|
||||
#ifdef ALBEDO_METAL
|
||||
fresnel3 *= rawAlbedo;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float aoSquared = ao * ao;
|
||||
shadow *= aoSquared; fresnel3 *= aoSquared * smoothness * smoothness;
|
||||
|
||||
if (smoothness > 0.0) {
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
float reflectionMask = 0.0;
|
||||
|
||||
float ssrMask = clamp(length(fresnel3) * 400.0 - 1.0, 0.0, 1.0);
|
||||
if(ssrMask > 0.0) reflection = SimpleReflection(viewPos, newNormal, dither, reflectionMask);
|
||||
reflection.rgb = pow(reflection.rgb * 2.0, vec3(8.0));
|
||||
reflection.a *= ssrMask;
|
||||
|
||||
if (reflection.a < 1.0) {
|
||||
#ifdef OVERWORLD
|
||||
vec3 skyRefPos = reflect(normalize(viewPos.xyz), newNormal);
|
||||
skyReflection = GetSkyColor(skyRefPos, true);
|
||||
|
||||
#ifdef AURORA
|
||||
skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12);
|
||||
#endif
|
||||
|
||||
#if CLOUDS == 1
|
||||
vec4 cloud = DrawCloudSkybox(skyRefPos * 100.0, 1.0, dither, lightCol, ambientCol, false);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
#if CLOUDS == 2
|
||||
vec3 cameraPos = GetReflectedCameraPos(worldPos, newNormal);
|
||||
float cloudViewLength = 0.0;
|
||||
|
||||
vec4 cloud = DrawCloudVolumetric(skyRefPos * 8192.0, cameraPos, 1.0, dither, lightCol, ambientCol, cloudViewLength, true);
|
||||
skyReflection = mix(skyReflection, cloud.rgb, cloud.a);
|
||||
#endif
|
||||
|
||||
#ifdef CLASSIC_EXPOSURE
|
||||
skyReflection *= 4.0 - 3.0 * eBS;
|
||||
#endif
|
||||
|
||||
skyReflection = mix(vanillaDiffuse * minLightCol, skyReflection, skyOcclusion);
|
||||
#endif
|
||||
|
||||
#ifdef NETHER
|
||||
skyReflection = netherCol.rgb * 0.04;
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
skyReflection = endCol.rgb * 0.01;
|
||||
#endif
|
||||
}
|
||||
|
||||
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflectionMask), vec3(0.0));
|
||||
|
||||
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * (1.0 - metalness)) +
|
||||
reflection.rgb * fresnel3;
|
||||
albedo.a = mix(albedo.a, 1.0, GetLuminance(fresnel3));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD || defined END
|
||||
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
|
||||
|
||||
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
|
||||
specularColor, shadow * vanillaDiffuse, color.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WATER_FOG == 1
|
||||
if((isEyeInWater == 0 && water > 0.5) || (isEyeInWater == 1 && water < 0.5)) {
|
||||
float opaqueDepth = texture2D(depthtex1, screenPos.xy).r;
|
||||
vec3 opaqueScreenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), opaqueDepth);
|
||||
#ifdef TAA
|
||||
vec3 opaqueViewPos = ToNDC(vec3(TAAJitter(opaqueScreenPos.xy, -0.5), opaqueScreenPos.z));
|
||||
#else
|
||||
vec3 opaqueViewPos = ToNDC(opaqueScreenPos);
|
||||
#endif
|
||||
|
||||
vec4 waterFog = GetWaterFog(opaqueViewPos - viewPos.xyz);
|
||||
albedo = mix(waterFog, vec4(albedo.rgb, 1.0), albedo.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
Fog(albedo.rgb, viewPos);
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
#endif
|
||||
}
|
||||
albedo.a *= cloudBlendOpacity;
|
||||
|
||||
/* DRAWBUFFERS:01 */
|
||||
gl_FragData[0] = albedo;
|
||||
gl_FragData[1] = vec4(vlAlbedo, 1.0);
|
||||
|
||||
#ifdef MULTICOLORED_BLOCKLIGHT
|
||||
/* DRAWBUFFERS:018 */
|
||||
gl_FragData[2] = vec4(lightAlbedo, 1.0);
|
||||
#if REFRACTION > 0
|
||||
/* DRAWBUFFERS:0186 */
|
||||
gl_FragData[3] = vec4(refraction, 1.0);
|
||||
#endif
|
||||
#else
|
||||
#if REFRACTION > 0
|
||||
/* DRAWBUFFERS:016 */
|
||||
gl_FragData[2] = vec4(refraction, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
varying float dist;
|
||||
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 normal, binormal, tangent;
|
||||
varying vec3 sunVec, upVec, eastVec;
|
||||
varying vec3 viewVector;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
varying vec4 vTexCoord, vTexCoordAM;
|
||||
#endif
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
|
||||
#ifdef TAA
|
||||
uniform int frameCounter;
|
||||
|
||||
uniform float viewWidth, viewHeight;
|
||||
#endif
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
attribute vec4 at_tangent;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Common Functions//
|
||||
float WavingWater(vec3 worldPos) {
|
||||
worldPos += cameraPosition;
|
||||
float fractY = fract(worldPos.y + 0.005);
|
||||
|
||||
float wave = sin(6.2831854 * (frametime * 0.7 + worldPos.x * 0.14 + worldPos.z * 0.07)) +
|
||||
sin(6.2831854 * (frametime * 0.5 + worldPos.x * 0.10 + worldPos.z * 0.20));
|
||||
if (fractY > 0.01) return wave * 0.0125;
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#ifdef TAA
|
||||
#include "/lib/util/jitter.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, vec2(0.0), vec2(0.9333, 1.0));
|
||||
|
||||
int blockID = int(mod(max(mc_Entity.x - 10000, 0), 10000));
|
||||
|
||||
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;
|
||||
|
||||
dist = length(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
#ifdef ADVANCED_MATERIALS
|
||||
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;
|
||||
#endif
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
if(color.a < 0.1) color.a = 1.0;
|
||||
|
||||
mat = 0.0;
|
||||
|
||||
if (blockID == 300 || blockID == 304) mat = 1.0;
|
||||
if (blockID == 301) mat = 2.0;
|
||||
if (blockID == 302) mat = 3.0;
|
||||
if (blockID == 303) mat = 4.0;
|
||||
|
||||
const vec2 sunRotationData = vec2(
|
||||
cos(sunPathRotation * 0.01745329251994),
|
||||
-sin(sunPathRotation * 0.01745329251994)
|
||||
);
|
||||
float ang = fract(timeAngle - 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);
|
||||
eastVec = normalize(gbufferModelView[0].xyz);
|
||||
|
||||
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
#ifdef WAVING_WATER
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
if (blockID == 300 || blockID == 302 || blockID == 304) position.y += WavingWater(position.xyz);
|
||||
#endif
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
position.y -= WorldCurvature(position.xz);
|
||||
#endif
|
||||
|
||||
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
||||
if (mat == 0.0) gl_Position.z -= 0.00001;
|
||||
|
||||
#ifdef TAA
|
||||
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 upVec, sunVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform int isEyeInWater;
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float nightVision;
|
||||
uniform float rainStrength;
|
||||
uniform float timeAngle, timeBrightness;
|
||||
uniform float viewWidth, viewHeight;
|
||||
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D depthtex0;
|
||||
|
||||
//Common Variables//
|
||||
float eBS = eyeBrightnessSmooth.y / 240.0;
|
||||
float sunVisibility = clamp(dot(sunVec, upVec) + 0.05, 0.0, 0.1) * 10.0;
|
||||
|
||||
//Common Functions//
|
||||
void Defog(inout vec3 albedo, float fogDensity) {
|
||||
float z = texture2D(depthtex0,gl_FragCoord.xy/vec2(viewWidth,viewHeight)).r;
|
||||
if (z == 1.0) return;
|
||||
|
||||
vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), z, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
float fog = length(viewPos) * fogDensity / 256.0;
|
||||
float clearDay = sunVisibility * (1.0 - rainStrength);
|
||||
fog *= (0.5 * rainStrength + 1.0) / (3.0 * clearDay + 1.0);
|
||||
fog = 1.0 - exp(-2.0 * pow(fog, 0.25 * clearDay + 1.25) * eBS);
|
||||
albedo.rgb /= 1.0 - fog;
|
||||
}
|
||||
|
||||
//Includes//
|
||||
#include "/lib/color/lightColor.glsl"
|
||||
#include "/lib/color/blocklightColor.glsl"
|
||||
#include "/lib/atmospherics/weatherDensity.glsl"
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if defined NETHER || defined END
|
||||
discard;
|
||||
#endif
|
||||
|
||||
vec4 albedo = vec4(0.0);
|
||||
|
||||
albedo.a = texture2D(texture, texCoord).a;
|
||||
|
||||
if (albedo.a > 0.001) {
|
||||
albedo.rgb = texture2D(texture, texCoord).rgb;
|
||||
|
||||
albedo.a *= 0.25 * rainStrength * length(albedo.rgb / 3.0) * float(albedo.a > 0.1);
|
||||
albedo.rgb = sqrt(albedo.rgb);
|
||||
albedo.rgb *= (ambientCol + lmCoord.x * lmCoord.x * blocklightCol) * WEATHER_OPACITY;
|
||||
|
||||
#if MC_VERSION < 10800
|
||||
albedo.a *= 4.0;
|
||||
albedo.rgb *= 0.525;
|
||||
#endif
|
||||
|
||||
#if defined FOG && MC_VERSION < 11500
|
||||
if (gl_FragCoord.z > 0.991) Defog(albedo.rgb, fogDensity);
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 0
|
||||
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
|
||||
albedo.a *= 1.4;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying vec2 texCoord, lmCoord;
|
||||
|
||||
varying vec3 sunVec, upVec;
|
||||
|
||||
//Uniforms//
|
||||
uniform float timeAngle;
|
||||
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
//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(timeAngle - 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();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord;
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
varying vec3 worldPos;
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int blockEntityId;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
#endif
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WATER_CAUSTICS
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
|
||||
float noise = 0.0;
|
||||
|
||||
vec2 wind = vec2(frametime) * 0.5 * WATER_SPEED;
|
||||
|
||||
worldPos.xz -= worldPos.y * 0.2;
|
||||
|
||||
#if WATER_NORMALS == 1
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).g;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 48.0 + offset).g;
|
||||
#elif WATER_NORMALS == 2
|
||||
offset /= 256.0;
|
||||
float noiseA = texture2D(noisetex, (worldPos.xz - wind) / 256.0 + offset).r;
|
||||
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 96.0 + offset).r;
|
||||
noiseA *= noiseA; noiseB *= noiseB;
|
||||
#endif
|
||||
|
||||
#if WATER_NORMALS > 0
|
||||
noise = mix(noiseA, noiseB, WATER_DETAIL);
|
||||
#endif
|
||||
|
||||
return noise * WATER_CAUSTICS_STRENGTH;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WATER_SHADOW_COLOR
|
||||
#include "/lib/color/waterColor.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
#if MC_VERSION >= 11300
|
||||
if (blockEntityId == 10205) discard;
|
||||
#endif
|
||||
|
||||
vec4 albedo = texture2D(tex, texCoord.xy);
|
||||
albedo.rgb *= color.rgb;
|
||||
|
||||
float premult = float(mat > 0.98 && mat < 1.02);
|
||||
float water = float(mat > 1.98 && mat < 2.02);
|
||||
float disable = float(mat > 2.98 && mat < 3.02);
|
||||
if (albedo.a < 0.01 || disable > 0.5) discard;
|
||||
|
||||
if (water > 0.5) {
|
||||
#if !defined WATER_SHADOW_COLOR && !defined WATER_CAUSTICS
|
||||
discard;
|
||||
#else
|
||||
#ifdef WATER_SHADOW_COLOR
|
||||
#if WATER_MODE == 0
|
||||
albedo.rgb = pow(waterColor.rgb / waterColor.a, vec3(0.25));
|
||||
#elif WATER_MODE == 1
|
||||
albedo.rgb = sqrt(albedo.rgb);
|
||||
#elif WATER_MODE == 2
|
||||
float waterLuma = length(albedo.rgb * albedo.rgb / pow(color.rgb, vec3(2.2))) * 2.0;
|
||||
albedo.rgb = sqrt(waterLuma * sqrt(waterColor.rgb / waterColor.a));
|
||||
#elif WATER_MODE == 3
|
||||
albedo.rgb = sqrt(color.rgb * 0.59);
|
||||
#endif
|
||||
|
||||
#if WATER_ALPHA_MODE == 0
|
||||
albedo.a = waterAlpha;
|
||||
#endif
|
||||
#else
|
||||
albedo.rgb = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
float normalOffset = WATER_SHARPNESS + 0.2;
|
||||
|
||||
float normalStrength = 0.35;
|
||||
|
||||
float h0 = GetWaterHeightMap(worldPos, vec2(0.0));
|
||||
float h1 = GetWaterHeightMap(worldPos, vec2( normalOffset, 0.0));
|
||||
float h2 = GetWaterHeightMap(worldPos, vec2(-normalOffset, 0.0));
|
||||
float h3 = GetWaterHeightMap(worldPos, vec2(0.0, normalOffset));
|
||||
float h4 = GetWaterHeightMap(worldPos, vec2(0.0, -normalOffset));
|
||||
|
||||
float xDeltaA = (h1 - h0) / normalOffset;
|
||||
float xDeltaB = (h2 - h0) / normalOffset;
|
||||
float yDeltaA = (h3 - h0) / normalOffset;
|
||||
float yDeltaB = (h4 - h0) / normalOffset;
|
||||
|
||||
float height = max((xDeltaA * -xDeltaB + yDeltaA * -yDeltaB), 0.0);
|
||||
|
||||
#if WATER_NORMALS == 1
|
||||
height *= 48.0;
|
||||
#elif WATER_NORMALS == 2
|
||||
height *= 24.0;
|
||||
#endif
|
||||
|
||||
#ifdef WATER_SHADOW_COLOR
|
||||
height /= length(albedo.rgb);
|
||||
#endif
|
||||
|
||||
height /= sqrt(height * height / 9.0 + 1.0);
|
||||
|
||||
albedo.rgb *= 1.0 + height;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SHADOW_COLOR
|
||||
albedo.rgb = mix(vec3(1.0), albedo.rgb, 1.0 - pow(1.0 - albedo.a, 1.5));
|
||||
albedo.rgb *= 1.0 - pow(albedo.a, 96.0);
|
||||
#else
|
||||
if ((premult > 0.5 && albedo.a < 0.98)) albedo.a = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
albedo.rgb *= 0.25;
|
||||
#endif
|
||||
|
||||
gl_FragData[0] = albedo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
varying float mat;
|
||||
|
||||
varying vec2 texCoord;
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
varying vec3 worldPos;
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
//Uniforms//
|
||||
uniform int worldTime;
|
||||
|
||||
uniform float frameTimeCounter;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
||||
uniform mat4 shadowProjection, shadowProjectionInverse;
|
||||
uniform mat4 shadowModelView, shadowModelViewInverse;
|
||||
|
||||
//Attributes//
|
||||
attribute vec4 mc_Entity;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
|
||||
//Common Variables//
|
||||
#ifdef WORLD_TIME_ANIMATION
|
||||
float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
|
||||
#else
|
||||
float frametime = frameTimeCounter * ANIMATION_SPEED;
|
||||
#endif
|
||||
|
||||
//Includes//
|
||||
#include "/lib/vertex/waving.glsl"
|
||||
|
||||
#ifdef WORLD_CURVATURE
|
||||
#include "/lib/vertex/worldCurvature.glsl"
|
||||
#endif
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
texCoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
int blockID = int(mod(max(mc_Entity.x - 10000, 0), 10000));
|
||||
|
||||
color = gl_Color;
|
||||
|
||||
mat = 0;
|
||||
if (blockID == 301 || blockID == 302) mat = 1;
|
||||
if (blockID == 300 || blockID == 304) mat = 2;
|
||||
|
||||
#ifndef SHADOW_VEGETATION
|
||||
if (blockID >= 100 && blockID <= 104) mat = 3;
|
||||
#endif
|
||||
|
||||
vec4 position = shadowModelViewInverse * shadowProjectionInverse * ftransform();
|
||||
|
||||
#ifdef WATER_CAUSTICS
|
||||
worldPos = position.xyz + cameraPosition.xyz;
|
||||
#endif
|
||||
|
||||
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
|
||||
position.xyz = WavingBlocks(position.xyz, blockID, istopv);
|
||||
|
||||
#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);
|
||||
|
||||
gl_Position.xy *= 1.0 / distortFactor;
|
||||
gl_Position.z = gl_Position.z * 0.2;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
BSL Shaders v8 Series by Capt Tatsu
|
||||
https://bitslablab.com
|
||||
*/
|
||||
|
||||
//Settings//
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
//Fragment Shader///////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FSH
|
||||
|
||||
//Varyings//
|
||||
|
||||
//Uniforms//
|
||||
|
||||
//Attributes//
|
||||
|
||||
//Optifine Constants//
|
||||
|
||||
//Common Variables//
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef VSH
|
||||
|
||||
//Varyings//
|
||||
|
||||
//Uniforms//
|
||||
|
||||
//Attributes//
|
||||
|
||||
//Optifine Constants//
|
||||
|
||||
//Common Variables//
|
||||
|
||||
//Common Functions//
|
||||
|
||||
//Includes//
|
||||
|
||||
//Program//
|
||||
void main() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user