jsp
This commit is contained in:
+200
@@ -0,0 +1,200 @@
|
||||
#if FXAA_TAA_INTERACTION > 0
|
||||
ivec2 neighbourhoodOffsets[8] = ivec2[8](
|
||||
ivec2( 1, 1),
|
||||
ivec2( 1,-1),
|
||||
ivec2(-1, 1),
|
||||
ivec2(-1,-1),
|
||||
ivec2( 1, 0),
|
||||
ivec2( 0, 1),
|
||||
ivec2(-1, 0),
|
||||
ivec2( 0,-1)
|
||||
);
|
||||
#endif
|
||||
|
||||
//FXAA 3.11 from http://blog.simonrodriguez.fr/articles/30-07-2016_implementing_fxaa.html
|
||||
float quality[12] = float[12] (1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0);
|
||||
|
||||
void FXAA311(inout vec3 color) {
|
||||
float edgeThresholdMin = 0.03125;
|
||||
float edgeThresholdMax = 0.0625;
|
||||
float subpixelQuality = 0.75;
|
||||
int iterations = 12;
|
||||
|
||||
vec2 view = 1.0 / vec2(viewWidth, viewHeight);
|
||||
|
||||
float lumaCenter = GetLuminance(color);
|
||||
float lumaDown = GetLuminance(texelFetch(colortex3, texelCoord + ivec2( 0, -1), 0).rgb);
|
||||
float lumaUp = GetLuminance(texelFetch(colortex3, texelCoord + ivec2( 0, 1), 0).rgb);
|
||||
float lumaLeft = GetLuminance(texelFetch(colortex3, texelCoord + ivec2(-1, 0), 0).rgb);
|
||||
float lumaRight = GetLuminance(texelFetch(colortex3, texelCoord + ivec2( 1, 0), 0).rgb);
|
||||
|
||||
float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
|
||||
float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));
|
||||
|
||||
float lumaRange = lumaMax - lumaMin;
|
||||
|
||||
if (lumaRange > max(edgeThresholdMin, lumaMax * edgeThresholdMax)) {
|
||||
float lumaDownLeft = GetLuminance(texelFetch(colortex3, texelCoord + ivec2(-1, -1), 0).rgb);
|
||||
float lumaUpRight = GetLuminance(texelFetch(colortex3, texelCoord + ivec2( 1, 1), 0).rgb);
|
||||
float lumaUpLeft = GetLuminance(texelFetch(colortex3, texelCoord + ivec2(-1, 1), 0).rgb);
|
||||
float lumaDownRight = GetLuminance(texelFetch(colortex3, texelCoord + ivec2( 1, -1), 0).rgb);
|
||||
|
||||
float lumaDownUp = lumaDown + lumaUp;
|
||||
float lumaLeftRight = lumaLeft + lumaRight;
|
||||
|
||||
float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
|
||||
float lumaDownCorners = lumaDownLeft + lumaDownRight;
|
||||
float lumaRightCorners = lumaDownRight + lumaUpRight;
|
||||
float lumaUpCorners = lumaUpRight + lumaUpLeft;
|
||||
|
||||
float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners ) +
|
||||
abs(-2.0 * lumaCenter + lumaDownUp ) * 2.0 +
|
||||
abs(-2.0 * lumaRight + lumaRightCorners);
|
||||
float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners ) +
|
||||
abs(-2.0 * lumaCenter + lumaLeftRight ) * 2.0 +
|
||||
abs(-2.0 * lumaDown + lumaDownCorners );
|
||||
|
||||
bool isHorizontal = (edgeHorizontal >= edgeVertical);
|
||||
|
||||
float luma1 = isHorizontal ? lumaDown : lumaLeft;
|
||||
float luma2 = isHorizontal ? lumaUp : lumaRight;
|
||||
float gradient1 = luma1 - lumaCenter;
|
||||
float gradient2 = luma2 - lumaCenter;
|
||||
|
||||
bool is1Steepest = abs(gradient1) >= abs(gradient2);
|
||||
float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));
|
||||
|
||||
float stepLength = isHorizontal ? view.y : view.x;
|
||||
|
||||
float lumaLocalAverage = 0.0;
|
||||
|
||||
if (is1Steepest) {
|
||||
stepLength = - stepLength;
|
||||
lumaLocalAverage = 0.5 * (luma1 + lumaCenter);
|
||||
} else {
|
||||
lumaLocalAverage = 0.5 * (luma2 + lumaCenter);
|
||||
}
|
||||
|
||||
vec2 currentUv = texCoord;
|
||||
if (isHorizontal) {
|
||||
currentUv.y += stepLength * 0.5;
|
||||
} else {
|
||||
currentUv.x += stepLength * 0.5;
|
||||
}
|
||||
|
||||
vec2 offset = isHorizontal ? vec2(view.x, 0.0) : vec2(0.0, view.y);
|
||||
|
||||
vec2 uv1 = currentUv - offset;
|
||||
vec2 uv2 = currentUv + offset;
|
||||
float lumaEnd1 = GetLuminance(texture2D(colortex3, uv1).rgb);
|
||||
float lumaEnd2 = GetLuminance(texture2D(colortex3, uv2).rgb);
|
||||
lumaEnd1 -= lumaLocalAverage;
|
||||
lumaEnd2 -= lumaLocalAverage;
|
||||
|
||||
bool reached1 = abs(lumaEnd1) >= gradientScaled;
|
||||
bool reached2 = abs(lumaEnd2) >= gradientScaled;
|
||||
bool reachedBoth = reached1 && reached2;
|
||||
|
||||
if (!reached1) {
|
||||
uv1 -= offset;
|
||||
}
|
||||
if (!reached2) {
|
||||
uv2 += offset;
|
||||
}
|
||||
|
||||
if (!reachedBoth) {
|
||||
for (int i = 2; i < iterations; i++) {
|
||||
if (!reached1) {
|
||||
lumaEnd1 = GetLuminance(texture2D(colortex3, uv1).rgb);
|
||||
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
|
||||
}
|
||||
if (!reached2) {
|
||||
lumaEnd2 = GetLuminance(texture2D(colortex3, uv2).rgb);
|
||||
lumaEnd2 = lumaEnd2 - lumaLocalAverage;
|
||||
}
|
||||
|
||||
reached1 = abs(lumaEnd1) >= gradientScaled;
|
||||
reached2 = abs(lumaEnd2) >= gradientScaled;
|
||||
reachedBoth = reached1 && reached2;
|
||||
|
||||
if (!reached1) {
|
||||
uv1 -= offset * quality[i];
|
||||
}
|
||||
if (!reached2) {
|
||||
uv2 += offset * quality[i];
|
||||
}
|
||||
|
||||
if (reachedBoth) break;
|
||||
}
|
||||
}
|
||||
|
||||
float distance1 = isHorizontal ? (texCoord.x - uv1.x) : (texCoord.y - uv1.y);
|
||||
float distance2 = isHorizontal ? (uv2.x - texCoord.x) : (uv2.y - texCoord.y);
|
||||
|
||||
bool isDirection1 = distance1 < distance2;
|
||||
float distanceFinal = min(distance1, distance2);
|
||||
|
||||
float edgeThickness = (distance1 + distance2);
|
||||
|
||||
float pixelOffset = - distanceFinal / edgeThickness + 0.5;
|
||||
|
||||
bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;
|
||||
|
||||
bool correctVariation = ((isDirection1 ? lumaEnd1 : lumaEnd2) < 0.0) != isLumaCenterSmaller;
|
||||
|
||||
float finalOffset = correctVariation ? pixelOffset : 0.0;
|
||||
|
||||
float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);
|
||||
float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);
|
||||
float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
|
||||
float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * subpixelQuality;
|
||||
|
||||
finalOffset = max(finalOffset, subPixelOffsetFinal);
|
||||
|
||||
// Compute the final UV coordinates.
|
||||
vec2 finalUv = texCoord;
|
||||
if (isHorizontal) {
|
||||
finalUv.y += finalOffset * stepLength;
|
||||
} else {
|
||||
finalUv.x += finalOffset * stepLength;
|
||||
}
|
||||
|
||||
vec3 newColor = texture2D(colortex3, finalUv).rgb;
|
||||
|
||||
#define FXAA_STRENGTH_SKIP 1.0 - FXAA_STRENGTH * 0.01
|
||||
|
||||
#if FXAA_TAA_INTERACTION > 0
|
||||
// Less FXAA when moving
|
||||
float skipFXAA = min(
|
||||
20.0 * length(cameraPosition - previousCameraPosition),
|
||||
FXAA_TAA_INTERACTION * 0.1
|
||||
);
|
||||
|
||||
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
|
||||
float z1 = texelFetch(depthtex1, texelCoord, 0).r;
|
||||
bool edge = false;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ivec2 texelCoordM = texelCoord + neighbourhoodOffsets[i];
|
||||
|
||||
float z0Check = texelFetch(depthtex0, texelCoordM, 0).r;
|
||||
float z1Check = texelFetch(depthtex1, texelCoordM, 0).r;
|
||||
if (max(abs(GetLinearDepth(z0Check) - GetLinearDepth(z0)), abs(GetLinearDepth(z1Check) - GetLinearDepth(z1))) > 0.09) {
|
||||
edge = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (edge) skipFXAA = 0.0;
|
||||
|
||||
if (dot(texelFetch(colortex2, texelCoord, 0).rgb, vec3(1.0)) < 0.01) skipFXAA = 0.0;
|
||||
|
||||
skipFXAA = mix(skipFXAA, 1.0, FXAA_STRENGTH_SKIP);
|
||||
#else
|
||||
float skipFXAA = FXAA_STRENGTH_SKIP;
|
||||
#endif
|
||||
|
||||
color = mix(newColor, color, skipFXAA);
|
||||
|
||||
// debug
|
||||
//if (skipFXAA > texCoord.y && texCoord.x < 0.02) color.rgb = vec3(1,0,1);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// Jitter offset from Chocapic13
|
||||
vec2 jitterOffsets[8] = vec2[8](
|
||||
vec2( 0.125,-0.375),
|
||||
vec2(-0.125, 0.375),
|
||||
vec2( 0.625, 0.125),
|
||||
vec2( 0.375,-0.625),
|
||||
vec2(-0.625, 0.625),
|
||||
vec2(-0.875,-0.125),
|
||||
vec2( 0.375,-0.875),
|
||||
vec2( 0.875, 0.875)
|
||||
);
|
||||
|
||||
vec2 TAAJitter(vec2 coord, float w) {
|
||||
#if TAA_JITTER > 0
|
||||
vec2 offset = jitterOffsets[int(framemod8)] * (w / vec2(viewWidth, viewHeight));
|
||||
#if TAA_JITTER == 1
|
||||
offset *= 0.125;
|
||||
#elif TAA_JITTER == 2
|
||||
offset *= 0.33;
|
||||
#endif
|
||||
return coord + offset;
|
||||
#else
|
||||
return coord;
|
||||
#endif
|
||||
}
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
#if TAA_SMOOTHING == 2
|
||||
float blendMinimum = 0.3;
|
||||
float blendVariable = 0.3;
|
||||
float blendConstant = 0.6;
|
||||
|
||||
float regularEdge = 10.0;
|
||||
float extraEdgeMult = 2.0;
|
||||
|
||||
float farEdgeDist = 128.0;
|
||||
#elif TAA_SMOOTHING == 3
|
||||
float blendMinimum = 0.35;
|
||||
float blendVariable = 0.2;
|
||||
float blendConstant = 0.7;
|
||||
|
||||
float regularEdge = 6.0;
|
||||
float extraEdgeMult = 3.0;
|
||||
|
||||
float farEdgeDist = 112.0;
|
||||
#elif TAA_SMOOTHING == 4
|
||||
float blendMinimum = 0.5;
|
||||
float blendVariable = 0.15;
|
||||
float blendConstant = 0.75;
|
||||
|
||||
float regularEdge = 4.0;
|
||||
float extraEdgeMult = 3.5;
|
||||
|
||||
float farEdgeDist = 96.0;
|
||||
#endif
|
||||
|
||||
#if TAA_MOVEMENT_IMPROVEMENT_FILTER == 1
|
||||
//Catmull-Rom sampling from Filmic SMAA presentation
|
||||
vec3 textureCatmullRom(sampler2D colortex, vec2 texcoord, vec2 view) {
|
||||
vec2 position = texcoord * view;
|
||||
vec2 centerPosition = floor(position - 0.5) + 0.5;
|
||||
vec2 f = position - centerPosition;
|
||||
vec2 f2 = f * f;
|
||||
vec2 f3 = f * f2;
|
||||
|
||||
float c = 0.7;
|
||||
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
|
||||
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
|
||||
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
|
||||
vec2 w3 = c * f3 - c * f2;
|
||||
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 tc12 = (centerPosition + w2 / w12) / view;
|
||||
|
||||
vec2 tc0 = (centerPosition - 1.0) / view;
|
||||
vec2 tc3 = (centerPosition + 2.0) / view;
|
||||
vec4 color = vec4(texture2DLod(colortex, vec2(tc12.x, tc0.y ), 0).rgb, 1.0) * (w12.x * w0.y ) +
|
||||
vec4(texture2DLod(colortex, vec2(tc0.x, tc12.y), 0).rgb, 1.0) * (w0.x * w12.y) +
|
||||
vec4(texture2DLod(colortex, vec2(tc12.x, tc12.y), 0).rgb, 1.0) * (w12.x * w12.y) +
|
||||
vec4(texture2DLod(colortex, vec2(tc3.x, tc12.y), 0).rgb, 1.0) * (w3.x * w12.y) +
|
||||
vec4(texture2DLod(colortex, vec2(tc12.x, tc3.y ), 0).rgb, 1.0) * (w12.x * w3.y );
|
||||
return color.rgb / color.a;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Previous frame reprojection from Chocapic13
|
||||
vec2 Reprojection(vec4 viewPos1) {
|
||||
vec4 pos = gbufferModelViewInverse * viewPos1;
|
||||
vec4 previousPosition = pos + vec4(cameraPosition - previousCameraPosition, 0.0);
|
||||
previousPosition = gbufferPreviousModelView * previousPosition;
|
||||
previousPosition = gbufferPreviousProjection * previousPosition;
|
||||
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
|
||||
}
|
||||
vec2 Reprojection(vec3 pos, mat4 projectionInverse, mat4 previousProjection) {
|
||||
pos = pos * 2.0 - 1.0;
|
||||
|
||||
vec4 viewPosPrev = projectionInverse * vec4(pos, 1.0);
|
||||
viewPosPrev /= viewPosPrev.w;
|
||||
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
|
||||
|
||||
vec4 previousPosition = viewPosPrev + vec4(cameraPosition - previousCameraPosition, 0.0);
|
||||
previousPosition = gbufferPreviousModelView * previousPosition;
|
||||
previousPosition = previousProjection * previousPosition;
|
||||
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 ClipAABB(vec3 q, vec3 aabb_min, vec3 aabb_max){
|
||||
vec3 p_clip = 0.5 * (aabb_max + aabb_min);
|
||||
vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001;
|
||||
|
||||
vec3 v_clip = q - vec3(p_clip);
|
||||
vec3 v_unit = v_clip.xyz / e_clip;
|
||||
vec3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return vec3(p_clip) + v_clip / ma_unit;
|
||||
else
|
||||
return q;
|
||||
}
|
||||
|
||||
ivec2 neighbourhoodOffsets[8] = ivec2[8](
|
||||
ivec2( 1, 1),
|
||||
ivec2( 1,-1),
|
||||
ivec2(-1, 1),
|
||||
ivec2(-1,-1),
|
||||
ivec2( 1, 0),
|
||||
ivec2( 0, 1),
|
||||
ivec2(-1, 0),
|
||||
ivec2( 0,-1)
|
||||
);
|
||||
|
||||
void NeighbourhoodClamping(vec3 color, inout vec3 tempColor, float z0, float z1, inout float edge) {
|
||||
vec3 minclr = color; vec3 maxclr = minclr;
|
||||
|
||||
int cc = 2;
|
||||
ivec2 texelCoordM1 = clamp(texelCoord, ivec2(cc), ivec2(view) - cc); // Fixes screen edges
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ivec2 texelCoordM2 = texelCoordM1 + neighbourhoodOffsets[i];
|
||||
|
||||
float z0CheckLinear = GetLinearDepth(texelFetch(depthtex0, texelCoordM2, 0).r);
|
||||
float z1CheckLinear = GetLinearDepth(texelFetch(depthtex1, texelCoordM2, 0).r);
|
||||
float z0Linear = GetLinearDepth(z0);
|
||||
float z1Linear = GetLinearDepth(z1);
|
||||
if (max(abs(z0CheckLinear - z0Linear), abs(z1CheckLinear - z1Linear)) > 0.09) {
|
||||
edge = regularEdge;
|
||||
|
||||
float approxClosestDist = min(z0CheckLinear, z0Linear) * far;
|
||||
if (approxClosestDist < farEdgeDist)
|
||||
if (int(texelFetch(colortex6, texelCoordM2, 0).g * 255.1) == 253) // Reduced Edge TAA (Leaves)
|
||||
edge *= extraEdgeMult;
|
||||
}
|
||||
|
||||
vec3 clr = texelFetch(colortex3, texelCoordM2, 0).rgb;
|
||||
minclr = min(minclr, clr); maxclr = max(maxclr, clr);
|
||||
}
|
||||
|
||||
tempColor = ClipAABB(tempColor, minclr, maxclr);
|
||||
}
|
||||
|
||||
void DoTAA(inout vec3 color, inout vec3 temp, float z1) {
|
||||
int materialMask = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
|
||||
|
||||
vec4 screenPos1 = vec4(texCoord, z1, 1.0);
|
||||
vec4 viewPos1 = gbufferProjectionInverse * (screenPos1 * 2.0 - 1.0);
|
||||
viewPos1 /= viewPos1.w;
|
||||
float lViewPos1 = length(viewPos1);
|
||||
|
||||
#ifdef ENTITY_TAA_NOISY_CLOUD_FIX
|
||||
float cloudLinearDepth = texture2D(colortex5, texCoord).a;
|
||||
|
||||
if (pow2(cloudLinearDepth) * renderDistance < min(lViewPos1, renderDistance)) {
|
||||
// Material in question is obstructed by the cloud volume
|
||||
materialMask = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (
|
||||
abs(materialMask - 149.5) < 50.0 // Entity Reflection Handling (see common.glsl for details)
|
||||
|| materialMask == 254 // No SSAO, No TAA, Reduce Reflection
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (materialMask == 254) { // No SSAO, No TAA, Reduce Reflection
|
||||
#ifndef CUSTOM_PBR
|
||||
if (z1 <= 0.56) return; // The edge pixel trick doesn't look nice on hand
|
||||
#endif
|
||||
int i = 0;
|
||||
while (i < 4) {
|
||||
int mms = int(texelFetch(colortex6, texelCoord + neighbourhoodOffsets[i], 0).g * 255.1);
|
||||
if (mms != materialMask) break;
|
||||
i++;
|
||||
} // Checking edge-pixels prevents flickering
|
||||
if (i == 4) return;
|
||||
}*/
|
||||
|
||||
float z0 = texelFetch(depthtex0, texelCoord, 0).r;
|
||||
|
||||
vec2 prvCoord = texCoord;
|
||||
if (z1 > 0.56) prvCoord = Reprojection(viewPos1);
|
||||
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
bool lodChunk = false;
|
||||
if (z1 == 1.0) {
|
||||
#ifdef VOXY
|
||||
float vxDepth = texture2D(vxDepthTexOpaque, texCoord).r;
|
||||
if (vxDepth < 1.0) {
|
||||
vec3 vxCoord = vec3(texCoord, vxDepth);
|
||||
prvCoord = Reprojection(vxCoord, vxProjInv, vxProjPrev);
|
||||
lodChunk = true;
|
||||
}
|
||||
#elif defined DISTANT_HORIZONS
|
||||
float dhDepth = texture2D(dhDepthTex1, texCoord).r;
|
||||
if (dhDepth < 1.0) {
|
||||
vec3 dhCoord = vec3(texCoord, dhDepth);
|
||||
prvCoord = Reprojection(dhCoord, dhProjectionInverse, dhPreviousProjection);
|
||||
lodChunk = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TAA_MOVEMENT_IMPROVEMENT_FILTER == 1
|
||||
vec3 tempColor = textureCatmullRom(colortex2, prvCoord, view);
|
||||
#else
|
||||
vec3 tempColor = texture2D(colortex2, prvCoord).rgb;
|
||||
#endif
|
||||
|
||||
if (tempColor == vec3(0.0) || any(isnan(tempColor))) { // Fixes the first frame and nans
|
||||
temp = color;
|
||||
return;
|
||||
}
|
||||
|
||||
float edge = 0.0;
|
||||
NeighbourhoodClamping(color, tempColor, z0, z1, edge);
|
||||
|
||||
if (materialMask == 253) // Reduced Edge TAA (Leaves)
|
||||
edge *= extraEdgeMult;
|
||||
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
if (lodChunk) {
|
||||
blendMinimum = 0.75;
|
||||
blendVariable = 0.05;
|
||||
blendConstant = 0.85;
|
||||
edge = 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec2 velocity = (texCoord - prvCoord.xy) * view;
|
||||
float blendFactor = float(prvCoord.x > 0.0 && prvCoord.x < 1.0 &&
|
||||
prvCoord.y > 0.0 && prvCoord.y < 1.0);
|
||||
float velocityFactor = dot(velocity, velocity) * 10.0;
|
||||
|
||||
#ifdef END
|
||||
if (z1 == 1.0)
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
if (!lodChunk)
|
||||
#endif
|
||||
{
|
||||
blendVariable *= 0.0;
|
||||
#if LIGHTSHAFT_QUALI_DEFINE == 2 // Medium (Default)
|
||||
edge = max(edge, regularEdge * 0.5);
|
||||
#elif LIGHTSHAFT_QUALI_DEFINE == 3 // High
|
||||
edge = max(edge, regularEdge * 0.75);
|
||||
#elif LIGHTSHAFT_QUALI_DEFINE == 4 // Very High
|
||||
edge = max(edge, regularEdge);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
blendFactor *= max(exp(-velocityFactor) * blendVariable + blendConstant - min(length(cameraPosition - previousCameraPosition), 0.05) * edge, blendMinimum);
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
blendFactor *= 1.0 - isLightningActive();
|
||||
#endif
|
||||
|
||||
#ifdef MIRROR_DIMENSION
|
||||
blendFactor = 0.0;
|
||||
#endif
|
||||
|
||||
color = mix(color, tempColor, blendFactor);
|
||||
temp = color;
|
||||
|
||||
//if (edge > 0.05) color.rgb = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
#if !defined AURORA_BOREALIS_GLSL
|
||||
#define AURORA_BOREALIS_GLSL
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
#include "/lib/colors/colorMultipliers.glsl"
|
||||
#endif
|
||||
#include "/lib/util/colorConversion.glsl"
|
||||
|
||||
#define AURORA_COLOR_PRESET 0 //[-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14] // 0 is manual and default, 1 is daily, 2 is monthly and 3 is one color preset same with all numbers after
|
||||
|
||||
#define AURORA_UP_R 112 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_UP_G 36 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_UP_B 192 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_UP_I 33 //[0 3 5 8 10 13 15 18 20 23 25 28 30 33 35 38 40 43 45 48 50 53 55 58 60 63 65 68 70 73 75 78 80 83 85 88 90 93 95 98 100]
|
||||
|
||||
#define AURORA_DOWN_R 96 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_DOWN_G 255 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_DOWN_B 192 //[0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 255]
|
||||
#define AURORA_DOWN_I 33 //[0 3 5 8 10 13 15 18 20 23 25 28 30 33 35 38 40 43 45 48 50 53 55 58 60 63 65 68 70 73 75 78 80 83 85 88 90 93 95 98 100]
|
||||
|
||||
#define AURORA_SIZE 1.00 //[0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 2.30 2.35 2.40 2.45 2.50 2.55 2.60 2.65 2.70 2.75 2.80 2.85 2.90 2.95 3.00]
|
||||
|
||||
//#define RGB_AURORA
|
||||
|
||||
#define AURORA_CLOUD_INFLUENCE_INTENSITY 1.00 //[0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.50 3.00]
|
||||
#define AURORA_TERRAIN_INFLUENCE_INTENSITY 1.00 //[0.00 0.25 0.50 0.75 1.00 1.25 1.50]
|
||||
|
||||
#define AURORA_NOISE_SCALE 1.00 //[0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 2.30 2.35 2.40 2.45 2.50 2.55 2.60 2.65 2.70 2.75 2.80 2.85 2.90 2.95 3.00 3.05 3.10 3.15 3.20 3.25 3.30 3.35 3.40 3.45 3.50 3.55 3.60 3.65 3.70 3.75 3.80 3.85 3.90 3.95 4.00 4.05 4.10 4.15 4.20 4.25 4.30 4.35 4.40 4.45 4.50 4.55 4.60 4.65 4.70 4.75 4.80 4.85 4.90 4.95 5.00]
|
||||
#define AURORA_PATTERN_WARP 0 //[0 1 2 3 4 5 6 7 8 9 10]
|
||||
#define AURORA_SATURATION 10 //[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
|
||||
#define AURORA_COLOR_MIX_POWER 2.0 //[0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0]
|
||||
|
||||
#include "/lib/atmospherics/auroraBorealisVisibility.glsl"
|
||||
|
||||
vec3 auroraUpA[] = vec3[](
|
||||
vec3(112.0, 36.0, 192.0), // [1] [2] Complementary
|
||||
vec3(112.0, 80.0, 255.0), // [3] Legacy Complementary (v4)
|
||||
vec3(168.0, 36.0, 88.0), // [4] permafrost
|
||||
vec3(255.0, 68.0, 124.0), // [5] Blossoming Lights (Pink)
|
||||
vec3(72.0, 96.0, 192.0), // [6] Nebula
|
||||
vec3(24.0, 255.0, 140.0), // [7] Celestial Dance
|
||||
vec3(255.0, 220.0, 255.0), // [8] Green Flash
|
||||
vec3(64.0, 255.0, 255.0), // [9] Ethereal Lights
|
||||
vec3(0.0, 20.0, 60.0), // [10] Glacial Blessing
|
||||
vec3(132.0, 0.0, 200.0), // [11] Mythical Lights
|
||||
vec3(120.0, 212.0, 56.0), // [12] watermelon
|
||||
vec3(0.0, 255.0, 255.0), // [13] blood bath
|
||||
vec3(255.0, 80.0, 112.0) // [14] Ghost
|
||||
);
|
||||
vec3 auroraDownA[] = vec3[](
|
||||
vec3(96.0, 255.0, 192.0), // [1] [2] Complementary
|
||||
vec3(80.0, 255.0, 180.0), // [3] Legacy Complementary (v4)
|
||||
vec3(60.0, 184.0, 152.0), // [4] permafrost
|
||||
vec3(160.0, 96.0, 255.0), // [5] Blossoming Lights (Pink)
|
||||
vec3(172.0, 44.0, 88.0), // [6] Nebula
|
||||
vec3(108.0, 72.0, 255.0), // [7] Celestial Dance
|
||||
vec3(68.0, 255.0, 72.0), // [8] Green Flash
|
||||
vec3(128.0, 64.0, 128.0), // [9] Ethereal Lights
|
||||
vec3(0.0, 24.0, 36.0), // [10] Glacial Blessing
|
||||
vec3(56.0, 168.0, 255.0), // [11] Mythical Lights
|
||||
vec3(176.0, 88.0, 72.0), // [12] watermelon
|
||||
vec3(180.0, 0.0, 0.0), // [13] blood bath
|
||||
vec3(80.0, 255.0, 180.0) // [14] Ghost
|
||||
);
|
||||
|
||||
vec2 warpAuroraCoords(vec2 coord, float warpAmount) {
|
||||
float angle = texture2D(noisetex, coord * 0.5).r * 6.28318 * warpAmount;
|
||||
float strength = texture2D(noisetex, coord * 0.7 + 0.5).r * warpAmount;
|
||||
vec2 offset = vec2(cos(angle), sin(angle)) * strength;
|
||||
return coord + offset;
|
||||
}
|
||||
|
||||
void GetAuroraColor(in vec2 wpos, out vec3 auroraUp, out vec3 auroraDown) {
|
||||
#ifdef RGB_AURORA
|
||||
auroraUp = getRainbowColor(wpos, 0.06);
|
||||
auroraDown = getRainbowColor(wpos, 0.05);
|
||||
#elif AURORA_COLOR_PRESET == 0
|
||||
auroraUp = vec3(AURORA_UP_R, AURORA_UP_G, AURORA_UP_B);
|
||||
auroraDown = vec3(AURORA_DOWN_R, AURORA_DOWN_G, AURORA_DOWN_B);
|
||||
#elif AURORA_COLOR_PRESET == -1
|
||||
float randomValue = hash11(float(worldDay));
|
||||
randomValue = pow(randomValue, 0.7); // Bias towards higher values (more transitions)
|
||||
float transitionsPerNight = min(randomValue * 2.0, 1.75);
|
||||
float idx, frac = modf(nightFactor * transitionsPerNight, idx);
|
||||
|
||||
int dayOffset = worldDay % auroraUpA.length();
|
||||
|
||||
int colorsCount = auroraUpA.length();
|
||||
int i0 = (int(idx) + dayOffset) % colorsCount;
|
||||
int i1 = (i0 + 1) % colorsCount;
|
||||
|
||||
// Interpolate in OKLab color space for perceptually uniform transitions
|
||||
vec3 oklabUp0 = rgb2oklab(auroraUpA[i0] / 255.0);
|
||||
vec3 oklabUp1 = rgb2oklab(auroraUpA[i1] / 255.0);
|
||||
vec3 oklabDown0 = rgb2oklab(auroraDownA[i0] / 255.0);
|
||||
vec3 oklabDown1 = rgb2oklab(auroraDownA[i1] / 255.0);
|
||||
|
||||
auroraUp = oklab2rgb(mix(oklabUp0, oklabUp1, frac)) * 255.0;
|
||||
auroraDown = oklab2rgb(mix(oklabDown0, oklabDown1, frac)) * 255.0;
|
||||
#else
|
||||
#if AURORA_COLOR_PRESET == 1
|
||||
int p = worldDay % auroraUpA.length();
|
||||
#elif AURORA_COLOR_PRESET == 2
|
||||
int p = worldDay % (auroraUpA.length() * 8) / 8;
|
||||
#else
|
||||
const int p = AURORA_COLOR_PRESET - 2;
|
||||
#endif
|
||||
|
||||
auroraUp = auroraUpA[p];
|
||||
auroraDown = auroraDownA[p];
|
||||
#endif
|
||||
auroraUp = max(auroraUp, vec3(0.001));
|
||||
auroraDown = max(auroraDown, vec3(0.001));
|
||||
|
||||
auroraUp *= (AURORA_UP_I * 0.093 + 3.1) / GetLuminance(auroraUp);
|
||||
auroraDown *= (AURORA_DOWN_I * 0.245 + 8.15) / GetLuminance(auroraDown);
|
||||
|
||||
#if AURORA_SATURATION != 10
|
||||
auroraUp = rgb2hsv(auroraUp);
|
||||
auroraUp.g *= AURORA_SATURATION * 0.1;
|
||||
auroraUp = hsv2rgb(auroraUp);
|
||||
|
||||
auroraDown = rgb2hsv(auroraDown);
|
||||
auroraDown.g *= AURORA_SATURATION * 0.1;
|
||||
auroraDown = hsv2rgb(auroraDown);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 getAuroraAmbientColor(vec3 color, vec3 viewPos, float multiplier, float influence, float VdotUAmount) {
|
||||
float visibility = GetAuroraVisibility(0.5, VdotUAmount);
|
||||
if (visibility > 0) {
|
||||
vec3 wpos = (gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz;
|
||||
wpos.xz /= (abs(wpos.y) + length(wpos.xz));
|
||||
|
||||
vec3 auroraUp, auroraDown;
|
||||
GetAuroraColor(wpos.xz, auroraUp, auroraDown);
|
||||
|
||||
vec3 auroraColor = mix(auroraUp, auroraDown, 0.8);
|
||||
#ifdef COMPOSITE1
|
||||
visibility *= influence;
|
||||
return mix(color, auroraColor, visibility);
|
||||
#endif
|
||||
auroraColor *= multiplier;
|
||||
visibility *= influence;
|
||||
#ifdef DEFERRED1
|
||||
return mix(color, saturateColors(auroraColor, 0.8) * visibility * 0.45, visibility);
|
||||
#endif
|
||||
float luminanceColor = GetLuminance(color);
|
||||
vec3 newColor = mix(color, mix(color, vec3(luminanceColor), 0.88), visibility);
|
||||
newColor *= mix(vec3(1.0), auroraColor * luminanceColor * 10.0, visibility);
|
||||
return clamp01(newColor);
|
||||
// return mix(color, color * auroraColor, visibility); // old, keep it for now
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 GetAuroraBorealis(vec3 viewPos, float VdotU, float dither) {
|
||||
float visibility = GetAuroraVisibility(VdotU, 1.0);
|
||||
|
||||
if (visibility > 0.0) {
|
||||
vec3 aurora = vec3(0.0);
|
||||
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * viewPos;
|
||||
wpos.xz /= wpos.y;
|
||||
vec2 cameraPositionM = cameraPosition.xz * 0.0075;
|
||||
cameraPositionM.x += syncedTimeDynamic * 0.04;
|
||||
|
||||
#ifdef DEFERRED1
|
||||
int sampleCount = 25;
|
||||
int sampleCountP = sampleCount + 5;
|
||||
#else
|
||||
int sampleCount = 10;
|
||||
int sampleCountP = sampleCount + 10;
|
||||
#endif
|
||||
|
||||
float ditherM = dither + 5.0;
|
||||
float auroraAnimate = frameTimeCounter * 0.001;
|
||||
|
||||
vec3 auroraUp, auroraDown;
|
||||
GetAuroraColor(wpos.xz, auroraUp, auroraDown);
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
float current = pow2((i + ditherM) / sampleCountP);
|
||||
|
||||
vec2 planePos = wpos.xz * (AURORA_SIZE * 0.8 + current) * 11.0 * AURORA_NOISE_SCALE + cameraPositionM;
|
||||
|
||||
#if AURORA_STYLE == 1
|
||||
planePos = floor(planePos) * 0.0007;
|
||||
|
||||
#if AURORA_PATTERN_WARP > 0
|
||||
planePos = warpAuroraCoords(planePos, AURORA_PATTERN_WARP * 0.0057);
|
||||
#endif
|
||||
|
||||
float noise = texture2DLod(noisetex, planePos, 0.0).b;
|
||||
noise = pow2(pow2(pow2(pow2(1.0 - 2.0 * abs(noise - 0.5)))));
|
||||
|
||||
noise *= pow1_5(texture2DLod(noisetex, planePos * 100.0 + auroraAnimate, 0.0).b);
|
||||
#else
|
||||
planePos *= 0.0007;
|
||||
|
||||
#if AURORA_PATTERN_WARP > 0
|
||||
planePos = warpAuroraCoords(planePos, AURORA_PATTERN_WARP * 0.0082);
|
||||
#endif
|
||||
|
||||
float noise = texture2DLod(noisetex, planePos, 0.0).r;
|
||||
noise = pow2(pow2(pow2(pow2(1.0 - 2.0 * abs(noise - 0.5)))));
|
||||
|
||||
noise *= texture2DLod(noisetex, planePos * 3.0 + auroraAnimate, 0.0).b;
|
||||
noise *= texture2DLod(noisetex, planePos * 5.0 - auroraAnimate, 0.0).b;
|
||||
#endif
|
||||
|
||||
float currentM = 1.0 - current;
|
||||
|
||||
aurora += noise * currentM * mix(auroraUp, auroraDown, pow(pow2(currentM), AURORA_COLOR_MIX_POWER));
|
||||
}
|
||||
|
||||
#if AURORA_STYLE == 1
|
||||
aurora *= 1.3;
|
||||
#else
|
||||
aurora *= 1.8;
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
aurora *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
|
||||
return aurora * visibility / sampleCount;
|
||||
}
|
||||
|
||||
return vec3(0.0);
|
||||
}
|
||||
#endif
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#if !defined AURORA_BOREALIS_VISIBILITY_GLSL
|
||||
#define AURORA_BOREALIS_VISIBILITY_GLSL
|
||||
|
||||
#define AURORA_CONDITION 3 //[-1 0 1 2 3 4]
|
||||
#define RANDOM_AURORA 0 //[0 1 2 3 4 5 6 7 8 9]
|
||||
#define AURORA_DRAW_DISTANCE 0.65 //[0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00]
|
||||
|
||||
float GetAuroraVisibility(in float VdotU, float VdotUAmount) {
|
||||
float visibility = sqrt1(clamp01(mix(1.0, VdotU, VdotUAmount) * (AURORA_DRAW_DISTANCE * 1.125 + 0.75) - 0.225)) - sunVisibility - maxBlindnessDarkness;
|
||||
|
||||
#ifdef CLEAR_SKY_WHEN_RAINING
|
||||
visibility -= rainFactorDynamic * 0.5;
|
||||
#else
|
||||
visibility -= rainFactorDynamic;
|
||||
#endif
|
||||
|
||||
visibility *= 1.0 - VdotU * 0.9 * VdotUAmount;
|
||||
|
||||
#if AURORA_CONDITION == 1 || AURORA_CONDITION == 3
|
||||
visibility -= moonPhase;
|
||||
#endif
|
||||
#if AURORA_CONDITION == 2 || AURORA_CONDITION == 3
|
||||
visibility *= inSnowy;
|
||||
#endif
|
||||
#if AURORA_CONDITION == 4
|
||||
visibility = max(visibility * inSnowy, visibility - moonPhase);
|
||||
#endif
|
||||
#if AURORA_CONDITION == -1 // Always except new moon
|
||||
visibility *= clamp01(max(moonPhase, 1) % 4);
|
||||
#endif
|
||||
|
||||
#if RANDOM_AURORA > 0
|
||||
float randomValue = hash11(float(worldDay));
|
||||
if (randomValue > RANDOM_AURORA * 0.1) {
|
||||
visibility = -1.0; // Disable aurora this day
|
||||
}
|
||||
#endif
|
||||
|
||||
return visibility;
|
||||
}
|
||||
#endif
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
vec3 GetBedrockNoise(vec3 viewPos, float VdotU, float dither) {
|
||||
float eyeAltitude1 = eyeAltitude * 0.005;
|
||||
float visibility = clamp01(-VdotU * 1.875 - 0.225) * (1.0 - maxBlindnessDarkness);
|
||||
visibility *= 1.0 + VdotU * 0.75;
|
||||
|
||||
float distanceAboveBedrock = bedrockLevel - eyeAltitude;
|
||||
|
||||
float fadeStart = 180.0;
|
||||
float fadeWidth = 50.0;
|
||||
|
||||
float noiseHeight = 2.0 / (1.0 + exp(-(fadeStart - distanceAboveBedrock) / fadeWidth));
|
||||
|
||||
visibility *= -eyeAltitude1 * 3.0 + (bedrockLevel / 66.6) + 2.0;
|
||||
|
||||
if (visibility >= 0.0) {
|
||||
vec3 wpos = (gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz;
|
||||
wpos /= (abs(wpos.y) + length(wpos.xz) * 0.5);
|
||||
|
||||
vec2 cameraPositionM = cameraPosition.xz * 0.0075;
|
||||
cameraPositionM.x += frameTimeCounter * 0.004;
|
||||
float VdotUM = 1.0 - VdotU * VdotU;
|
||||
|
||||
// Star calculation
|
||||
vec2 starCoord = noiseHeight * wpos.xz * 0.2 + cameraPositionM * 0.1;
|
||||
starCoord = floor(starCoord * 1024.0) / 1024.0;
|
||||
|
||||
float star = GetStarNoise(starCoord.xy) *
|
||||
GetStarNoise(starCoord.xy+0.1) *
|
||||
GetStarNoise(starCoord.xy+0.23);
|
||||
star = max0((star - 0.4) * 6.0);
|
||||
star *= star;
|
||||
|
||||
vec3 stars = star * vec3(0.1765, 0.1569, 0.1804) * (VdotUM + 0.3);
|
||||
|
||||
float wind = fract(frameTimeCounter * 0.0125);
|
||||
const int sampleCount = 1;
|
||||
const int sampleCountP = sampleCount + 5;
|
||||
float ditherM = dither + 5.0;
|
||||
|
||||
vec3 spots = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
float current = pow2((i + ditherM) / sampleCountP);
|
||||
float currentM = 1.0 - current;
|
||||
|
||||
vec2 planePos = wpos.xz * (0.5 + current) * noiseHeight;
|
||||
planePos = (planePos * 0.5 + cameraPositionM * 0.5) * 20.0;
|
||||
|
||||
float noiseSpots = texture2DLod(noisetex, floor(planePos) * 0.1, 0.0).g;
|
||||
vec3 noise = texture2DLod(noisetex, vec2(noiseSpots) + wind * 0.3, 0.0).b * vec3(0.3);
|
||||
|
||||
spots += noise * currentM * 6.0;
|
||||
}
|
||||
|
||||
#ifdef OVERWORLD
|
||||
spots = (spots - 0.5) * 1.5 + 0.5; // contrast
|
||||
#else
|
||||
spots = (spots - 0.5) * 3.5 + 0.5; // contrast
|
||||
#endif
|
||||
|
||||
spots += stars;
|
||||
|
||||
float clampedNoiseHeight = clamp01(noiseHeight);
|
||||
return spots * visibility / sampleCount * clampedNoiseHeight + clampedNoiseHeight - 1.0;
|
||||
}
|
||||
|
||||
return vec3(0.0);
|
||||
}
|
||||
+238
@@ -0,0 +1,238 @@
|
||||
// Precomputed global constants
|
||||
#define BH_ANGULAR_RAD (BLACK_HOLE_SIZE * 0.01745329251)
|
||||
#define BH_SIZE_FACTOR max(BLACK_HOLE_SIZE * 0.2, 1.0)
|
||||
#define BH_ADJUSTED_PERIOD max(75 * BLACK_HOLE_SIZE * 0.2, 1.0)
|
||||
#define BH_SWIRL_RATE (BLACK_HOLE_LENSING_SWIRL * BH_ANGULAR_RAD / BH_ADJUSTED_PERIOD)
|
||||
|
||||
vec3 SphericalToWorldDir(float longitudeDeg, float latitudeDeg) {
|
||||
float lonRad = radians(longitudeDeg);
|
||||
float latRad = radians(latitudeDeg);
|
||||
float cosLat = cos(latRad);
|
||||
return vec3(cosLat * cos(lonRad), sin(latRad), cosLat * sin(lonRad));
|
||||
}
|
||||
|
||||
float LoopingWanderNoise(float angle, vec2 seed) {
|
||||
float sum = 0.0, ampSum = 0.0, amp = 0.5, freq = 1.0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
vec2 coord = vec2(cos(angle * freq), sin(angle * freq)) * 7.0 + seed;
|
||||
sum += amp * smoothHash12(coord);
|
||||
ampSum += amp;
|
||||
amp *= 0.3;
|
||||
freq *= 2.0;
|
||||
}
|
||||
float value = sum / ampSum;
|
||||
|
||||
float signedValue = clamp(value * 2.0 - 1.0, -1.0, 1.0);
|
||||
float stretched = signedValue * (1.5 - 0.5 * signedValue * signedValue);
|
||||
return stretched * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 getBlackHoleDir() {
|
||||
#if BLACK_HOLE_DIRECTION_MODE == 1
|
||||
// Fixed manual position
|
||||
vec3 worldDir = SphericalToWorldDir(BLACK_HOLE_LONGITUDE, BLACK_HOLE_LATITUDE);
|
||||
return normalize((gbufferModelView * vec4(worldDir, 0.0)).xyz);
|
||||
#elif BLACK_HOLE_DIRECTION_MODE == 2
|
||||
// Slowly wandering position
|
||||
float dayP = frameTimeCounter / 86400.0;
|
||||
#ifdef EUPHORIA_PATCHES_UNIFORMS
|
||||
dayP = euphoriaPatchesCurrentDayMillis >= 0 ? float(euphoriaPatchesCurrentDayMillis) / 86400000.0 : dayP;
|
||||
#endif
|
||||
|
||||
float loops = floor(BLACK_HOLE_LOOPS_PER_DAY + 0.5);
|
||||
float loopAngle = fract(dayP * loops) * tau;
|
||||
|
||||
float longitude = LoopingWanderNoise(loopAngle, vec2(11.3, 47.9)) * 360.0;
|
||||
|
||||
float latitudeBias = BLACK_HOLE_LATITUDE_BIAS * 90.0; // shifts path toward the upper (+) or lower (-) hemisphere
|
||||
float maxSwing = max(89.0 - abs(latitudeBias), 0.0);
|
||||
float latitude = latitudeBias + (LoopingWanderNoise(loopAngle * 3, vec2(83.7, 19.2)) * 2.0 - 1.0) * maxSwing;
|
||||
|
||||
vec3 worldDir = SphericalToWorldDir(longitude, latitude);
|
||||
worldDir = mix(worldDir, vec3(0, 1, 0), vlFactor); // For Ender Dragon Fight
|
||||
|
||||
return normalize((gbufferModelView * vec4(worldDir, 0.0)).xyz);
|
||||
#else
|
||||
// Follows the end sun angle
|
||||
return normalize((gbufferModelView * vec4(vec3(0.0, SUN_ROTATION_DATA * 2000.0), 1.0)).xyz);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Faster alternative to acos
|
||||
// Source: https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/#more-3316
|
||||
float fastAcos(float x) {
|
||||
float absX = min(abs(x), 1.0);
|
||||
float res = (0.0464619 * absX - 0.201877) * absX + 1.57018;
|
||||
res *= sqrt(1.0 - absX);
|
||||
return x >= 0.0 ? res : pi - res;
|
||||
}
|
||||
|
||||
float GetBlackHoleTurbulence(vec2 coord) {
|
||||
float sum = 0.0, amp = 0.6;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sum += amp * smoothHash12(coord);
|
||||
coord *= 2.17;
|
||||
amp *= 0.55;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
// Seamless polar turbulence sampling
|
||||
float SampleBlackHoleTurbulence(float diskAngle, float diskDist, float ringCount, float wind) {
|
||||
float theta = (diskAngle + wind) * ringCount;
|
||||
vec2 turbulenceCoord = vec2(cos(theta) * 2.5, sin(theta) * 2.5 + diskDist * 40.0);
|
||||
return pow3(clamp01(GetBlackHoleTurbulence(turbulenceCoord)));
|
||||
}
|
||||
|
||||
void GetOrthonormalBasis(vec3 n, out vec3 b1, out vec3 b2) {
|
||||
if (abs(n.x) < 1e-3 && abs(n.z) < 1e-3) {
|
||||
b1 = vec3(1.0, 0.0, 0.0);
|
||||
b2 = cross(b1, n);
|
||||
return;
|
||||
}
|
||||
|
||||
float horizontalAngle = atan(n.z, n.x);
|
||||
b1 = vec3(-sin(horizontalAngle), 0.0, cos(horizontalAngle));
|
||||
b2 = cross(b1, n);
|
||||
}
|
||||
|
||||
struct BlackHoleGeometry {
|
||||
vec3 rayDir;
|
||||
vec3 sunDir;
|
||||
float nu;
|
||||
float r;
|
||||
};
|
||||
|
||||
BlackHoleGeometry GetBlackHoleGeometry(vec3 nViewPos, vec3 holeDir) {
|
||||
mat3 invMV = mat3(gbufferModelViewInverse);
|
||||
BlackHoleGeometry geo;
|
||||
geo.rayDir = normalize(invMV * nViewPos);
|
||||
geo.sunDir = normalize(invMV * holeDir);
|
||||
geo.nu = dot(geo.rayDir, geo.sunDir);
|
||||
geo.r = fastAcos(geo.nu);
|
||||
return geo;
|
||||
}
|
||||
|
||||
// Approximate gravitational lensing with swirling star displacement
|
||||
vec3 GetBlackHoleLensedDirection(vec3 nViewPos, vec3 holeDir) {
|
||||
BlackHoleGeometry geo = GetBlackHoleGeometry(nViewPos, holeDir);
|
||||
const float lensRadius = BH_ANGULAR_RAD * BLACK_HOLE_LENSING_RANGE;
|
||||
|
||||
if (geo.nu <= 0.0 || geo.r >= lensRadius || geo.r < 1e-4) return nViewPos;
|
||||
|
||||
float safeR = max(geo.r, BH_ANGULAR_RAD * 0.3);
|
||||
float t = clamp01(1.0 - geo.r / lensRadius);
|
||||
float bend = BLACK_HOLE_LENSING_STRENGTH * BH_ANGULAR_RAD * pow3(t) / safeR;
|
||||
|
||||
vec3 radial = normalize(geo.rayDir - geo.sunDir * geo.nu);
|
||||
float swirlAngle = -frameTimeCounter * BH_SWIRL_RATE / safeR;
|
||||
vec3 swirlRadial = radial * cos(swirlAngle) + cross(geo.sunDir, radial) * sin(swirlAngle);
|
||||
|
||||
vec3 warped = normalize(geo.rayDir + swirlRadial * bend);
|
||||
return normalize(mat3(gbufferModelView) * warped);
|
||||
}
|
||||
|
||||
vec4 GetBlackHole(vec3 nViewPos, vec3 holeDir) {
|
||||
BlackHoleGeometry geo = GetBlackHoleGeometry(nViewPos, holeDir);
|
||||
|
||||
if (geo.nu <= -0.2) return vec4(0.0);
|
||||
|
||||
vec3 rayDir = geo.rayDir;
|
||||
vec3 sunDir = geo.sunDir;
|
||||
float nu = geo.nu;
|
||||
|
||||
float hemisphereMask = smoothstep(-0.2, 0.0, nu);
|
||||
|
||||
// 2D polar projection along tangent plane
|
||||
vec3 tangent, bitangent;
|
||||
GetOrthonormalBasis(sunDir, tangent, bitangent);
|
||||
vec2 diskPos = vec2(dot(rayDir, tangent), dot(rayDir, bitangent));
|
||||
|
||||
#if BLACK_HOLE_PIXELATION > 0
|
||||
float pixelSize = BH_ANGULAR_RAD / BLACK_HOLE_PIXELATION;
|
||||
vec2 p = (floor(diskPos / pixelSize) + 0.5) * pixelSize;
|
||||
#else
|
||||
vec2 p = diskPos;
|
||||
#endif
|
||||
|
||||
#if BLACK_HOLE_SHAPE == 1
|
||||
float circularDist = length(p);
|
||||
float squareDist = max(abs(p.x), abs(p.y));
|
||||
float squareness = 1.0 - smoothstep(BH_ANGULAR_RAD, BH_ANGULAR_RAD * 1.7, circularDist);
|
||||
|
||||
float squircleP = mix(2.0, 40.0, squareness);
|
||||
vec2 normP = abs(p) / max(squareDist, 1e-6);
|
||||
vec2 pPow = pow(normP, vec2(squircleP));
|
||||
|
||||
float diskDist = squareDist * pow(pPow.x + pPow.y, 1.0 / squircleP);
|
||||
float holeDist = max(abs(diskPos.x), abs(diskPos.y));
|
||||
#else
|
||||
float diskDist = length(p);
|
||||
float holeDist = diskDist;
|
||||
#endif
|
||||
|
||||
vec2 shapePos = p;
|
||||
float diskAngle = atan(p.y, p.x);
|
||||
|
||||
float diskMask = float(holeDist < BH_ANGULAR_RAD);
|
||||
|
||||
const float ringCount = max(1.0, floor(BLACK_HOLE_RING_COUNT + 0.5));
|
||||
float ringExtent = BH_ANGULAR_RAD * BLACK_HOLE_RING_SIZE + vlFactor * 0.66;
|
||||
|
||||
float windStrength = ringExtent / max(diskDist, BH_ANGULAR_RAD);
|
||||
float windRange = BLACK_HOLE_DIFFERENTIAL_AMOUNT * windStrength * BH_SIZE_FACTOR;
|
||||
|
||||
// Differential wind crossfade
|
||||
float cyclePhase = frameTimeCounter / BH_ADJUSTED_PERIOD;
|
||||
float phaseA = fract(cyclePhase);
|
||||
float phaseB = fract(cyclePhase + 0.5);
|
||||
float weightB = 1.0 - abs(2.0 * phaseB - 1.0);
|
||||
|
||||
float turbulenceA = SampleBlackHoleTurbulence(diskAngle, diskDist, ringCount, phaseA * windRange);
|
||||
float turbulenceB = SampleBlackHoleTurbulence(diskAngle, diskDist, ringCount, phaseB * windRange);
|
||||
float turbulence = mix(turbulenceA, turbulenceB, weightB);
|
||||
|
||||
// Precomputed distance ratio
|
||||
float ringDist = max0(diskDist - BH_ANGULAR_RAD);
|
||||
float distRatio = ringDist / ringExtent;
|
||||
|
||||
float ringFalloff = pow3(clamp01(1.0 - distRatio));
|
||||
float ringFadeIn = smoothstep(0.0, 0.3, distRatio);
|
||||
float ring = ringFalloff * ringFadeIn * mix(0.35, 1.0, turbulence);
|
||||
|
||||
float rimInner = pow2(clamp01(1.0 - abs(diskDist - BH_ANGULAR_RAD + BH_ANGULAR_RAD * 0.05) / (BH_ANGULAR_RAD * 0.015))) * 1.3;
|
||||
float rimOuter = pow3(clamp01(1.0 - abs(diskDist - BH_ANGULAR_RAD - BH_ANGULAR_RAD * 0.02) / (BH_ANGULAR_RAD * 0.15))) * 0.45;
|
||||
float rim = rimOuter;
|
||||
|
||||
#if BLACK_HOLE_PIXELATION == 0 || BLACK_HOLE_PIXELATION >= 25 && BLACK_HOLE_SHAPE == 1
|
||||
rim += rimInner;
|
||||
#endif
|
||||
|
||||
float edgeProximity = clamp01(1.0 - distRatio * 2.5);
|
||||
float innerHeat = pow6(edgeProximity);
|
||||
vec2 microAngleCoord = vec2(cos(diskAngle * 3.0), sin(diskAngle * 3.0)) * 1.5;
|
||||
float microRings = GetBlackHoleTurbulence(vec2(diskDist * 570.0, diskDist * 42.0) + microAngleCoord);
|
||||
|
||||
float ringBrightness = (ring + rim) * BLACK_HOLE * 0.1;
|
||||
ringBrightness += innerHeat * BLACK_HOLE * 0.1 * mix(0.6, 1.0, microRings) * (1.0 - diskMask);
|
||||
|
||||
vec3 beamPurple = baseBeamPurple * (2.5 - 1.0 * vlFactor);
|
||||
vec3 ringColor = mix(sqrt(beamPurple), sqrt(endOrangeCol), clamp01(distRatio * 1.35));
|
||||
ringColor = mix(ringColor, ringColor + 0.5, innerHeat);
|
||||
|
||||
// Horizontal accretion-disk streak
|
||||
#if BLACK_HOLE_STREAK > 0
|
||||
float streakWidth = BH_ANGULAR_RAD * 0.11;
|
||||
float streakFalloff = exp(-pow2(shapePos.y / streakWidth));
|
||||
float streakLength = ringExtent * BLACK_HOLE_STREAK * 0.005;
|
||||
float streakExtent = exp(-pow2(max0(abs(shapePos.x) - BH_ANGULAR_RAD) / streakLength));
|
||||
float streakWind = mix(phaseA, phaseB, weightB) * windRange * 15;
|
||||
float streakMovement = frameTimeCounter * (0.2 * diskMask + sign(shapePos.x) * 0.55 * (1.0 - diskMask));
|
||||
float streakNoise = GetBlackHoleTurbulence(vec2(shapePos.x * 20.0 - streakWind - streakMovement, shapePos.y * 150.0));
|
||||
float streak = streakFalloff * streakExtent * mix(0.5, 1.0, streakNoise);
|
||||
ringBrightness += streak * BLACK_HOLE * 0.08 * (1.0 - vlFactor);
|
||||
#endif
|
||||
|
||||
float totalMult = ringBrightness * hemisphereMask;
|
||||
return vec4(ringColor * totalMult, diskMask);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#ifndef INCLUDE_CLOUD_COORD
|
||||
#define INCLUDE_CLOUD_COORD
|
||||
|
||||
#include "/lib/shaderSettings/clouds.glsl"
|
||||
|
||||
const float cloudNarrowness = CLOUD_NARROWNESS;
|
||||
|
||||
// Thanks to SixthSurge
|
||||
vec2 GetRoundedCloudCoord(vec2 pos, float cloudRoundness) { // cloudRoundness is meant to be 0.125 for clouds and 0.35 for cloud shadows
|
||||
vec2 coord = pos.yx + 0.5;
|
||||
#ifdef ROTATE_REIMAGINED_CLOUDS_90_NEW
|
||||
coord = coord.yx;
|
||||
#endif
|
||||
vec2 signCoord = sign(coord);
|
||||
coord = abs(coord) + 1.0;
|
||||
vec2 i, f = modf(coord, i);
|
||||
f = smoothstep(0.5 - cloudRoundness, 0.5 + cloudRoundness, f);
|
||||
coord = i + f;
|
||||
return (coord - 0.5) * signCoord / 256.0;
|
||||
}
|
||||
|
||||
vec3 ModifyTracePos(vec3 tracePos, int cloudAltitude) {
|
||||
#if CLOUD_SPEED_MULT == 100
|
||||
float wind = syncedTimeDynamic;
|
||||
#else
|
||||
#define CLOUD_SPEED_MULT_M CLOUD_SPEED_MULT * 0.01
|
||||
float wind = frameTimeCounter * CLOUD_SPEED_MULT_M;
|
||||
#endif
|
||||
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
wind *= CLOUD_LAYER2_SPEED_MULT;
|
||||
}
|
||||
|
||||
#if CLOUD_DIRECTION == 1
|
||||
tracePos.x -= wind;
|
||||
tracePos.z += cloudAltitude * 64.0;
|
||||
#else
|
||||
tracePos.z -= wind;
|
||||
tracePos.x += cloudAltitude * 64.0;
|
||||
#endif
|
||||
|
||||
tracePos.xz *= cloudNarrowness;
|
||||
return tracePos.xyz;
|
||||
}
|
||||
|
||||
#endif
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
#include "/lib/shaderSettings/clouds.glsl"
|
||||
#if CLOUD_UNBOUND_SIZE_MULT != 100
|
||||
#define CLOUD_UNBOUND_SIZE_MULT_M CLOUD_UNBOUND_SIZE_MULT * 0.01
|
||||
#endif
|
||||
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
#include "/lib/colors/cloudColors.glsl"
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
|
||||
float InterleavedGradientNoiseForClouds() {
|
||||
float n = 52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y);
|
||||
#ifdef TAA
|
||||
return fract(n + goldenRatio * mod(float(frameCounter), 3600.0));
|
||||
#else
|
||||
return fract(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SHADOW_QUALITY > -1 && !defined VOXY_PATCH
|
||||
vec3 GetShadowOnCloudPosition(vec3 tracePos, vec3 cameraPos) {
|
||||
vec3 wpos = PlayerToShadow(tracePos - cameraPos);
|
||||
float distb = sqrt(wpos.x * wpos.x + wpos.y * wpos.y);
|
||||
float distortFactor = 1.0 - shadowMapBias + distb * shadowMapBias;
|
||||
vec3 shadowPosition = vec3(vec2(wpos.xy / distortFactor), wpos.z * 0.2);
|
||||
return shadowPosition * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
bool GetShadowOnCloud(vec3 tracePos, vec3 cameraPos, int cloudAltitude, float lowerPlaneAltitude, float higherPlaneAltitude) {
|
||||
const float cloudShadowOffset = 0.5;
|
||||
|
||||
vec3 shadowPosition0 = GetShadowOnCloudPosition(tracePos, cameraPos);
|
||||
if (length(shadowPosition0.xy * 2.0 - 1.0) < 1.0) {
|
||||
float shadowsample0 = shadow2D(shadowtex0, shadowPosition0).z;
|
||||
|
||||
if (shadowsample0 == 0.0) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
#include "/lib/atmospherics/clouds/reimaginedClouds.glsl"
|
||||
#endif
|
||||
#ifdef CLOUDS_UNBOUND
|
||||
#include "/lib/atmospherics/clouds/unboundClouds.glsl"
|
||||
#endif
|
||||
|
||||
vec4 GetClouds(inout float cloudLinearDepth, float skyFade, vec3 cameraPosOffset, vec3 playerPos, vec3 viewPos,
|
||||
float lViewPos, float VdotS, float VdotU, float dither, vec3 auroraBorealis, vec3 nightNebula, vec3 sunVec) {
|
||||
vec4 clouds = vec4(0.0);
|
||||
|
||||
vec3 nPlayerPos = normalize(playerPos);
|
||||
float lViewPosM = lViewPos < renderDistance * 1.5 ? lViewPos - 1.0 : 1000000000.0;
|
||||
float skyMult0 = pow2(skyFade * 3.333333 - 2.333333);
|
||||
|
||||
#if IRIS_VERSION >= 10800
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
float modFactor = 1.0 / cloudNarrowness * 256.0;
|
||||
#else
|
||||
#if CLOUD_UNBOUND_SIZE_MULT == 100
|
||||
float modFactor = 1.0 / cloudNarrowness;
|
||||
#else
|
||||
float modFactor = 1.0 / (cloudNarrowness * CLOUD_UNBOUND_SIZE_MULT_M);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int modFactorM = int(modFactor);
|
||||
|
||||
vec2 cameraPositionBIM = cameraPositionInt.xz - modFactorM * (cameraPositionInt.xz / modFactorM);
|
||||
|
||||
vec3 cameraPos = vec3(
|
||||
cameraPositionBIM.x + cameraPositionBestFract.x,
|
||||
cameraPosition.y,
|
||||
cameraPositionBIM.y + cameraPositionBestFract.z
|
||||
);
|
||||
|
||||
#if defined CLOUDS_UNBOUND && defined DOUBLE_UNBOUND_CLOUDS
|
||||
float layer2ScaleFactor = CLOUD_UNBOUND_LAYER2_SIZE * 10.0 / CLOUD_UNBOUND_SIZE_MULT;
|
||||
#if CLOUD_UNBOUND_SIZE_MULT == 100
|
||||
float modFactor2 = 1.0 / (cloudNarrowness * layer2ScaleFactor);
|
||||
#else
|
||||
float modFactor2 = 1.0 / (cloudNarrowness * CLOUD_UNBOUND_SIZE_MULT_M * layer2ScaleFactor);
|
||||
#endif
|
||||
|
||||
int modFactorM2 = int(modFactor2);
|
||||
|
||||
vec2 cameraPositionBIM2 = cameraPositionInt.xz - modFactorM2 * (cameraPositionInt.xz / modFactorM2);
|
||||
|
||||
vec3 cameraPos2 = vec3(
|
||||
cameraPositionBIM2.x + cameraPositionBestFract.x,
|
||||
cameraPosition.y,
|
||||
cameraPositionBIM2.y + cameraPositionBestFract.z
|
||||
);
|
||||
#endif
|
||||
#else
|
||||
vec3 cameraPos = cameraPosition;
|
||||
#if defined CLOUDS_UNBOUND && defined DOUBLE_UNBOUND_CLOUDS
|
||||
vec3 cameraPos2 = cameraPosition;
|
||||
#endif
|
||||
#endif
|
||||
cameraPos += cameraPosOffset;
|
||||
#if defined CLOUDS_UNBOUND && defined DOUBLE_UNBOUND_CLOUDS
|
||||
cameraPos2 += cameraPosOffset;
|
||||
#endif
|
||||
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
float thresholdF = 4000.0;
|
||||
#else
|
||||
float thresholdF = 4000.0;
|
||||
#endif
|
||||
|
||||
//float thresholdMix = pow2(clamp01(VdotU * 15.0));
|
||||
//thresholdF = mix(far, thresholdF, thresholdMix * 0.5 + 0.5);
|
||||
thresholdF *= CLOUD_RENDER_DISTANCE;
|
||||
|
||||
#if RAINBOW_CLOUD != 0
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz);
|
||||
wpos /= (abs(wpos.y) + length(wpos.xz));
|
||||
|
||||
vec3 rainbowColor = getRainbowColor(wpos.xz * rainbowCloudDistribution * 0.35, 0.05);
|
||||
cloudRainColor *= rainbowColor;
|
||||
cloudAmbientColor *= rainbowColor;
|
||||
cloudLightColor *= rainbowColor;
|
||||
#endif
|
||||
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
cloudAmbientColor *= 1.0 - 0.25 * rainFactor;
|
||||
#endif
|
||||
|
||||
vec3 cloudColorMult = vec3(1.0);
|
||||
#if CLOUD_R != 100 || CLOUD_G != 100 || CLOUD_B != 100
|
||||
cloudColorMult *= vec3(CLOUD_R, CLOUD_G, CLOUD_B) * 0.01;
|
||||
#endif
|
||||
cloudAmbientColor *= cloudColorMult;
|
||||
cloudLightColor *= cloudColorMult;
|
||||
|
||||
#if defined CLOUDS_REIMAGINED && defined DOUBLE_REIM_CLOUDS
|
||||
int maxCloudAlt = max(cloudAlt1i, cloudAlt2i);
|
||||
int minCloudAlt = min(cloudAlt1i, cloudAlt2i);
|
||||
|
||||
if (abs(cameraPos.y - minCloudAlt) < abs(cameraPos.y - maxCloudAlt)) {
|
||||
clouds = GetVolumetricClouds(minCloudAlt, thresholdF, cloudLinearDepth, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
if (clouds.a == 0.0) {
|
||||
clouds = GetVolumetricClouds(maxCloudAlt, thresholdF, cloudLinearDepth, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
}
|
||||
} else {
|
||||
clouds = GetVolumetricClouds(maxCloudAlt, thresholdF, cloudLinearDepth, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
if (clouds.a == 0.0) {
|
||||
clouds = GetVolumetricClouds(minCloudAlt, thresholdF, cloudLinearDepth, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined CLOUDS_UNBOUND && defined DOUBLE_UNBOUND_CLOUDS
|
||||
float cloudLinearDepth1 = 1.0;
|
||||
float cloudLinearDepth2 = 1.0;
|
||||
//The order of calculating the clouds actually matters here
|
||||
vec4 clouds1 = GetVolumetricClouds(cloudAlt1i, thresholdF, cloudLinearDepth1, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
vec4 clouds2 = GetVolumetricClouds(cloudAlt2i, thresholdF, cloudLinearDepth2, skyFade, skyMult0,
|
||||
cameraPos2, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos);
|
||||
|
||||
if (clouds1.a * clouds2.a < 1e-36)
|
||||
clouds = clouds1 * sign(max(0.0, clouds1.a - 1e-36)) + clouds2 * sign(max(0.0, clouds2.a - 1e-36));
|
||||
else {
|
||||
if (cloudLinearDepth1 < cloudLinearDepth2)
|
||||
clouds = vec4(mix(clouds2.rgb, clouds1.rgb, clouds1.w), mix(clouds2.w, 1.0, clouds1.w));
|
||||
else
|
||||
clouds = vec4(mix(clouds1.rgb, clouds2.rgb, clouds2.w), mix(clouds1.w, 1.0, clouds2.w));
|
||||
}
|
||||
|
||||
cloudLinearDepth = min(clouds1.a > 0.5 ? cloudLinearDepth1 : 1.0, clouds2.a > 0.5 ? cloudLinearDepth2 : 1.0);
|
||||
#else
|
||||
clouds = GetVolumetricClouds(cloudAlt1i, thresholdF, cloudLinearDepth, skyFade, skyMult0,
|
||||
cameraPos, nPlayerPos, lViewPosM, VdotS, VdotU, dither, sunVec, viewPos) ;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
clouds.rgb *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
clouds.rgb *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
#if AURORA_STYLE > 0
|
||||
clouds.rgb += auroraBorealis * 0.1;
|
||||
#endif
|
||||
#if NIGHT_NEBULAE == 1
|
||||
clouds.rgb += nightNebula * 0.2;
|
||||
#endif
|
||||
|
||||
return clouds;
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
#include "/lib/shaderSettings/cloudsAndLighting.glsl"
|
||||
#include "/lib/atmospherics/clouds/cloudCoord.glsl"
|
||||
|
||||
#ifdef DOUBLE_REIM_CLOUDS
|
||||
const float cloudStretch = CLOUD_STRETCH * 4.2;
|
||||
const float L2cloudStretch = cloudStretch * CLOUD_REIMAGINED_LAYER2_HEIGHT;
|
||||
const float cloudTallness = cloudStretch * 2.0;
|
||||
#else
|
||||
const float cloudStretch = CLOUD_STRETCH * 4.2;
|
||||
const float cloudTallness = cloudStretch * 2.0;
|
||||
#endif
|
||||
const float cloudRoundness = CLOUD_ROUNDNESS;
|
||||
|
||||
bool GetCloudNoise(vec3 tracePos, inout vec3 tracePosM, int cloudAltitude, float cloudStretchParam) {
|
||||
tracePosM = ModifyTracePos(tracePos, cloudAltitude);
|
||||
vec2 coord = GetRoundedCloudCoord(tracePosM.xz, cloudRoundness);
|
||||
|
||||
#ifdef DEFERRED1
|
||||
float noise = texture2D(colortex3, coord).b;
|
||||
#else
|
||||
float noise = texture2D(gaux4, coord).b;
|
||||
#endif
|
||||
|
||||
float threshold = clamp(abs(cloudAltitude - tracePos.y) / cloudStretchParam, 0.001, 0.999);
|
||||
threshold = pow2(pow2(pow2(threshold)));
|
||||
return noise > threshold * 0.5 + 0.25;
|
||||
}
|
||||
|
||||
float Get2DCloudSample(vec2 pos) {
|
||||
#ifdef DEFERRED1
|
||||
return texture2D(colortex3, GetRoundedCloudCoord(pos, cloudRoundness)).b;
|
||||
#else
|
||||
return texture2D(gaux4, GetRoundedCloudCoord(pos, cloudRoundness)).b;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec4 GetVolumetricClouds(int cloudAltitude, float distanceThreshold, inout float cloudLinearDepth, float skyFade, float skyMult0, vec3 cameraPos, vec3 nPlayerPos, float lViewPosM, float VdotS, float VdotU, float dither, vec3 sunVec, vec3 viewPos) {
|
||||
vec4 volumetricClouds = vec4(0.0);
|
||||
|
||||
// Use local variables to avoid modifying globals
|
||||
float localCloudStretch = cloudStretch;
|
||||
float localCloudTallness = cloudTallness;
|
||||
|
||||
#ifdef DOUBLE_REIM_CLOUDS
|
||||
if (cloudAltitude != cloudAlt1i) { // second layer
|
||||
localCloudStretch = L2cloudStretch;
|
||||
localCloudTallness = 2.0 * localCloudStretch;
|
||||
}
|
||||
#endif
|
||||
|
||||
float higherPlaneAltitude = cloudAltitude + localCloudStretch;
|
||||
float lowerPlaneAltitude = cloudAltitude - localCloudStretch;
|
||||
|
||||
float lowerPlaneDistance = (lowerPlaneAltitude - cameraPos.y) / nPlayerPos.y;
|
||||
float higherPlaneDistance = (higherPlaneAltitude - cameraPos.y) / nPlayerPos.y;
|
||||
float minPlaneDistance = min(lowerPlaneDistance, higherPlaneDistance);
|
||||
minPlaneDistance = max(minPlaneDistance, 0.0);
|
||||
float maxPlaneDistance = max(lowerPlaneDistance, higherPlaneDistance);
|
||||
if (maxPlaneDistance < 0.0) return vec4(0.0);
|
||||
float planeDistanceDif = maxPlaneDistance - minPlaneDistance;
|
||||
|
||||
float aboveClouds = clamp01((cameraPos.y - lowerPlaneAltitude) * 0.05);
|
||||
float skyFadeM = mix(skyFade, 1.0, mix(0.4 * max(aboveClouds, rainFactor2), 1.0, clamp01(CLOUD_TRANSPARENCY - 1.0)));
|
||||
float min1CloudTransparency = min1(CLOUD_TRANSPARENCY);
|
||||
|
||||
#if CLOUD_QUALITY_INTERNAL == 1 || !defined DEFERRED1
|
||||
int sampleCount = max(int(planeDistanceDif) / 16, 6);
|
||||
#elif CLOUD_QUALITY_INTERNAL == 2
|
||||
int sampleCount = max(int(planeDistanceDif) / 8, 12);
|
||||
#elif CLOUD_QUALITY_INTERNAL == 3 || CLOUD_QUALITY_INTERNAL == 4
|
||||
int sampleCount = max(int(planeDistanceDif), 12);
|
||||
#endif
|
||||
|
||||
float stepMult = planeDistanceDif / sampleCount;
|
||||
vec3 traceAdd = nPlayerPos * stepMult;
|
||||
vec3 tracePos = cameraPos + minPlaneDistance * nPlayerPos;
|
||||
tracePos += traceAdd * dither;
|
||||
tracePos.y -= traceAdd.y;
|
||||
|
||||
#ifdef FIX_AMD_REFLECTION_CRASH
|
||||
sampleCount = min(sampleCount, 30); //BFARC
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
cloudAmbientColor = getAuroraAmbientColor(cloudAmbientColor, viewPos, 0.032, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.75);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
tracePos += traceAdd;
|
||||
|
||||
vec3 cloudPlayerPos = tracePos - cameraPos;
|
||||
float lTracePos = length(cloudPlayerPos);
|
||||
float lTracePosXZ = length(cloudPlayerPos.xz);
|
||||
float cloudMult = 1.0;
|
||||
if (lTracePosXZ > distanceThreshold) break;
|
||||
if (lTracePos > lViewPosM) {
|
||||
if (skyFade < 0.7) continue;
|
||||
else cloudMult = skyMult0;
|
||||
}
|
||||
|
||||
vec3 tracePosM;
|
||||
if (GetCloudNoise(tracePos, tracePosM, cloudAltitude, localCloudStretch)) {
|
||||
float lightMult = 1.0;
|
||||
|
||||
#if SHADOW_QUALITY > -1 && !defined VOXY_PATCH
|
||||
float shadowLength = shadowDistance * 0.9166667; //consistent08JJ622
|
||||
if (shadowLength > lTracePos)
|
||||
if (GetShadowOnCloud(tracePos, cameraPos, cloudAltitude, lowerPlaneAltitude, higherPlaneAltitude)) {
|
||||
#ifdef CLOUD_CLOSED_AREA_CHECK
|
||||
if (eyeBrightness.y != 240) continue;
|
||||
else
|
||||
#endif
|
||||
lightMult = 0.25;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INVERTED_CLOUD_SHADING
|
||||
float cloudShading = (higherPlaneAltitude - tracePos.y) / localCloudTallness;
|
||||
#else
|
||||
float cloudShading = 1.0 - (higherPlaneAltitude - tracePos.y) / localCloudTallness;
|
||||
#endif
|
||||
cloudShading = pow(max0(cloudShading), max0(CLOUD_SHADING_AMOUNT * 0.1 - 0.2));
|
||||
float VdotSM1 = max0(sunVisibility > 0.5 ? VdotS : - VdotS);
|
||||
|
||||
#if CLOUD_QUALITY_INTERNAL >= 2
|
||||
#ifdef DEFERRED1
|
||||
float cloudShadingM = 1.0 - pow2(cloudShading);
|
||||
#else
|
||||
float cloudShadingM = 1.0 - cloudShading;
|
||||
#endif
|
||||
|
||||
float gradientNoise = InterleavedGradientNoiseForClouds();
|
||||
|
||||
vec3 cLightPos = tracePosM;
|
||||
#if REIMAGINED_CLOUDS_OUTLINE > 0
|
||||
vec3 cLightPosAdd = nPlayerPos * REIMAGINED_CLOUDS_OUTLINE * localCloudTallness * 0.01;
|
||||
float tempCloudOutlineThickness = 0.0;
|
||||
#else
|
||||
vec3 cLightPosAdd = normalize(ViewToPlayer(lightVec * 1000000000.0)) * vec3(0.08) * shadowTime;
|
||||
float tempCloudOutlineThickness = 1.0;
|
||||
#endif
|
||||
|
||||
float light = 2.0;
|
||||
cLightPos += (tempCloudOutlineThickness + gradientNoise) * cLightPosAdd;
|
||||
light -= Get2DCloudSample(cLightPos.xz) * cloudShadingM;
|
||||
cLightPos += gradientNoise * cLightPosAdd;
|
||||
light -= Get2DCloudSample(cLightPos.xz) * cloudShadingM;
|
||||
|
||||
float VdotSM2 = VdotSM1 * shadowTime * 0.25;
|
||||
VdotSM2 += 0.5 * cloudShading + 0.08;
|
||||
cloudShading = VdotSM2 * light * lightMult;
|
||||
#endif
|
||||
|
||||
#if CLOUD_SUN_MOON_SHADING > 0
|
||||
float visibilityFactor = 1.0;
|
||||
#if CLOUD_SUN_MOON_SHADING == 1
|
||||
visibilityFactor = 1.0 - sunVisibility;
|
||||
#elif CLOUD_SUN_MOON_SHADING == 2
|
||||
visibilityFactor = sunVisibility;
|
||||
#endif
|
||||
|
||||
if (visibilityFactor > 0.0) {
|
||||
vec3 worldLightVec = mat3(gbufferModelViewInverse) * sunVec;
|
||||
float cloudLightRadius = 375.0;
|
||||
|
||||
float aboveFade = 1.0 - smoothstep(-20.0, 0.0, cameraPos.y - cloudAltitude);
|
||||
float sunPlaneIntersect = (cloudAltitude - cameraPos.y) / worldLightVec.y;
|
||||
vec2 posVector = cameraPos.xz + worldLightVec.xz * sunPlaneIntersect - tracePos.xz;
|
||||
|
||||
float moonVisibility = abs(1.0 - moonPhase / 4.0);
|
||||
float sunMult = mix(moonVisibility, 0.75, sunVisibility);
|
||||
float falloff = exp((1.0 - max0(1.0 - length(posVector) / cloudLightRadius)) * -6.0) * aboveFade * sunMult;
|
||||
|
||||
float sunCloudMult = clamp01(falloff * 2.5 * mix(1.0, (lTracePos - minPlaneDistance) / (maxPlaneDistance - minPlaneDistance), 0.6));
|
||||
|
||||
vec3 bloodMoonCloudColor = vec3(1.0);
|
||||
#if BLOOD_MOON > 0
|
||||
bloodMoonCloudColor = mix(bloodMoonCloudColor, vec3(0.302, 0.0078, 0.0078) * 5, getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
|
||||
cloudLightColor += bloodMoonCloudColor * sunCloudMult * 0.11 * visibilityFactor;
|
||||
cloudShading += sunCloudMult * 1.5 * visibilityFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLOOD_MOON > 0
|
||||
vec3 hsvCloudLightColor = rgb2hsv(cloudLightColor);
|
||||
cloudLightColor = mix(cloudLightColor, hsv2rgb(vec3(0, max(0.66, hsvCloudLightColor.y), hsvCloudLightColor.z)), getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
cloudLightColor = getAuroraAmbientColor(cloudLightColor, viewPos, 0.1, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.75);
|
||||
#endif
|
||||
|
||||
vec3 colorSample = cloudAmbientColor * 0.95 * (1.0 - 0.35 * cloudShading) + cloudLightColor * 0.9 * (0.1 + cloudShading);
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
// Lightning flashes around lightning bolt position
|
||||
vec3 lightningPos = getLightningPos(tracePos - cameraPos, lightningBoltPosition.xyz, false);
|
||||
vec2 lightningAdd = lightningFlashEffect(lightningPos, vec3(1.0), 450.0, 0.0, 0) * isLightningActive() * 10.0;
|
||||
colorSample += lightningAdd.y;
|
||||
|
||||
// Thunderstorm cloud highlights (randomly appear in stormy weather)
|
||||
float highlightBoost = getThunderstormCloudHighlights(tracePos, cameraPos.xz, lTracePos, minPlaneDistance, maxPlaneDistance, 0.005);
|
||||
colorSample += highlightBoost;
|
||||
#endif
|
||||
|
||||
float distanceRatio = (distanceThreshold - lTracePosXZ) / distanceThreshold;
|
||||
float cloudFogFactor = pow2(clamp(distanceRatio, 0.0, 1.0)) * 0.707;
|
||||
cloudFogFactor = mix(1.0, cloudFogFactor, skyFadeM);
|
||||
float nightCloudRemove = NIGHT_CLOUD_UNBOUND_REMOVE * (1.0 - sunVisibility) * -1 + 1.0; // mapped to 1 to 0 range
|
||||
|
||||
bool isCustomSky;
|
||||
vec3 cloudSkyColor = GetSky(VdotU, VdotS, dither, isEyeInWater == 0, false, isCustomSky, false);
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
if (isCustomSky) {
|
||||
vec3 averageSkyColor = texelFetch(colortex14, texelCoord, 0).rgb;
|
||||
cloudSkyColor = mix(cloudSkyColor, averageSkyColor, cloudFogFactor);
|
||||
}
|
||||
#endif
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
cloudSkyColor *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
|
||||
#if defined DOUBLE_REIM_CLOUDS && CLOUD_REIMAGINED_LAYER2_TRANSPARENCY != 20
|
||||
if (cloudAltitude != cloudAlt1i) { // second layer uses custom transparency
|
||||
cloudMult *= (CLOUD_REIMAGINED_LAYER2_TRANSPARENCY * 0.05) * nightCloudRemove;
|
||||
} else {
|
||||
cloudMult *= min1CloudTransparency * nightCloudRemove;
|
||||
}
|
||||
#else
|
||||
cloudMult *= min1CloudTransparency * nightCloudRemove;
|
||||
#endif
|
||||
|
||||
colorSample *= 1.0 - 0.2 * (1.0 - skyFadeM) * max(sunVisibility2, nightFactor);
|
||||
colorSample = mix(cloudSkyColor, colorSample, cloudFogFactor * 0.707);
|
||||
colorSample *= pow2(1.0 - maxBlindnessDarkness);
|
||||
|
||||
float cloudDistanceFactor = clamp(distanceRatio, 0.0, 0.75);
|
||||
|
||||
volumetricClouds.a = sqrt(cloudDistanceFactor * 1.33333) * cloudMult;
|
||||
volumetricClouds.rgb = colorSample;
|
||||
|
||||
cloudLinearDepth = sqrt(lTracePos / renderDistance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
volumetricClouds.a *= 0.5 + 0.5 * skyFadeM;
|
||||
|
||||
return volumetricClouds;
|
||||
}
|
||||
+522
@@ -0,0 +1,522 @@
|
||||
#include "/lib/shaderSettings/cloudsAndLighting.glsl"
|
||||
const float cloudStretchModified = max(0.25, float(CLOUD_STRETCH) * 1.9 - 0.9);
|
||||
#if CLOUD_QUALITY_INTERNAL == 1 || !defined DEFERRED1
|
||||
const float cloudStretchRaw = 11.0 * cloudStretchModified;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 2
|
||||
const float cloudStretchRaw = 16.0 * cloudStretchModified;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 3
|
||||
const float cloudStretchRaw = 18.0 * cloudStretchModified;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 4
|
||||
const float cloudStretchRaw = 20.0 * cloudStretchModified;
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
const float L2cloudStretch = cloudStretchRaw * CLOUD_UNBOUND_LAYER2_HEIGHT / CLOUD_STRETCH;
|
||||
|
||||
#if CLOUD_UNBOUND_SIZE_MULT <= 100
|
||||
float cloudStretch = cloudStretchRaw;
|
||||
#else
|
||||
float cloudStretch = cloudStretchRaw / float(CLOUD_UNBOUND_SIZE_MULT_M);
|
||||
#endif
|
||||
|
||||
float cloudTallness = cloudStretch * 2.0;
|
||||
#else
|
||||
#if CLOUD_UNBOUND_SIZE_MULT <= 100
|
||||
const float cloudStretch = cloudStretchRaw;
|
||||
#else
|
||||
const float cloudStretch = cloudStretchRaw / float(CLOUD_UNBOUND_SIZE_MULT_M);
|
||||
#endif
|
||||
const float cloudTallness = cloudStretch * 2.0;
|
||||
#endif
|
||||
|
||||
#if CLOUD_QUALITY_INTERNAL > 1
|
||||
const float cloudNarrowness = 0.00012;
|
||||
#else
|
||||
const float cloudNarrowness = 0.00006;
|
||||
#endif
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
const float pixelatedUnboundWindSpeedMult = 0.2;
|
||||
|
||||
vec3 PixelateUnboundCloudPos(vec3 tracePos, float pixelStep) {
|
||||
return (floor(tracePos / pixelStep) + 0.5) * pixelStep;
|
||||
}
|
||||
|
||||
vec2 PixelateUnboundCloudPos(vec2 tracePos, float pixelStep) {
|
||||
return (floor(tracePos / pixelStep) + 0.5) * pixelStep;
|
||||
}
|
||||
|
||||
float QuantizeCloudValue(float value, float levels) {
|
||||
return floor(value * levels + 0.5) / levels;
|
||||
}
|
||||
|
||||
float GetVoxelCloudVariation(vec3 cloudTracePos, float pixelStep) {
|
||||
vec3 voxelCoord = floor(cloudTracePos / pixelStep + 0.5);
|
||||
return fract(sin(dot(voxelCoord, vec3(12.9898, 78.233, 37.719))) * 43758.5453);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
float GetCloudNoise(vec3 tracePos, int cloudAltitude, float lTracePosXZ, float cloudPlayerPosY) {
|
||||
vec3 tracePosM = tracePos.xyz * cloudNarrowness;
|
||||
float wind = 0.0006;
|
||||
float noise = 0.0;
|
||||
float currentPersist = 1.0;
|
||||
float total = 0.0;
|
||||
|
||||
#if CLOUD_SPEED_MULT == 100
|
||||
#define CLOUD_SPEED_MULT_M CLOUD_SPEED_MULT * 0.01
|
||||
wind *= syncedTimeDynamic;
|
||||
#else
|
||||
#define CLOUD_SPEED_MULT_M CLOUD_SPEED_MULT * 0.01
|
||||
wind *= frameTimeCounter * CLOUD_SPEED_MULT_M;
|
||||
#endif
|
||||
|
||||
#if CLOUD_UNBOUND_SIZE_MULT != 100
|
||||
tracePosM *= CLOUD_UNBOUND_SIZE_MULT_M;
|
||||
wind *= CLOUD_UNBOUND_SIZE_MULT_M;
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
tracePosM *= CLOUD_UNBOUND_LAYER2_SIZE * 10.0 / CLOUD_UNBOUND_SIZE_MULT;
|
||||
wind *= CLOUD_UNBOUND_LAYER2_SIZE * 30.0 * CLOUD_LAYER2_SPEED_MULT / CLOUD_UNBOUND_SIZE_MULT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
float pixelStepM = PIXELATED_UNBOUND_CLOUDS * cloudNarrowness;
|
||||
|
||||
#if CLOUD_UNBOUND_SIZE_MULT != 100
|
||||
pixelStepM *= CLOUD_UNBOUND_SIZE_MULT_M;
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
pixelStepM *= CLOUD_UNBOUND_LAYER2_SIZE * 10.0 / CLOUD_UNBOUND_SIZE_MULT;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
int sampleCount = 5;
|
||||
float persistance = 0.43;
|
||||
float noiseMult = 0.92;
|
||||
wind *= pixelatedUnboundWindSpeedMult;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 1
|
||||
int sampleCount = 2;
|
||||
float persistance = 0.6;
|
||||
float noiseMult = 0.95;
|
||||
wind *= 0.5;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 2 || !defined DEFERRED1
|
||||
int sampleCount = 4;
|
||||
float persistance = 0.5;
|
||||
float noiseMult = 1.14;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 3
|
||||
int sampleCount = 4;
|
||||
float persistance = 0.5;
|
||||
float noiseMult = 1.0;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 4
|
||||
int sampleCount = 5;
|
||||
float persistance = 0.5;
|
||||
float noiseMult = 1.05;
|
||||
#endif
|
||||
|
||||
#ifndef DEFERRED1
|
||||
noiseMult *= 1.2;
|
||||
#endif
|
||||
|
||||
#if CLOUD_DIRECTION == 1
|
||||
tracePosM.xz = tracePosM.zx;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
vec3 windOffset = vec3(0.0, 0.0, wind);
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
vec3 pos = PixelateUnboundCloudPos(tracePosM - windOffset, pixelStepM);
|
||||
#else
|
||||
vec3 pos = tracePosM - windOffset;
|
||||
#endif
|
||||
|
||||
#if CLOUD_QUALITY_INTERNAL >= 2
|
||||
noise += Noise3D(pos) * currentPersist;
|
||||
#else
|
||||
noise += texture2DLod(noisetex, pos.xz, 0.0).b * currentPersist;
|
||||
#endif
|
||||
total += currentPersist;
|
||||
|
||||
float octaveOffset = 3.0;
|
||||
tracePosM *= octaveOffset;
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
pixelStepM *= octaveOffset;
|
||||
wind *= octaveOffset; // normalize wind speed across octaves to prevent different speed voxel grids
|
||||
#else
|
||||
wind *= 0.5;
|
||||
#endif
|
||||
currentPersist *= persistance;
|
||||
}
|
||||
noise = pow2(noise / total);
|
||||
|
||||
#define CLOUD_BASE_ADD 0.8
|
||||
//#define CLOUD_FAR_ADD -0.005
|
||||
#define CLOUD_ABOVE_ADD 0.1
|
||||
|
||||
float nightCloudRemove = NIGHT_CLOUD_UNBOUND_REMOVE * (1.0 - sunVisibility) * -0.65 + 1.0; // mapped to 1 to 0.65 range
|
||||
|
||||
float seasonCloudAdd = 0.0;
|
||||
#if SEASONS > 0
|
||||
float autumnOnlyForests = 1.0;
|
||||
#ifdef AUTUMN_CONDITION
|
||||
autumnOnlyForests = inForest;
|
||||
#endif
|
||||
float autumnWinterTime = autumnTime + winterTime;
|
||||
#if SNOW_CONDITION != 2
|
||||
autumnWinterTime *= mix(inSnowy + autumnOnlyForests, inSnowy, winterTime); // make only appear in cold biomes during winter
|
||||
#endif
|
||||
#if SNOW_CONDITION == 0
|
||||
autumnWinterTime *= mix(rainFactor + autumnOnlyForests, rainFactor, winterTime); // make only appear in rain during winter
|
||||
#endif
|
||||
seasonCloudAdd += mix(0.0, 0.35, autumnWinterTime);
|
||||
seasonCloudAdd += mix(0.0, -0.2, summerTime);
|
||||
#endif
|
||||
|
||||
noiseMult *= CLOUD_BASE_ADD
|
||||
//+ CLOUD_FAR_ADD * sqrt(lTracePosXZ + 10.0) // more/less clouds far away
|
||||
+ CLOUD_ABOVE_ADD * clamp01(-cloudPlayerPosY / cloudTallness) // more clouds when camera is above them
|
||||
+ CLOUD_UNBOUND_RAIN_ADD * rainFactor + seasonCloudAdd; // more clouds during rain and seasons
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
if (cloudAltitude != cloudAlt1i)
|
||||
noise *= noiseMult * CLOUD_UNBOUND_LAYER2_AMOUNT * nightCloudRemove;
|
||||
else
|
||||
#endif
|
||||
noise *= noiseMult * CLOUD_UNBOUND_AMOUNT * nightCloudRemove;
|
||||
|
||||
float threshold = clamp(abs(cloudAltitude - tracePos.y) / cloudStretch, 0.001, 0.999);
|
||||
threshold = pow2(pow2(pow2(threshold)));
|
||||
return noise - (threshold * 0.2 + 0.25);
|
||||
}
|
||||
|
||||
vec4 GetVolumetricClouds(int cloudAltitude, float distanceThreshold, inout float cloudLinearDepth, float skyFade, float skyMult0, vec3 cameraPos, vec3 nPlayerPos, float lViewPosM, float VdotS, float VdotU, float dither, vec3 sunVec, vec3 viewPos) {
|
||||
vec4 volumetricClouds = vec4(0.0);
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
float L1cloudStretch = cloudStretch;
|
||||
|
||||
if (cloudAltitude != cloudAlt1i) { // second layer
|
||||
cloudStretch = L2cloudStretch;
|
||||
cloudTallness = 2.0 * cloudStretch;
|
||||
}
|
||||
#endif
|
||||
|
||||
float higherPlaneAltitude = cloudAltitude + cloudStretch;
|
||||
float lowerPlaneAltitude = cloudAltitude - cloudStretch;
|
||||
|
||||
float lowerPlaneDistance = (lowerPlaneAltitude - cameraPos.y) / nPlayerPos.y;
|
||||
float higherPlaneDistance = (higherPlaneAltitude - cameraPos.y) / nPlayerPos.y;
|
||||
float minPlaneDistance = min(lowerPlaneDistance, higherPlaneDistance);
|
||||
minPlaneDistance = max(minPlaneDistance, 0.0);
|
||||
float maxPlaneDistance = max(lowerPlaneDistance, higherPlaneDistance);
|
||||
if (maxPlaneDistance < 0.0) return vec4(0.0);
|
||||
float planeDistanceDif = maxPlaneDistance - minPlaneDistance;
|
||||
|
||||
float aboveClouds = clamp01((cameraPos.y - lowerPlaneAltitude) * 0.01);
|
||||
float skyFadeM = mix(skyFade, 1.0, mix(0.4 * max(aboveClouds, rainFactor2), 1.0, clamp01(CLOUD_TRANSPARENCY - 1.0)));
|
||||
float min1CloudTransparency = min1(CLOUD_TRANSPARENCY);
|
||||
|
||||
#ifndef DEFERRED1
|
||||
float stepMult = 64.0;
|
||||
#elif PIXELATED_UNBOUND_CLOUDS > 0
|
||||
float stepMult = 3.0;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 1
|
||||
float stepMult = 16.0;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 2
|
||||
float stepMult = 32.0;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 3
|
||||
float stepMult = 16.0;
|
||||
#elif CLOUD_QUALITY_INTERNAL == 4
|
||||
float stepMult = 24.0;
|
||||
#endif
|
||||
|
||||
#if defined DOUBLE_UNBOUND_CLOUDS && (CLOUD_UNBOUND_LAYER2_SIZE > 10 || CLOUD_UNBOUND_SIZE_MULT > 100)
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
#if CLOUD_UNBOUND_LAYER2_SIZE > 10
|
||||
stepMult = stepMult / sqrt(CLOUD_UNBOUND_LAYER2_SIZE * 0.1);
|
||||
#endif
|
||||
} else {
|
||||
#if CLOUD_UNBOUND_SIZE_MULT > 100
|
||||
stepMult = stepMult / sqrt(float(CLOUD_UNBOUND_SIZE_MULT_M));
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if CLOUD_UNBOUND_SIZE_MULT > 100
|
||||
stepMult = stepMult / sqrt(float(CLOUD_UNBOUND_SIZE_MULT_M));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int sampleCount = int(planeDistanceDif / stepMult + dither + 1);
|
||||
vec3 traceAdd = nPlayerPos * stepMult;
|
||||
vec3 tracePos = cameraPos + minPlaneDistance * nPlayerPos;
|
||||
tracePos += traceAdd * dither;
|
||||
tracePos.y -= traceAdd.y;
|
||||
|
||||
float firstHitPos = 0.0;
|
||||
float VdotSM1 = max0(sunVisibility > 0.5 ? VdotS : - VdotS);
|
||||
float VdotSM1M = VdotSM1 * invRainFactor;
|
||||
float VdotSM2 = pow2(VdotSM1) * abs(sunVisibility - 0.5) * 2.0;
|
||||
float VdotSM3 = VdotSM2 * (2.5 + rainFactor) + 1.5 * rainFactor;
|
||||
float VdotSM4 = pow(VdotSM1M, 100.0) * sunVisibility;
|
||||
|
||||
#ifdef FIX_AMD_REFLECTION_CRASH
|
||||
sampleCount = min(sampleCount, 30); //BFARC
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
cloudLightColor = getAuroraAmbientColor(cloudLightColor, viewPos, 0.06, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.75);
|
||||
cloudAmbientColor = getAuroraAmbientColor(cloudAmbientColor, viewPos, 0.03, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.75);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
tracePos += traceAdd;
|
||||
|
||||
if (abs(tracePos.y - cloudAltitude) > cloudStretch) break;
|
||||
|
||||
vec3 cloudPlayerPos = tracePos - cameraPos;
|
||||
float lTracePos = length(cloudPlayerPos);
|
||||
float lTracePosXZ = length(cloudPlayerPos.xz);
|
||||
float cloudMult = 1.0;
|
||||
if (lTracePosXZ > distanceThreshold) break;
|
||||
if (lTracePos > lViewPosM) {
|
||||
if (skyFade < 0.7) continue;
|
||||
else cloudMult = skyMult0;
|
||||
}
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
float cloudWind = 0.0006;
|
||||
#if CLOUD_SPEED_MULT == 100
|
||||
cloudWind *= syncedTimeDynamic;
|
||||
#else
|
||||
cloudWind *= frameTimeCounter * (CLOUD_SPEED_MULT * 0.01);
|
||||
#endif
|
||||
|
||||
float cloudTraceScale = cloudNarrowness;
|
||||
|
||||
#if CLOUD_UNBOUND_SIZE_MULT != 100
|
||||
cloudWind *= CLOUD_UNBOUND_SIZE_MULT_M;
|
||||
cloudTraceScale *= CLOUD_UNBOUND_SIZE_MULT_M;
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
float cloudLayer2Scale = CLOUD_UNBOUND_LAYER2_SIZE * 10.0 / CLOUD_UNBOUND_SIZE_MULT;
|
||||
cloudWind *= CLOUD_UNBOUND_LAYER2_SIZE * 30.0 * CLOUD_LAYER2_SPEED_MULT / CLOUD_UNBOUND_SIZE_MULT;
|
||||
cloudTraceScale *= cloudLayer2Scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 cloudWindOffset = vec3(0.0, 0.0, (cloudWind / cloudTraceScale) * pixelatedUnboundWindSpeedMult);
|
||||
#if CLOUD_DIRECTION == 1
|
||||
cloudWindOffset.xz = cloudWindOffset.zx;
|
||||
#endif
|
||||
|
||||
vec3 cloudTracePos = PixelateUnboundCloudPos(tracePos - cloudWindOffset, PIXELATED_UNBOUND_CLOUDS);
|
||||
#else
|
||||
vec3 cloudTracePos = tracePos;
|
||||
#endif
|
||||
|
||||
float cloudNoise = GetCloudNoise(tracePos, cloudAltitude, lTracePosXZ, cloudPlayerPos.y);
|
||||
|
||||
if (cloudNoise > 0.00001) {
|
||||
#if defined DOUBLE_UNBOUND_CLOUDS
|
||||
//Fixes overlapping clouds
|
||||
|
||||
if (CLOUD_UNBOUND_LAYER2_HEIGHT > CLOUD_STRETCH){
|
||||
if (cloudAltitude == cloudAlt1i) {
|
||||
if (abs(tracePos.y - cloudAlt2i) < L2cloudStretch)
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (cloudAltitude != cloudAlt1i) {
|
||||
if (abs(tracePos.y - cloudAlt1i) < L1cloudStretch)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined CLOUD_CLOSED_AREA_CHECK && SHADOW_QUALITY > -1 && !defined VOXY_PATCH
|
||||
float shadowLength = shadowDistance * 0.9166667; //consistent08JJ622
|
||||
if (shadowLength < lTracePos)
|
||||
if (GetShadowOnCloud(tracePos, cameraPos, cloudAltitude, lowerPlaneAltitude, higherPlaneAltitude)) {
|
||||
if (eyeBrightness.y != 240) continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (firstHitPos < 1.0) {
|
||||
firstHitPos = lTracePos;
|
||||
#if CLOUD_QUALITY_INTERNAL == 1 && defined DEFERRED1
|
||||
tracePos.y += 4.0 * (texture2DLod(noisetex, tracePos.xz * cloudNarrowness * 16.0, 0.0).r - 0.5);
|
||||
#endif
|
||||
}
|
||||
|
||||
float opacityFactor = min1(cloudNoise * 8.0);
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
opacityFactor = QuantizeCloudValue(opacityFactor, 4.0);
|
||||
float pixelStep = PIXELATED_UNBOUND_CLOUDS;
|
||||
float hitDepth = max0(lTracePos - firstHitPos);
|
||||
float depthFade = exp(-hitDepth / (pixelStep * 2.6));
|
||||
opacityFactor *= mix(0.62, 1.0, depthFade);
|
||||
#endif
|
||||
|
||||
#if defined DOUBLE_UNBOUND_CLOUDS && CLOUD_UNBOUND_LAYER2_TRANSPARENCY != 20
|
||||
float cloudTransparency = cloudAltitude != cloudAlt1i ? opacityFactor * (CLOUD_UNBOUND_LAYER2_TRANSPARENCY * 0.05) : opacityFactor * min1CloudTransparency;
|
||||
#else
|
||||
float cloudTransparency = min1CloudTransparency;
|
||||
#endif
|
||||
|
||||
opacityFactor *= cloudTransparency;
|
||||
|
||||
|
||||
float cloudSampleY = tracePos.y;
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
cloudSampleY = mix(cloudTracePos.y, tracePos.y, 0.66);
|
||||
#endif
|
||||
|
||||
#ifdef INVERTED_CLOUD_SHADING
|
||||
float cloudShading = (higherPlaneAltitude - cloudSampleY) / cloudTallness;
|
||||
#else
|
||||
float cloudShading = 1.0 - (higherPlaneAltitude - cloudSampleY) / cloudTallness;
|
||||
#endif
|
||||
|
||||
cloudShading *= 1.0 + 0.2 * VdotSM3 * (1.0 - opacityFactor) + VdotSM4;
|
||||
#if CLOUD_SHADING_AMOUNT != 10
|
||||
cloudShading = pow(max0(cloudShading), CLOUD_SHADING_AMOUNT * 0.1);
|
||||
#endif
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
cloudShading *= 0.9;
|
||||
float layer2ShadeFactor = 0.0;
|
||||
#ifdef DOUBLE_UNBOUND_CLOUDS
|
||||
layer2ShadeFactor = float(cloudAltitude != cloudAlt1i);
|
||||
#endif
|
||||
|
||||
float voxelVariation = GetVoxelCloudVariation(cloudTracePos, pixelStep);
|
||||
float voxelShade = mix(0.85, 1.2, voxelVariation);
|
||||
voxelShade = mix(voxelShade, voxelShade * mix(0.3, 0.55, layer2ShadeFactor) + mix(0.7, 0.45, layer2ShadeFactor), aboveClouds);
|
||||
float cloudHeight01 = clamp01((tracePos.y - lowerPlaneAltitude) / cloudTallness);
|
||||
#ifdef INVERTED_CLOUD_SHADING
|
||||
float reverseHeight01 = cloudHeight01;
|
||||
#else
|
||||
float reverseHeight01 = 1.0 - cloudHeight01;
|
||||
#endif
|
||||
float undersideLift = reverseHeight01 * mix(0.05, 0.10, sunVisibility) * mix(1.0, 1.8, layer2ShadeFactor);
|
||||
|
||||
cloudShading *= voxelShade;
|
||||
cloudShading += undersideLift + reverseHeight01 * 0.13 * layer2ShadeFactor;
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
cloudLightColor = getAuroraAmbientColor(cloudLightColor, viewPos, 0.1, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.75);
|
||||
#endif
|
||||
|
||||
#if CLOUD_SUN_MOON_SHADING > 0
|
||||
float visibilityFactor = 1.0;
|
||||
#if CLOUD_SUN_MOON_SHADING == 1
|
||||
visibilityFactor = 1.0 - sunVisibility;
|
||||
#elif CLOUD_SUN_MOON_SHADING == 2
|
||||
visibilityFactor = sunVisibility;
|
||||
#endif
|
||||
|
||||
if (visibilityFactor > 0.0) {
|
||||
vec3 worldLightVec = mat3(gbufferModelViewInverse) * sunVec;
|
||||
float cloudLightRadius = 375.0;
|
||||
|
||||
float aboveFade = clamp01(1.0 - (cameraPos.y - cloudAltitude) / (cloudTallness * 3.0));
|
||||
float radiusFactor = mix(cloudLightRadius * 8.0, cloudLightRadius, aboveFade);
|
||||
float moonVisibility = abs(1.0 - moonPhase / 4.0);
|
||||
float sunMult = mix(moonVisibility, 0.85, sunVisibility);
|
||||
|
||||
float sunPlaneIntersect = (cloudAltitude - cameraPos.y) / worldLightVec.y;
|
||||
vec2 posVector = cameraPos.xz + worldLightVec.xz * sunPlaneIntersect - tracePos.xz;
|
||||
float falloff = exp((1.0 - max0(1.0 - length(posVector) / radiusFactor)) * -6.0) * aboveFade * sunMult;
|
||||
|
||||
float sunShadingFactor = clamp01(falloff * mix(1.0, 2.0, aboveFade) * mix(1.0, (lTracePos - minPlaneDistance) / (maxPlaneDistance - minPlaneDistance), 0.75));
|
||||
|
||||
vec3 bloodMoonCloudColor = vec3(1.0);
|
||||
#if BLOOD_MOON > 0
|
||||
bloodMoonCloudColor = mix(bloodMoonCloudColor, vec3(0.302, 0.0078, 0.0078) * 5, getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
visibilityFactor *= 0.2;
|
||||
#endif
|
||||
|
||||
cloudLightColor += bloodMoonCloudColor * sunShadingFactor * 0.3 * visibilityFactor;
|
||||
cloudShading += sunShadingFactor * 0.45 * visibilityFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLOOD_MOON > 0
|
||||
vec3 hsvCloudLightColor = rgb2hsv(cloudLightColor);
|
||||
cloudLightColor = mix(cloudLightColor, hsv2rgb(vec3(0, max(0.66, hsvCloudLightColor.y), hsvCloudLightColor.z)), getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
|
||||
vec3 colorSample = cloudAmbientColor * (0.4 + 0.6 * cloudShading) + cloudLightColor * cloudShading;
|
||||
//vec3 colorSample = 2.5 * cloudLightColor * pow2(cloudShading); // <-- Used this to take the Unbound logo
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
// Lightning flashes around lightning bolt position
|
||||
vec3 lightningPos = getLightningPos(tracePos - cameraPos, lightningBoltPosition.xyz, false);
|
||||
vec2 lightningAdd = lightningFlashEffect(lightningPos, vec3(1.0), 550.0, 0.0, 0) * isLightningActive() * 10.0;
|
||||
colorSample += lightningAdd.y;
|
||||
|
||||
// Thunderstorm cloud highlights (randomly appear in stormy weather)
|
||||
float highlightBoost = getThunderstormCloudHighlights(tracePos, cameraPos.xz, lTracePos, minPlaneDistance, maxPlaneDistance, 0.004);
|
||||
colorSample += highlightBoost;
|
||||
#endif
|
||||
|
||||
float distanceRatio = (distanceThreshold - lTracePosXZ) / distanceThreshold;
|
||||
float cloudDistanceFactor = clamp(distanceRatio, 0.0, 0.8) * 1.25;
|
||||
float cloudFogFactor = pow2(pow1_5(clamp(distanceRatio, 0.0, 1.0))) * 0.69;
|
||||
cloudFogFactor = mix(1.0, cloudFogFactor, skyFadeM);
|
||||
|
||||
bool isCustomSky;
|
||||
vec3 cloudSkyColor = GetSky(VdotU, VdotS, dither, isEyeInWater == 0, false, isCustomSky, false);
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
if (isCustomSky) {
|
||||
vec3 averageSkyColor = texelFetch(colortex14, texelCoord, 0).rgb;
|
||||
cloudSkyColor = mix(cloudSkyColor, averageSkyColor, cloudFogFactor);
|
||||
}
|
||||
#endif
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
cloudSkyColor *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
colorSample *= 1.0 - 0.2 * (1.0 - skyFadeM) * max(sunVisibility2, nightFactor);
|
||||
colorSample = mix(cloudSkyColor, colorSample, cloudFogFactor * 0.69);
|
||||
colorSample *= pow2(1.0 - maxBlindnessDarkness);
|
||||
|
||||
volumetricClouds.rgb = mix(volumetricClouds.rgb, colorSample, 1.0 - min1(volumetricClouds.a));
|
||||
volumetricClouds.a += opacityFactor * pow(cloudDistanceFactor, 0.5 + 10.0 * pow(abs(VdotSM1M), 90.0)) * cloudMult;
|
||||
#if PIXELATED_UNBOUND_CLOUDS > 0
|
||||
volumetricClouds.a += mix(0.0, min(1.0 - pow5(distanceRatio * 0.99), 0.2), cloudTransparency * (1.0 - min1(15 * pow(abs(VdotSM1M), 130.0))));
|
||||
#endif
|
||||
|
||||
if (volumetricClouds.a > 0.9) {
|
||||
volumetricClouds.a = 1.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DOUBLE_UNBOUND_CLOUDS
|
||||
if (volumetricClouds.a > 0.5)
|
||||
#endif
|
||||
{ cloudLinearDepth = sqrt(firstHitPos / renderDistance); }
|
||||
|
||||
volumetricClouds.a *= 0.5 + 0.5 * skyFadeM;
|
||||
|
||||
return volumetricClouds;
|
||||
}
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
#ifndef ENDCRYSTAL_SAMPLER_DEFINE
|
||||
uniform isampler2D endcrystal_sampler;
|
||||
#endif
|
||||
|
||||
const float healing_boundRadius = 6.0;
|
||||
const float healing_ballRadius = 3.5;
|
||||
const float healing_beamRadius = 0.6;
|
||||
const float vortex_cylinderRadius = 3.0;
|
||||
const float vortex_ballRadius = 5.0;
|
||||
const float death_radius = 70.0;
|
||||
|
||||
vec3 beamPurple = baseBeamPurple * (2.5 - 1.0 * vlFactor);
|
||||
|
||||
vec3 endDragonColM = sqrt(endOrangeCol);
|
||||
vec3 beamColM = sqrt(beamPurple);
|
||||
|
||||
const float endCrystalVoxelSize = 8.0 / END_CRYSTAL_VOXEL_PIXEL;
|
||||
|
||||
vec3 VoxelizeEndCrystalPos(vec3 relPos) {
|
||||
#if END_CRYSTAL_VOXEL_PIXEL == 0
|
||||
return relPos;
|
||||
#endif
|
||||
return (floor(relPos / endCrystalVoxelSize) + 0.5) * endCrystalVoxelSize;
|
||||
}
|
||||
|
||||
float GetBallRadius(float state) {
|
||||
return vortex_ballRadius * (1.0 + 4.0 * sqrt(1.0 - state));
|
||||
}
|
||||
|
||||
float VortexWidth(float x, float ballRadius) {
|
||||
if (x > 0.5 * ballRadius) {
|
||||
float expScale = sqrt(0.75) * ballRadius - vortex_cylinderRadius;
|
||||
return vortex_cylinderRadius + expScale * exp( -sqrt(1.0/3.0) / expScale * (x - 0.5 * ballRadius));
|
||||
} else if (x > -ballRadius) {
|
||||
return sqrt(pow2(ballRadius) - pow2(x));
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
vec4 SampleEndCrystalVortex(vec3 relPos, vec2 state, vec2 noiseOffset) {
|
||||
relPos = VoxelizeEndCrystalPos(relPos);
|
||||
float thisBallRadius = GetBallRadius(state.x);
|
||||
|
||||
float beamFactor = smoothstep(-thisBallRadius, thisBallRadius, relPos.y);
|
||||
float featureWidth = VortexWidth(relPos.y, thisBallRadius);
|
||||
vec2 horizontalScaledPos = featureWidth > 0.0 ? relPos.xz / featureWidth : vec2(2.0);
|
||||
float featureDist = length(horizontalScaledPos);
|
||||
if (length(relPos.xz) > featureWidth) {
|
||||
return vec4(0.0);
|
||||
}
|
||||
float beamStrength = 2.5 * beamFactor * (cos(featureDist * 3.1416) * 0.5 + 0.5) * pow2(max(0.0, 1 - pow2(0.005 / (0.9 * state.x + 0.1) / pow2(pow2(state.y)) * relPos.y))) * state.x;
|
||||
float spiralStrength = 200 * beamFactor * pow(featureDist, 7) * pow2(1.0 - featureDist) * pow2(max(0.0, 1 - pow2(0.02 / (0.6 * state.x * state.x + 0.4) / state.y * relPos.y)));
|
||||
float spiralAngle = (0.4 / vortex_cylinderRadius * relPos.y - 0.2 * pow2(min(0.0, -2.5 + relPos.y / thisBallRadius))) / (state.x + 0.2);
|
||||
vec2 spiralPos = mat2(cos(spiralAngle), -sin(spiralAngle), sin(spiralAngle), cos(spiralAngle)) * horizontalScaledPos;
|
||||
vec4 beamNoise = texture2DLod(noisetex, noiseOffset + 5.0 / noiseTextureResolution * horizontalScaledPos, 0.0);
|
||||
vec4 beamNoise2 = texture2DLod(noisetex, noiseOffset + 5.0 / noiseTextureResolution * vec2(relPos.y * 0.02 + 2.7 * beamNoise.gb - 3.6 * frameTimeCounter * 0.5), 0.0);
|
||||
vec4 spiralNoise = texture2DLod(noisetex, noiseOffset + 5.0 / noiseTextureResolution * spiralPos, 0.0);
|
||||
vec4 spiralNoise2 = texture2DLod(noisetex, noiseOffset + 20.0 / noiseTextureResolution * spiralPos, 0.0);
|
||||
return vec4(beamStrength * beamNoise.r * beamNoise2.r * endDragonColM + spiralStrength * pow2(spiralNoise.r) * (0.5 + spiralNoise2.r) * beamColM, beamStrength + spiralStrength) * 0.3;
|
||||
}
|
||||
|
||||
vec4 SingleEndCrystalVortex(vec3 start, vec3 direction, vec3 center, vec2 state, float dither) {
|
||||
const float stepSize = 0.5;
|
||||
float invHorizontalDirLen = 1.0 / length(direction.xz);
|
||||
float thisBallRadius = GetBallRadius(state.x);
|
||||
float closestProgress = clamp(
|
||||
dot(center.xz - start.xz, direction.xz) * pow2(invHorizontalDirLen),
|
||||
-thisBallRadius * invHorizontalDirLen,
|
||||
1.0 + thisBallRadius * invHorizontalDirLen);
|
||||
vec3 closestPos = start + closestProgress * direction;
|
||||
float closestDist = length(closestPos.xz - center.xz);
|
||||
if (closestDist > thisBallRadius) {
|
||||
return vec4(0.0);
|
||||
}
|
||||
float startProgress = closestProgress - sqrt((thisBallRadius * thisBallRadius - closestDist * closestDist)) * invHorizontalDirLen;
|
||||
float endProgress = min(1.0, 2 * closestProgress - startProgress);
|
||||
startProgress = max(0.0, startProgress);
|
||||
vec2 noiseOffset = (center.xz + cameraPosition.xz + vec2(3.0, 1.6) * frameTimeCounter) * 0.005;
|
||||
vec4 colour = vec4(0.0);
|
||||
float dist = startProgress + dither * invHorizontalDirLen * stepSize;
|
||||
for (int k = 0; k < 100; k++) {
|
||||
if (dist > endProgress) break;
|
||||
colour += SampleEndCrystalVortex(start + dist * direction - center, state, noiseOffset);
|
||||
dist += invHorizontalDirLen * stepSize;
|
||||
}
|
||||
return colour * stepSize * smoothstep(0.0, 1.0, state.x);
|
||||
}
|
||||
|
||||
float EndCrystalBeamWidth(float x, float len) {
|
||||
x = 0.5 * len - abs(x - 0.5 * len);
|
||||
if (x <= -healing_ballRadius) return 0.0;
|
||||
if (x < 0.5 * healing_ballRadius) return sqrt(pow2(healing_ballRadius) - pow2(x));
|
||||
float expScale = sqrt(0.75) * healing_ballRadius - healing_beamRadius;
|
||||
return healing_beamRadius + expScale * exp( -sqrt(1.0/3.0) / expScale * (x - 0.5 * healing_ballRadius));
|
||||
}
|
||||
|
||||
vec4 SampleEndCrystalBeam(vec3 relPos, float len) {
|
||||
relPos = VoxelizeEndCrystalPos(relPos);
|
||||
float beamWidth = EndCrystalBeamWidth(relPos.x, len);
|
||||
|
||||
if (beamWidth > 0.0001) {
|
||||
float beamFactor = smoothstep(0.0, 2.0 * healing_ballRadius, 0.5 * len - abs(relPos.x - 0.5 * len));
|
||||
float noisyTime = frameTimeCounter + 0.4 * texture2DLod(noisetex, vec2(3.0 / noiseTextureResolution, frameTimeCounter / (0.45 * noiseTextureResolution)), 0.0).r;
|
||||
|
||||
relPos.yz /= beamWidth;
|
||||
float strength = 0.0;
|
||||
vec3 healBeamColor = vec3(0.0);
|
||||
for (int k = 0; k < 3; k++) {
|
||||
vec2 noiseCoords = vec2(0.2 / noiseTextureResolution * relPos.x, 0 + vec2(k, 6 * k) / noiseTextureResolution);
|
||||
vec4 zapNoise0 = texture2DLod(noisetex, noiseCoords + floor(8.0 * noisyTime) / noiseTextureResolution, 0.0);
|
||||
vec4 zapNoise1 = texture2DLod(noisetex, 3.3 * noiseCoords + floor(8.0 * noisyTime) / noiseTextureResolution, 0.0);
|
||||
vec4 zapNoise2 = texture2DLod(noisetex, 6.8 * noiseCoords + (15.0 * frameTimeCounter) / noiseTextureResolution, 0.0);
|
||||
vec2 thisRelPos = relPos.yz + beamFactor / beamWidth * (6.0 * zapNoise0.rb + 1.6 * zapNoise1.rb + 1.2 * zapNoise2.rb - (3.0 + 0.8 + 0.6));
|
||||
vec4 sideNoise = texture2DLod(noisetex, (7.0 * thisRelPos.xy) / noiseTextureResolution, 0.0);
|
||||
vec3 colorNoise = texture2DLod(noisetex, 4.0 * noiseCoords + floor(12.0 * noisyTime) / noiseTextureResolution, 0.0).rgb;
|
||||
float centerDist0 = length(thisRelPos.xy);
|
||||
|
||||
float centerDist = centerDist0 - 1.2;
|
||||
strength = max(strength, clamp( -centerDist, 0.0, 0.2) * pow2(max(0.0, 1.0 - pow2((centerDist0 - 1.0) * beamWidth * 0.5))) * mix(1.0, sideNoise.b, beamWidth / healing_ballRadius));
|
||||
healBeamColor = mix(clamp01(saturateColors(beamColM, 0.8) - sideNoise.rgb * 0.08), saturateColors(beamColM, 1.3) * 1.3, colorNoise);
|
||||
}
|
||||
return strength / beamWidth * vec4(healBeamColor * 0.5, 1.0) + 0.2 * beamFactor * exp(-6.0 * dot(relPos.yz, relPos.yz)) * vec4(endDragonColM * 2.2, 1.0);
|
||||
}
|
||||
return vec4(0.0);
|
||||
}
|
||||
|
||||
|
||||
vec4 EndCrystalBeam(vec3 start, vec3 direction, vec3 startPos, vec3 endPos, float dither) {
|
||||
vec3 startDiff = start - startPos;
|
||||
vec3 beamDirection = endPos - startPos;
|
||||
mat3 rotMat;
|
||||
rotMat[0] = normalize(beamDirection);
|
||||
rotMat[1] = normalize(cross(beamDirection, vec3(-2e-4, 1, 1e-5)));
|
||||
rotMat[2] = cross(rotMat[0], rotMat[1]);
|
||||
start *= rotMat;
|
||||
startPos *= rotMat;
|
||||
beamDirection *= rotMat;
|
||||
direction *= rotMat;
|
||||
const float stepSize = 0.5;
|
||||
float invHorizontalDirLen = 1.0 / length(direction.yz);
|
||||
float closestProgress = clamp(
|
||||
dot(startPos.yz - start.yz, direction.yz) * pow2(invHorizontalDirLen),
|
||||
-healing_boundRadius * invHorizontalDirLen,
|
||||
1.0 + healing_boundRadius * invHorizontalDirLen);
|
||||
vec3 closestPos = start + closestProgress * direction;
|
||||
float closestDist = length(closestPos.yz - startPos.yz);
|
||||
if (closestDist > healing_boundRadius) {
|
||||
return vec4(0.0);
|
||||
}
|
||||
float startProgress = closestProgress - sqrt((healing_boundRadius * healing_boundRadius - closestDist * closestDist)) * invHorizontalDirLen;
|
||||
float endProgress = min(1.0, 2 * closestProgress - startProgress);
|
||||
startProgress = max(0.0, startProgress);
|
||||
vec4 colour = vec4(0.0);
|
||||
float dist = startProgress + dither * invHorizontalDirLen * stepSize;
|
||||
for (int k = 0; k < 100; k++) {
|
||||
if (dist > endProgress) break;
|
||||
colour += SampleEndCrystalBeam(start + dist * direction - startPos, beamDirection.x);
|
||||
dist += invHorizontalDirLen * stepSize;
|
||||
}
|
||||
return 3.0 * log(length(colour) * stepSize + 1.0) * normalize(colour + 0.0000001);
|
||||
}
|
||||
|
||||
float GetDragonDeathFactor(float dragonDeathTime) {
|
||||
return 0.02 * dragonDeathTime * exp(0.1 * dragonDeathTime);
|
||||
}
|
||||
|
||||
vec4 SampleDeathBuildup(vec3 relPos, float dragonDeathTime) {
|
||||
relPos = VoxelizeEndCrystalPos(relPos);
|
||||
float effectFactor = GetDragonDeathFactor(dragonDeathTime);
|
||||
float effectRadius = death_radius * effectFactor;
|
||||
float sizeNoiseFactor = 1.0 + 0.3 * texture2DLod(noisetex, vec2(0.2, dragonDeathTime * 5.0 / noiseTextureResolution), 0.0).r;
|
||||
float centerDist = length(relPos) / effectRadius;
|
||||
relPos *= sizeNoiseFactor;
|
||||
float angle = centerDist * 5.0 / log(dragonDeathTime * 0.6 + 1.0);
|
||||
mat2 rotMat = mat2(
|
||||
cos(angle), sin(angle),
|
||||
-sin(angle), cos(angle)
|
||||
);
|
||||
relPos.xz = rotMat * relPos.xz;
|
||||
vec2 val = pow(fract(hash23(floor(0.8 * relPos + 2.7 * sign(relPos) * exp(0.3 * dragonDeathTime)))), vec2(40.0 * pow2(centerDist))) * (1.0 - centerDist);
|
||||
return 0.1 * (vec4(beamColM, 1.0) * (val.x + 0.4 * exp(-8.0 * pow2(centerDist))) + vec4(endDragonColM, 1.0) * (val.y + 0.1 * exp(-3.0 * pow2(centerDist))));
|
||||
}
|
||||
|
||||
vec4 DragonDeathAnimation(vec3 start, vec3 direction, vec3 dragonPos, float dragonDeathTime, float dragonDeathFactor, float dither) {
|
||||
float dirLen = length(direction);
|
||||
float closestProgress = dot(dragonPos - start, direction) / pow2(dirLen);
|
||||
vec4 colour = vec4(0.0);
|
||||
if (dragonDeathFactor >= 0.99) {
|
||||
float effectRadius = death_radius * GetDragonDeathFactor(dragonDeathTime);
|
||||
vec3 closestPos = start + closestProgress * direction;
|
||||
float closestDist = length(closestPos - dragonPos);
|
||||
if (closestDist >= effectRadius) return vec4(0.0);
|
||||
float stepSize = 0.5 / dirLen;
|
||||
float startProgress = closestProgress - sqrt(pow2(effectRadius) - pow2(closestDist)) / dirLen;
|
||||
float endProgress = min(1.0, 2.0 * closestProgress - startProgress);
|
||||
startProgress = max(0.0, startProgress);
|
||||
float dist = startProgress + stepSize * dither;
|
||||
for (int k = 0; k < 150; k++) {
|
||||
if (dist > endProgress) break;
|
||||
colour += SampleDeathBuildup(start + dist * direction - dragonPos, dragonDeathTime);
|
||||
dist += stepSize;
|
||||
}
|
||||
colour *= stepSize * dirLen;
|
||||
} else {
|
||||
vec3 closestPos = start + clamp(closestProgress, 0.0, 1.0) * direction;
|
||||
float closestDist = length(dragonPos - closestPos);
|
||||
colour = vec4(endDragonColM + 0.5 * beamColM, 1.0) * (0.4 * death_radius * (1.0 - exp(-dirLen/(4.0 * death_radius))) * exp(-10.0 * (1.0 - dragonDeathFactor) - closestDist * closestDist / (death_radius * death_radius)) * dragonDeathFactor);
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
|
||||
vec4 EndCrystalVortices(vec3 start, vec3 direction, float dither) {
|
||||
vec4 color = vec4(0.0);
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL / 2 == 1 || DRAGON_DEATH_EFFECT_INTERNAL > 0
|
||||
ivec4 rawDragonPos = ivec4(
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 5), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 6), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 7), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 8), 0).r
|
||||
);
|
||||
vec3 dragonPos = rawDragonPos.xyz != ivec3(0) ? 0.0001 * rawDragonPos.xyz : vec3(0.5, 80.5, 0.5) - cameraPosition;
|
||||
#endif
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL / 2 == 1
|
||||
vec3[15] healBeamEndPositions;
|
||||
int isTarget = 0;
|
||||
int healBeamCount = 15;
|
||||
for (int k = 0; k < 15; k++) {
|
||||
ivec4 rawPos = ivec4(
|
||||
texelFetch(endcrystal_sampler, ivec2(20 + k, 5), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(20 + k, 6), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(20 + k, 7), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(20 + k, 8), 0).r
|
||||
);
|
||||
if (rawPos.w == 0) {
|
||||
healBeamCount = k;
|
||||
break;
|
||||
}
|
||||
healBeamEndPositions[k] = vec3(rawPos.xyz) / rawPos.w;
|
||||
isTarget |= (length(healBeamEndPositions[k].xz + cameraPosition.xz - 0.5) < 4.5 || length(dragonPos - healBeamEndPositions[k]) < 5.0) ? 1 << k : 0;
|
||||
}
|
||||
#endif
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL % 2 == 1
|
||||
for (int k = 0; k < 20; k++) {
|
||||
if (texelFetch(endcrystal_sampler, ivec2(k, 8), 0).r <= 0) continue;
|
||||
ivec4 rawPos = ivec4(
|
||||
texelFetch(endcrystal_sampler, ivec2(k, 5), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(k, 6), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(k, 7), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(k, 8), 0).r
|
||||
);
|
||||
if (rawPos.w <= 0) {
|
||||
continue;
|
||||
}
|
||||
int age = texelFetch(endcrystal_sampler, ivec2(k, 9), 0).r;
|
||||
vec3 pos = rawPos.xyz * 0.0001;
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL / 2 == 1
|
||||
for (int i = 0; i < healBeamCount; i++) {
|
||||
isTarget |= length(pos - healBeamEndPositions[i]) < 4.5 ? 1<<(i+15) : 0;
|
||||
}
|
||||
#endif
|
||||
vec2 state = vec2(clamp(rawPos.w / 15000.0, 0.0, 1.0), 1.00001 - exp(-0.0001 * age));
|
||||
if (length(pos) > min(shadowDistance, far) * 0.9 && state.x < 0.999) {
|
||||
state.y = state.x;
|
||||
state.x = 1.0;
|
||||
}
|
||||
vec4 thisVortexCol = pow2(SingleEndCrystalVortex(start, direction, pos, state, dither));
|
||||
color += thisVortexCol;
|
||||
}
|
||||
#endif
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL / 2 == 1
|
||||
for (int k = 0; k < healBeamCount; k++) {
|
||||
for (int l = k+1; l < healBeamCount; l++) {
|
||||
if (
|
||||
((isTarget >> k & 1) == 0 ^^ (isTarget >> l & 1) == 0)
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL % 2 == 1
|
||||
&& ((isTarget >> k + 15 & 1) == 0 ^^ (isTarget >> l + 15 & 1) == 0)
|
||||
#endif
|
||||
) {
|
||||
vec3 pos0 = healBeamEndPositions[k];
|
||||
vec3 pos1 = healBeamEndPositions[l];
|
||||
if (pos0.y > pos1.y) {
|
||||
vec3 tmp = pos0;
|
||||
pos0 = pos1;
|
||||
pos1 = tmp;
|
||||
}
|
||||
color += pow2(EndCrystalBeam(start, direction, pos0, pos1, dither));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if DRAGON_DEATH_EFFECT_INTERNAL > 0
|
||||
int isDying = texelFetch(endcrystal_sampler, ivec2(35, 0), 0).r;
|
||||
float dragonDeathTime = 0.0001 * rawDragonPos.w;
|
||||
float dragonDeathFactor = 0.0001 * isDying;
|
||||
// dragonDeathTime = mod(frameTimeCounter, 22.0);
|
||||
// dragonDeathFactor = 2.2 - 0.1 * dragonDeathTime;
|
||||
// dragonPos = vec3(0, 80, 0) - cameraPosition;
|
||||
if (dragonDeathFactor > 0.001) {
|
||||
color += pow2(DragonDeathAnimation(start, direction, dragonPos, dragonDeathTime, dragonDeathFactor, dither));
|
||||
}
|
||||
#endif
|
||||
return sqrt(color) * (1.0 - maxBlindnessDarkness);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
vec3 DrawEndFlash(vec3 nViewPos, float VdotU, float dither) {
|
||||
vec3 worldEndFlashPosition = mat3(gbufferModelViewInverse) * endFlashPosition;
|
||||
worldEndFlashPosition = normalize(worldEndFlashPosition);
|
||||
vec3 nViewPosWorld = mat3(gbufferModelViewInverse) * nViewPos;
|
||||
nViewPosWorld = normalize(nViewPosWorld);
|
||||
|
||||
vec3 horizontalEndPos = normalize(vec3(worldEndFlashPosition.x, 0.0, worldEndFlashPosition.z));
|
||||
vec3 horizontalViewPos = normalize(vec3(nViewPosWorld.x, 0.0, nViewPosWorld.z));
|
||||
float horizDirFactor = pow(max0(dot(horizontalEndPos, horizontalViewPos)), 0.2);
|
||||
|
||||
float dirFactor = pow(max0(dot(worldEndFlashPosition, nViewPosWorld)), 10.0);
|
||||
|
||||
float verticalDist = abs(nViewPosWorld.y - worldEndFlashPosition.y);
|
||||
float verticalFalloff = exp(-pow2(verticalDist * 5.5));
|
||||
|
||||
float endFlashFactor = endFlashIntensityM * dirFactor * verticalFalloff;
|
||||
|
||||
if (endFlashFactor < 0.001) return vec3(0.0);
|
||||
|
||||
float time = frameTimeCounter * 0.05;
|
||||
float pulse = sin(time * 3.0) * 0.5 + 0.5;
|
||||
|
||||
vec2 noiseCoord = horizontalViewPos.xz * 0.5 + time * 0.05;
|
||||
float noise1 = texture2DLod(noisetex, noiseCoord, 0).r;
|
||||
float noise2 = texture2DLod(noisetex, noiseCoord * 2.7 - time * 0.17, 0).g;
|
||||
float noise3 = texture2DLod(noisetex, noiseCoord * 0.5 + time * 0.05, 0).b;
|
||||
|
||||
float rayFactor = pow(max0(noise1 * noise2), 1.5) * 2.0;
|
||||
|
||||
float stripeFactor = pow(horizDirFactor, 2.0 + 4.0 * pulse);
|
||||
|
||||
// Inner core and wave animations
|
||||
float radius = 1.0 + sin(time * 2.0) * 0.1;
|
||||
float distFromCenter = length(dot(horizontalEndPos, horizontalViewPos));
|
||||
float waveFront = smoothstep(0.0, 0.2, 1.0 - abs(distFromCenter - radius) * (4.0 + pulse * 4.0));
|
||||
float core = pow(horizDirFactor, 1.0 + pulse * 2.0) * (1.0 + noise3 * 0.5);
|
||||
|
||||
float flashIntensity = mix(core, waveFront, 0.5) * endFlashFactor * (0.6 + rayFactor * 0.8);
|
||||
flashIntensity *= stripeFactor;
|
||||
|
||||
vec3 orangeColor = mix(endOrangeCol, vec3(1.0), 0.3) * (1.2 + noise2 * 1.3);
|
||||
|
||||
vec3 finalColor = saturateColors(orangeColor, 0.8) * flashIntensity * 0.7;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#ifndef ENDCRYSTAL_SAMPLER_DEFINE
|
||||
uniform isampler2D endcrystal_sampler;
|
||||
#endif
|
||||
|
||||
vec2 RayAABoxIntersection(vec2 start, vec2 dir, vec2 lower, vec2 upper) {
|
||||
dir += 0.000001 * vec2(equal(dir, vec2(0.0)));
|
||||
vec2 front = mix(upper, lower, 0.5 * sign(dir) + 0.5);
|
||||
vec2 back = mix(lower, upper, 0.5 * sign(dir) + 0.5);
|
||||
vec2 front_iscts = (front - start) / dir;
|
||||
vec2 back_iscts = (back - start) / dir;
|
||||
float front_isct = max(front_iscts.x, front_iscts.y);
|
||||
float back_isct = min(back_iscts.x , back_iscts.y );
|
||||
return front_isct < back_isct ? vec2(front_isct, back_isct) : vec2(-1);
|
||||
}
|
||||
|
||||
vec4 GetEndPortalBeamNoise(vec3 relPos) {
|
||||
float colMixFactor = texture2DLod(noisetex, (relPos.xz + 0.1 * frameTimeCounter * vec2(-0.5, 1.5)) * 10.0 / noiseTextureResolution, 0.0).r;
|
||||
float strengthMul = texture2DLod(noisetex, (relPos.xz + 0.1 * frameTimeCounter * vec2(1.5, -1.0)) * 5.0 / noiseTextureResolution + 0.2, 0.0).r;
|
||||
colMixFactor = pow2(pow2(colMixFactor));
|
||||
strengthMul = pow2(strengthMul);
|
||||
vec3 col = mix(vec3(0.1137, 0.5569, 0.5255), vec3(0.3725, 0.8863, 0.749), colMixFactor);
|
||||
float strength
|
||||
= float(relPos.y > 0 && relPos.y < 2)
|
||||
* (2 - relPos.y)
|
||||
/ (3 * relPos.y*relPos.y*relPos.y + 1)
|
||||
* (strengthMul + 0.5);
|
||||
return pow2(vec4(col, 1) * strength);
|
||||
}
|
||||
|
||||
vec4 GetEndPortalBeam(vec3 start, vec3 dir) {
|
||||
if (texelFetch(endcrystal_sampler, ivec2(35, 4), 0).r == 1) {
|
||||
ivec4 rawPortalPos = ivec4(
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 5), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 6), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 7), 0).r,
|
||||
texelFetch(endcrystal_sampler, ivec2(35, 8), 0).r
|
||||
);
|
||||
if (rawPortalPos.w > 0) {
|
||||
vec3 portalPos = floor(vec3(rawPortalPos.xyz) / max(1, rawPortalPos.w) + 0.5) + 0.5 - cameraPositionFract;
|
||||
vec2 iscts = RayAABoxIntersection(start.xz, dir.xz, portalPos.xz - 1.49, portalPos.xz + 1.49);
|
||||
int validIsctCount = 0;
|
||||
vec3[2] isctPositions;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
if (iscts[k] > 0.0 && iscts[k] < 1.0) {
|
||||
isctPositions[validIsctCount++] = start + iscts[k] * dir;
|
||||
}
|
||||
}
|
||||
vec4 col = vec4(0.0);
|
||||
for (int k = 0; k < validIsctCount; k++) {
|
||||
col += GetEndPortalBeamNoise(isctPositions[k] - portalPos);
|
||||
}
|
||||
|
||||
vec3 absDir = abs(dir);
|
||||
float maxDir = max(absDir.x, max(absDir.y, absDir.z));
|
||||
float transition = 1.0 - pow3(min1(maxDir / mix(40, 10, maxBlindnessDarkness) * 2.0)); // fade to 0 when close to the range limit (32 blocks)
|
||||
|
||||
col *= transition;
|
||||
|
||||
return col;
|
||||
}
|
||||
}
|
||||
return vec4(0.0);
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
#include "/lib/shaderSettings/enderNebula.glsl"
|
||||
|
||||
// MIT License
|
||||
// Copyright (c) 2023 jedlimlx
|
||||
// Code is based on the Supplemental Patches Code
|
||||
// https://github.com/jedlimlx/supplemental-patches/blob/multiloader/src/main/resources/resourcepacks/builtin_shaders/assets/supplemental_patches/euphoria/atmospherics/sky/enderscape_nebula/nebula.glsl
|
||||
|
||||
vec3 snapToCubeSphereGrid(vec3 wpos, int resolution) {
|
||||
vec3 absW = abs(wpos);
|
||||
vec3 faceNormal;
|
||||
vec2 uv;
|
||||
|
||||
if (absW.x >= absW.y && absW.x >= absW.z) {
|
||||
faceNormal = vec3(sign(wpos.x), 0.0, 0.0);
|
||||
uv = wpos.yz / absW.x;
|
||||
} else if (absW.y >= absW.z) {
|
||||
faceNormal = vec3(0.0, sign(wpos.y), 0.0);
|
||||
uv = wpos.xz / absW.y;
|
||||
} else {
|
||||
faceNormal = vec3(0.0, 0.0, sign(wpos.z));
|
||||
uv = wpos.xy / absW.z;
|
||||
}
|
||||
|
||||
uv = (floor((uv * 0.5 + 0.5) * float(resolution)) + 0.5) / float(resolution) * 2.0 - 1.0;
|
||||
|
||||
if (faceNormal.x != 0.0) return normalize(vec3(faceNormal.x, uv));
|
||||
if (faceNormal.y != 0.0) return normalize(vec3(uv.x, faceNormal.y, uv.y));
|
||||
return normalize(vec3(uv, faceNormal.z));
|
||||
}
|
||||
|
||||
const float nebulaNoiseAmps[6] = float[6](0.16, 0.32, 0.48, 0.63, 0.72, 0.74);
|
||||
|
||||
#if END_NEBULA_RESOLUTION == 0
|
||||
#define NEBULA_GRID_SCALE 800.0
|
||||
#else
|
||||
#define NEBULA_GRID_SCALE float(END_NEBULA_RESOLUTION * 100)
|
||||
#endif
|
||||
|
||||
vec2 GetNebulaDistortion(vec3 x) {
|
||||
#if END_NEBULA_QUALITY == 1
|
||||
const int octaves = 3;
|
||||
#elif END_NEBULA_QUALITY == 2
|
||||
const int octaves = 5;
|
||||
#elif END_NEBULA_QUALITY == 3
|
||||
const int octaves = 8;
|
||||
#elif END_NEBULA_QUALITY == 4
|
||||
const int octaves = 12;
|
||||
#elif END_NEBULA_QUALITY == 5
|
||||
const int octaves = 16;
|
||||
#endif
|
||||
|
||||
vec2 v = vec2(0.0);
|
||||
float amplitude = 1.0;
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
v += amplitude * vec2(Noise3D(x), Noise3D(3.0 * x - 200.0));
|
||||
x *= 2.0;
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
#if END_NEBULA_RESOLUTION == 0
|
||||
vec3 unprojectNebulaStarCoord(vec2 c) {
|
||||
vec2 s = c / 0.65;
|
||||
float r = length(s);
|
||||
float d = inversesqrt(r * r + (1.0 - r) * (1.0 - r));
|
||||
return normalize(vec3(s.x * d, d * (1.0 - r), s.y * d));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns (star brightness, per-star random 0-1 value used to vary how much each star blends into the nebula color)
|
||||
vec2 GetNebulaStars(vec3 wpos, float resolution, float densityMult, float seedOffset) {
|
||||
#if END_NEBULA_RESOLUTION == 0
|
||||
vec3 starCoord = 0.65 * wpos / (abs(wpos.y) + length(wpos.xz));
|
||||
vec2 starCoord2 = starCoord.xz;
|
||||
|
||||
vec2 fractPart = fract(starCoord2 * resolution);
|
||||
starCoord2 = floor(starCoord2 * resolution) / resolution;
|
||||
|
||||
float colorRand = hash12(starCoord2 * resolution + 91.7);
|
||||
|
||||
// We need to sample it here for smooth one as otherwise stars have weird noise patterns
|
||||
vec3 starDir = unprojectNebulaStarCoord(starCoord2);
|
||||
vec3 starNoiseBase = 4.0 * starDir + frameTimeCounter * 0.005 * END_NEBULA_ANIMATION_SPEED - 1417.0 + seedOffset;
|
||||
float starNoise = 0.0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int octave = i + 2;
|
||||
starNoise += nebulaNoiseAmps[i] * pow(Noise3D(starNoiseBase / pow3(float(octave))), 3.5) * 1.25;
|
||||
}
|
||||
float localDensity = clamp01(pow(max(0.0, starNoise), 18.0)) * 12.0;
|
||||
|
||||
float threshold = mix(0.97, 0.86, clamp01(localDensity * 0.1));
|
||||
float starScale = 1.0 / (1.0 - threshold);
|
||||
|
||||
float star = max0(GetStarNoise(starCoord2) - threshold) * starScale;
|
||||
star *= getStarEdgeFactor(fractPart, STAR_ROUNDNESS_END / 10.0, STAR_SOFTNESS_END);
|
||||
star *= getTwinklingStars(starCoord2, float(END_TWINKLING_STARS));
|
||||
#else
|
||||
float threshold = mix(0.97, 0.86, clamp01(densityMult * 0.1)); // denser noise zones get more star cells
|
||||
float starScale = 1.0 / (1.0 - threshold);
|
||||
|
||||
ivec3 starCell = ivec3(floor(resolution * wpos + 700.0));
|
||||
vec3 starCellHash = hash33(uvec3(starCell));
|
||||
float starHash = starCellHash.x * 0.5 + 0.5;
|
||||
float colorRand = starCellHash.y * 0.5 + 0.5;
|
||||
|
||||
float star = max0(starHash - threshold) * starScale;
|
||||
// Uses starCell coordinates instead of wpos.xy to prevent wpos.z=0 from collapsing
|
||||
// directions along the great circle into a static "vertical ring" texture lookup.
|
||||
vec2 twinkleCoord = vec2(starCell.xy) / resolution + float(starCell.z) * 1.7;
|
||||
star *= getTwinklingStars(twinkleCoord, float(END_TWINKLING_STARS));
|
||||
#endif
|
||||
|
||||
return vec2(star, colorRand);
|
||||
}
|
||||
|
||||
vec3 GetEnderNebula(vec3 viewPos, float VdotU) {
|
||||
#if END_NEBULA_HEMISPHERE != 0
|
||||
#if END_NEBULA_HEMISPHERE == 1
|
||||
if (VdotU < 0.0) return vec3(0.0);
|
||||
#else
|
||||
if (VdotU > 0.0) return vec3(0.0);
|
||||
#endif
|
||||
float nebulaBelowHorizonBrightness = min(1.0, abs(VdotU) * 3.0);
|
||||
#else
|
||||
float nebulaBelowHorizonBrightness = 1.0;
|
||||
#endif
|
||||
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
|
||||
|
||||
#if END_NEBULA_RESOLUTION > 0
|
||||
wpos = snapToCubeSphereGrid(wpos, END_NEBULA_RESOLUTION * 100);
|
||||
#endif
|
||||
|
||||
vec2 distortionRaw = GetNebulaDistortion(0.05 * wpos);
|
||||
float galaxyMask = smoothstep(1.5, 3.7, distortionRaw.x + distortionRaw.y);
|
||||
|
||||
vec2 distortion = 0.075 * END_NEBULA_DISTORTION_INTENSITY * sin(3.0 * distortionRaw);
|
||||
vec3 basis1 = vec3(-wpos.y, wpos.x, wpos.z);
|
||||
vec3 basis2 = cross(wpos, basis1);
|
||||
vec3 distortedWpos = normalize(wpos + distortion.x * basis1 + distortion.y * basis2);
|
||||
|
||||
// Use hash as direct seed causes float precision issues with large numbers
|
||||
float seedOffset = hash1(uint(END_NEBULA_SEED)) * 6967.0;
|
||||
|
||||
// layered noise builds both the nebula shape and a secondary color noise used to mix the two nebula colors
|
||||
vec3 noiseBase = 4.0 * distortedWpos + frameTimeCounter * 0.005 * END_NEBULA_ANIMATION_SPEED - 1417 + seedOffset;
|
||||
|
||||
float noise = 0.0;
|
||||
float colorNoise = 0.0;
|
||||
float coverageNoise = 0.0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int octave = i + 2; // octave 1 is always 0 amplitude, so it's skipped entirely
|
||||
float rawLayer = Noise3D(noiseBase / pow3(float(octave)));
|
||||
float layer = nebulaNoiseAmps[i] * pow(rawLayer, 3.5);
|
||||
noise += layer * 1.25;
|
||||
colorNoise += layer / float(octave);
|
||||
coverageNoise += nebulaNoiseAmps[i] * rawLayer;
|
||||
}
|
||||
|
||||
vec3 beamPurple = sqrt(baseBeamPurple * (2.5 - 1.0 * vlFactor));
|
||||
|
||||
vec3 colorOld = mix(
|
||||
sqrt(endOrangeCol),
|
||||
beamPurple,
|
||||
pow2(cos(6.7 * colorNoise) * 0.5)
|
||||
) * END_NEBULA_COLOR_2_INTENSITY + galaxyMask * 0.5;
|
||||
|
||||
vec3 color = mix(endSkyColor, colorOld, clamp01(colorNoise + galaxyMask * 0.5));
|
||||
|
||||
#if END_NEBULA_RESOLUTION > 0
|
||||
noise *= mix(1.0, hash13(NEBULA_GRID_SCALE * wpos), END_NEBULA_GRAININESS); // Causes moire on non-pixelated resolutions, aka remove it there lol
|
||||
#endif
|
||||
|
||||
float coverageFactor = 1.0;
|
||||
#if END_NEBULA_COVERAGE > 0
|
||||
float coverageThreshold = (END_NEBULA_COVERAGE * 0.1 + 1.0) * 3.05 * 0.25;
|
||||
float coverageWidth = 0.001 + coverageThreshold * 0.7;
|
||||
coverageFactor = smoothstep(coverageThreshold, coverageThreshold + coverageWidth, coverageNoise);
|
||||
noise *= coverageFactor;
|
||||
#endif
|
||||
|
||||
noise = pow(noise, 1.3);
|
||||
noise *= mix(0.8, 1.5, galaxyMask);
|
||||
|
||||
float nebulaStarFactor = mix(0.05, 0.7, clamp01(noise));
|
||||
nebulaStarFactor = mix(nebulaStarFactor, 1.5, clamp01(pow3(noise)));
|
||||
float nebulaStarDensity = clamp01(nebulaStarFactor + galaxyMask);
|
||||
nebulaStarDensity += clamp01(pow(max(0.0, noise), 18.0)) * 12.0;
|
||||
|
||||
float nebulaStars = 0.0;
|
||||
float starColorRand = 0.0;
|
||||
#if END_NEBULA_STAR_BRIGHTNESS > 0
|
||||
vec2 nebulaStarsData = GetNebulaStars(wpos, NEBULA_GRID_SCALE, nebulaStarDensity, seedOffset);
|
||||
nebulaStars = nebulaStarsData.x * nebulaStarFactor * coverageFactor * END_NEBULA_STAR_BRIGHTNESS * 0.1;
|
||||
starColorRand = nebulaStarsData.y;
|
||||
#endif
|
||||
|
||||
vec3 nebula = noise * color;
|
||||
|
||||
#ifdef END_NEBULA_ONLY_STARS
|
||||
nebula = vec3(0.0);
|
||||
#endif
|
||||
|
||||
float starColorBlend = mix(0.2, 0.93, pow(starColorRand, 0.15));
|
||||
nebula = max0(nebula + nebulaStars * mix(vec3(1.0), color, starColorBlend)) * END_NEBULA * 0.1 * nebulaBelowHorizonBrightness;
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
nebula *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
|
||||
return nebula;
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#include "/lib/shaderSettings/enderStars.glsl"
|
||||
vec3 GetEnderStars(vec3 viewPos, float VdotU, float sizeMult, float starAmount) {
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
|
||||
vec3 starCoord = 0.65 * wpos / (abs(wpos.y) + length(wpos.xz));
|
||||
vec2 starCoord2 = starCoord.xz * 0.5 / (END_STAR_SIZE * sizeMult);
|
||||
starCoord2 += VdotU < 0.0 ? 100.0 : 0.0;
|
||||
|
||||
#if END_STAR_HEMISPHERE != 0
|
||||
#if END_STAR_HEMISPHERE == 1
|
||||
if (VdotU < 0.0) return vec3(0.0);
|
||||
#else
|
||||
if (VdotU > 0.0) return vec3(0.0);
|
||||
#endif
|
||||
float starBelowHorizonBrightness = min(1.0, (abs(VdotU)) * 3.0);
|
||||
#else
|
||||
float starBelowHorizonBrightness = 1.0;
|
||||
#endif
|
||||
|
||||
const float starFactor = 1024.0;
|
||||
vec2 fractPart = fract(starCoord2 * starFactor);
|
||||
starCoord2 = floor(starCoord2 * starFactor) / starFactor;
|
||||
|
||||
float star = GetStarNoise(starCoord2.xy) * GetStarNoise(starCoord2.xy+0.1) * GetStarNoise(starCoord2.xy+0.23);
|
||||
|
||||
#if END_STAR_AMOUNT == 0
|
||||
star = max0(star - 0.77);
|
||||
#elif END_STAR_AMOUNT == 2
|
||||
star = max0((star + 0.15) * 0.9 - 0.7);
|
||||
#elif END_STAR_AMOUNT == 3
|
||||
star = max0((star + 0.4) * 0.8 - 0.7);
|
||||
#elif END_STAR_AMOUNT == 4
|
||||
star = max0((star + 0.5) * 0.8 - 0.7);
|
||||
#else
|
||||
star = max0(star - 0.7);
|
||||
#endif
|
||||
|
||||
star *= getStarEdgeFactor(fractPart, STAR_ROUNDNESS_END / 10.0, STAR_SOFTNESS_END);
|
||||
star = max0(star - starAmount * 0.1);
|
||||
star *= star;
|
||||
|
||||
vec3 starColor = GetStarColor(starCoord2,
|
||||
endSkyColor,
|
||||
vec3(STAR_COLOR_1_END_R, STAR_COLOR_1_END_G, STAR_COLOR_1_END_B),
|
||||
vec3(STAR_COLOR_2_END_R, STAR_COLOR_2_END_G, STAR_COLOR_2_END_B),
|
||||
vec3(STAR_COLOR_3_END_R, STAR_COLOR_3_END_G, STAR_COLOR_3_END_B),
|
||||
float(STAR_COLOR_VARIATION_END));
|
||||
|
||||
vec3 enderStars = star * starColor * 3000.0 * END_STAR_BRIGHTNESS * starBelowHorizonBrightness;
|
||||
|
||||
float absVdotU = abs(VdotU);
|
||||
float VdotUM2 = pow2(1.0 - absVdotU);
|
||||
enderStars *= min(VdotUM2 + 0.015, 0.05) + 0.015;
|
||||
|
||||
float VdotUM3 = smoothstep(0.0, 0.25, absVdotU);
|
||||
float endBeamHeight = END_BEAM_HEIGHT * 200.0;
|
||||
float beamFactor = END_BEAM_INTENSITY * max0(endBeamHeight - abs(END_BEAM_CENTER_ALT - cameraPosition.y)) / endBeamHeight;
|
||||
enderStars *= pow(VdotUM3, min1(beamFactor + 0.001) * min1(END_BEAM_HEIGHT));
|
||||
|
||||
#if END_TWINKLING_STARS > 0
|
||||
enderStars *= getTwinklingStars(starCoord2, float(END_TWINKLING_STARS));
|
||||
#endif
|
||||
|
||||
return enderStars * END_STAR_INTENSITY;
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#include "/lib/shaderSettings/bloom.glsl"
|
||||
#ifdef CAVE_FOG
|
||||
#include "/lib/atmospherics/fog/caveFactor.glsl"
|
||||
#endif
|
||||
|
||||
const float rainBloomAdd = 8.0;
|
||||
const float nightBloomAdd = 3.0;
|
||||
const float caveBloomAdd = 14.0;
|
||||
const float waterBloomAdd = 14.0;
|
||||
|
||||
#ifdef BORDER_FOG
|
||||
const float netherBloomAdd = 14.0;
|
||||
#else
|
||||
const float netherBloomAdd = 3.0;
|
||||
#endif
|
||||
|
||||
float GetBloomFog(float lViewPos) {
|
||||
#ifdef OVERWORLD
|
||||
float bloomFog = pow2(pow2(1.0 - exp(-lViewPos * (0.02 + 0.04 * float(isEyeInWater == 1)))));
|
||||
|
||||
float bloomFogMult;
|
||||
if (isEyeInWater != 1) {
|
||||
bloomFogMult = (rainFactor2 * rainBloomAdd + nightBloomAdd * (1.0 - sunFactor)) * eyeBrightnessM;
|
||||
#ifdef CAVE_FOG
|
||||
bloomFogMult += GetCaveFactor() * caveBloomAdd;
|
||||
#endif
|
||||
} else {
|
||||
bloomFogMult = waterBloomAdd;
|
||||
}
|
||||
#elif defined NETHER
|
||||
float farM = min(renderDistance, NETHER_VIEW_LIMIT); // consistency9023HFUE85JG
|
||||
float bloomFog = lViewPos / clamp(farM, 96.0, 512.0);
|
||||
bloomFog *= bloomFog * bloomFog;
|
||||
bloomFog = 1.0 - exp(-8.0 * bloomFog);
|
||||
bloomFog *= float(isEyeInWater == 0);
|
||||
|
||||
float bloomFogMult = netherBloomAdd;
|
||||
#else
|
||||
float bloomFog = 0.0;
|
||||
float bloomFogMult = 0.0;
|
||||
#endif
|
||||
|
||||
bloomFogMult *= BLOOM_STRENGTH * 8.33333;
|
||||
|
||||
return 1.0 + bloomFog * bloomFogMult;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#ifndef INCLUDE_CAVE_FACTOR
|
||||
#define INCLUDE_CAVE_FACTOR
|
||||
#define CAVE_FOG_R_NEW 0.13 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
|
||||
#define CAVE_FOG_G_NEW 0.13 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
|
||||
#define CAVE_FOG_B_NEW 0.15 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
|
||||
#define CAVE_FOG_I 1.00 //[0.20 0.25 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.0]
|
||||
|
||||
float GetCaveFactor() {
|
||||
float caveFactor = clamp(1.0 - cameraPosition.y / oceanAltitude, 0.0, 1.0 - eyeBrightnessM);
|
||||
#ifdef SULFUR_CAVE_FOG
|
||||
caveFactor = mix(caveFactor, 1.0, inSulfurCaves);
|
||||
#endif
|
||||
return caveFactor;
|
||||
}
|
||||
|
||||
vec3 caveFogColorRaw = vec3(CAVE_FOG_R_NEW, CAVE_FOG_G_NEW, CAVE_FOG_B_NEW) * CAVE_FOG_I;
|
||||
#if CAVE_LIGHTING < 100
|
||||
vec3 caveFogColorRaw2 = caveFogColorRaw * 0.7;
|
||||
#elif CAVE_LIGHTING == 100
|
||||
vec3 caveFogColorRaw2 = caveFogColorRaw * (0.7 + 0.3 * vsBrightness); // Default
|
||||
#elif CAVE_LIGHTING > 100
|
||||
vec3 caveFogColorRaw2 = caveFogColorRaw;
|
||||
#endif
|
||||
#ifdef SULFUR_CAVE_FOG
|
||||
vec3 caveFogColor = mix(caveFogColorRaw2, vec3(0.22, 0.25, 0.1), inSulfurCaves);
|
||||
#else
|
||||
vec3 caveFogColor = caveFogColorRaw2;
|
||||
#endif
|
||||
#endif
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
vec3 GetColoredLightFog(vec3 nPlayerPos, vec3 translucentMult, float lViewPos, float lViewPos1, float dither, float vlFactor, float caveFactor) {
|
||||
vec3 lightFog = vec3(0.0);
|
||||
|
||||
float stepMult = 8.0;
|
||||
|
||||
float maxDist = min(effectiveACTdistance * 0.5, far);
|
||||
int sampleCount = int(maxDist / stepMult + 0.001);
|
||||
vec3 traceAdd = nPlayerPos * stepMult;
|
||||
vec3 tracePos = traceAdd * dither;
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
tracePos += traceAdd;
|
||||
|
||||
float lTracePos = length(tracePos);
|
||||
if (lTracePos > lViewPos1) break;
|
||||
if (any(greaterThan(abs(tracePos * 2.0), vec3(voxelVolumeSize)))) break;
|
||||
|
||||
vec3 voxelPos = SceneToVoxel(tracePos);
|
||||
voxelPos = clamp01(voxelPos / vec3(voxelVolumeSize));
|
||||
|
||||
vec4 lightVolume = GetLightVolume(voxelPos);
|
||||
vec3 lightSample = lightVolume.rgb;
|
||||
|
||||
#if defined END && END_CENTER_LIGHTING > 0 && MC_VERSION >= 10900 && defined END_CENTER_LIGHTING_AFFECT_BLOCKLIGHT
|
||||
vec3 endCenterCol = saturateColors(vec3(END_CENTER_LIGHTING_R, END_CENTER_LIGHTING_G, END_CENTER_LIGHTING_B), 1.1);
|
||||
vec3 endCenterPos = vec3(0.5, 60.5, 0.5) - (tracePos + cameraPositionBest);
|
||||
endCenterPos.y *= 0.66; // Make it a pill-shaped point light
|
||||
float rawDistance = length(endCenterPos);
|
||||
float endCenterLightDist = exp(-rawDistance * 0.62) * 100;
|
||||
lightSample = mix(lightSample, clamp01(saturateColors(endCenterCol, 1.3)), clamp01(endCenterLightDist) * (1.0 - vlFactor));
|
||||
#endif
|
||||
|
||||
float lTracePosM = length(
|
||||
vec3(
|
||||
tracePos.x,
|
||||
#if COLORED_LIGHTING_INTERNAL <= 512
|
||||
tracePos.y * 2.0,
|
||||
#elif COLORED_LIGHTING_INTERNAL == 768
|
||||
tracePos.y * 3.0,
|
||||
#elif COLORED_LIGHTING_INTERNAL == 1024
|
||||
tracePos.y * 4.0,
|
||||
#endif
|
||||
tracePos.z
|
||||
)
|
||||
);
|
||||
lightSample *= max0(1.0 - lTracePosM / maxDist);
|
||||
lightSample *= pow2(min1(lTracePos * 0.03125));
|
||||
|
||||
#ifdef CAVE_SMOKE
|
||||
if (caveFactor > 0.00001) {
|
||||
vec3 smokePos = 0.0025 * (tracePos + cameraPosition);
|
||||
vec3 smokeWind = frameTimeCounter * vec3(0.006, 0.003, 0.0);
|
||||
float smoke = Noise3D(smokePos + smokeWind)
|
||||
* Noise3D(smokePos * 3.0 - smokeWind)
|
||||
* Noise3D(smokePos * 9.0 + smokeWind);
|
||||
smoke = smoothstep1(smoke);
|
||||
lightSample *= mix(1.0, smoke * 16.0, caveFactor);
|
||||
lightSample += caveFogColor * pow2(smoke) * 0.05 * caveFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lTracePos > lViewPos) lightSample *= translucentMult;
|
||||
lightFog += lightSample;
|
||||
}
|
||||
|
||||
#ifdef NETHER
|
||||
lightFog *= netherColor * 5.0;
|
||||
#endif
|
||||
|
||||
lightFog *= 1.0 - maxBlindnessDarkness;
|
||||
lightFog = pow(lightFog / sampleCount, vec3(0.25));
|
||||
|
||||
return lightFog;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#if !defined END_CENTER_FOG
|
||||
#define END_CENTER_FOG
|
||||
float doEndCenterFog(vec3 ro, vec3 rayDir, float wsdist, float falloff) { // Thanks to FoZy STYLE
|
||||
vec3 d = ro - vec3(0.5, 60.5, 0.5); // Light source vector
|
||||
d.y *= 0.7;
|
||||
rayDir.y *= 0.7;
|
||||
|
||||
float a = falloff * dot(rayDir, rayDir);
|
||||
float b = 2.0 * falloff * dot(rayDir, d);
|
||||
float c = 1.0 + falloff * dot(d, d);
|
||||
|
||||
float sqrtDiscr = max(0.001, sqrt(4.0 * a * c - b * b));
|
||||
float upper = (2.0 * a * wsdist + b) / sqrtDiscr;
|
||||
float lower = b / sqrtDiscr;
|
||||
|
||||
return 2.0 * (atan(upper) - atan(lower)) / sqrtDiscr;
|
||||
}
|
||||
#endif
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
#include "/lib/shaderSettings/mainFog.glsl"
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
#include "/lib/colors/colorMultipliers.glsl"
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
#include "/lib/colors/moonPhaseInfluence.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef BORDER_FOG
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#elif defined NETHER || defined END
|
||||
#include "/lib/colors/skyColors.glsl"
|
||||
#endif
|
||||
|
||||
void DoBorderFog(inout vec4 color, inout float skyFade, float lPos, float VdotU, float VdotS, float dither) {
|
||||
#ifdef OVERWORLD
|
||||
float fog = lPos / renderDistance;
|
||||
fog = pow2(pow2(fog));
|
||||
#if !defined DISTANT_HORIZONS && !defined VOXY
|
||||
fog = pow2(pow2(fog));
|
||||
#endif
|
||||
fog = 1.0 - exp(-BORDER_FOG_DISTANCE_OVERWORLD * fog);
|
||||
#endif
|
||||
#ifdef NETHER
|
||||
float farM = min(renderDistance, NETHER_VIEW_LIMIT); // consistency9023HFUE85JG
|
||||
float fog = lPos / farM;
|
||||
fog = mix(fog * BORDER_FOG_DISTANCE_NETHER / 3, min1(lPos / min(farM, 256.0)), 0.5);
|
||||
#endif
|
||||
#ifdef END
|
||||
float fog = lPos / renderDistance;
|
||||
fog = pow2(pow2(fog));
|
||||
fog = 1.0 - exp(-BORDER_FOG_DISTANCE_END * fog);
|
||||
#endif
|
||||
|
||||
#ifdef IRIS_FEATURE_FADE_VARIABLE
|
||||
#if defined GBUFFERS_WATER || defined DEFERRED1
|
||||
float chunkFadeM = mix(1.0, chunkFade, pow2(clamp01(lPos * 0.015))); // don't do fade very close to the player
|
||||
fog = mix(1.0, fog, chunkFadeM);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (fog > 0.01 + 0.0025 * dither) {
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
|
||||
#ifdef OVERWORLD
|
||||
bool isCustomSky;
|
||||
vec3 fogColorM = GetSky(VdotU, VdotS, dither, true, false, isCustomSky, false);
|
||||
#define BORDER_FOG_DENSITY BORDER_FOG_DENSITY_OVERWORLD
|
||||
#elif defined NETHER
|
||||
vec3 fogColorM = netherColor;
|
||||
#define BORDER_FOG_DENSITY BORDER_FOG_DENSITY_NETHER
|
||||
#else
|
||||
vec3 fogColorM = endSkyColor;
|
||||
#define BORDER_FOG_DENSITY BORDER_FOG_DENSITY_END
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
fogColorM *= atmColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
fogColorM *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
fog *= BORDER_FOG_DENSITY;
|
||||
color = mix(color, vec4(fogColorM, 0.0), fog);
|
||||
|
||||
#ifndef GBUFFERS_WATER
|
||||
skyFade = fog;
|
||||
#else
|
||||
skyFade = fog * (1.0 - isEyeInWater);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CAVE_FOG
|
||||
#include "/lib/atmospherics/fog/caveFactor.glsl"
|
||||
|
||||
void DoCaveFog(inout vec4 color, float lViewPos) {
|
||||
float fog = GetCaveFactor() * (0.9 - 0.9 * exp(- lViewPos * 0.015 * CAVE_FOG_DENSITY));
|
||||
|
||||
color = mix(color, vec4(caveFogColor, 0.0), fog);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ATMOSPHERIC_FOG
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
#include "/lib/colors/skyColors.glsl"
|
||||
|
||||
// SRATA: Atm. fog starts reducing above this altitude
|
||||
// CRFTM: Atm. fog continues reducing for this meters
|
||||
#ifdef OVERWORLD
|
||||
#define atmFogSRATA ATM_FOG_ALTITUDE + 0.1
|
||||
#if !defined DISTANT_HORIZONS && !defined VOXY
|
||||
float atmFogCRFTM = 60.0;
|
||||
#else
|
||||
float atmFogCRFTM = 90.0;
|
||||
#endif
|
||||
|
||||
vec3 GetAtmFogColor(float altitudeFactorRaw, float VdotS) {
|
||||
vec3 atmFogColor = vec3(ATMOSPHERIC_FOG_R_NEW, ATMOSPHERIC_FOG_G_NEW, ATMOSPHERIC_FOG_B_NEW) * ATMOSPHERIC_FOG_I;
|
||||
#ifdef RADIOACTIVE_ATMOSPHERIC_FOG
|
||||
atmFogColor *= GetLuminance(atmFogColor) * 10;
|
||||
#endif
|
||||
|
||||
float nightFogMult = 2.5 - 0.625 * max(pow2(pow2(altitudeFactorRaw)), rainFactor);
|
||||
float dayNightFogBlend = pow(invNightFactor, 4.0 - VdotS - 2.5 * sunVisibility2);
|
||||
return atmFogColor * mix(
|
||||
nightUpSkyColor * (nightFogMult - dayNightFogBlend * nightFogMult),
|
||||
dayDownSkyColor * (0.9 + 0.3 * noonFactor)
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
+ dayUpSkyColor * 0.2 * sqrt1(noonFactor)
|
||||
#endif
|
||||
,
|
||||
dayNightFogBlend
|
||||
);
|
||||
}
|
||||
#else
|
||||
float atmFogSRATA = 55.1;
|
||||
float atmFogCRFTM = 30.0;
|
||||
#endif
|
||||
|
||||
float GetAtmFogAltitudeFactor(float altitude) {
|
||||
float altitudeFactor = pow2(1.0 - clamp(altitude - atmFogSRATA, 0.0, atmFogCRFTM) / atmFogCRFTM);
|
||||
#ifndef LIGHTSHAFTS_ACTIVE
|
||||
altitudeFactor = mix(altitudeFactor, 1.0, rainFactor * 0.2);
|
||||
#endif
|
||||
return altitudeFactor;
|
||||
}
|
||||
|
||||
void DoAtmosphericFog(inout vec4 color, vec3 playerPos, float lViewPos, float VdotS, float dither) {
|
||||
#if !defined DISTANT_HORIZONS && !defined VOXY
|
||||
float renDisFactor = min1(192.0 / renderDistance);
|
||||
|
||||
#if ATM_FOG_DISTANCE != 100
|
||||
#define ATM_FOG_DISTANCE_M 100.0 / ATM_FOG_DISTANCE;
|
||||
renDisFactor *= ATM_FOG_DISTANCE_M;
|
||||
#endif
|
||||
float fog = 1.0 - exp(-pow(lViewPos * (0.001 - 0.0007 * rainFactor), 2.0 - rainFactor2) * lViewPos * renDisFactor);
|
||||
#else
|
||||
float fog = 1.0 - exp2(-max0(lViewPos - 40.0) * (0.4 + 0.4 * rainFactor) / ATM_FOG_DISTANCE);
|
||||
#endif
|
||||
|
||||
float altitudeFactorRaw = GetAtmFogAltitudeFactor(playerPos.y + cameraPosition.y);
|
||||
float altitudeFactor = altitudeFactorRaw * 0.9 + 0.1;
|
||||
float atmFogMultVar = ATMOSPHERIC_FOG_DENSITY * ATM_FOG_MULT;
|
||||
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
altitudeFactor = mix(altitudeFactor, 1.0, pow2(pow2(fog)));
|
||||
#endif
|
||||
|
||||
fog *= atmFogMultVar - 0.1 - 0.15 * invRainFactor;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float cameraAltitudeFactor = GetAtmFogAltitudeFactor(cameraPosition.y + 0.25 * atmFogCRFTM);
|
||||
altitudeFactor = mix(altitudeFactor, 1.0, 0.8 * cameraAltitudeFactor);
|
||||
|
||||
altitudeFactor *= 1.0 - 0.5 * cameraAltitudeFactor * invRainFactor;
|
||||
|
||||
#if defined SPECIAL_BIOME_WEATHER || RAIN_STYLE == 2
|
||||
if (isEyeInWater == 0) {
|
||||
#if RAIN_STYLE == 2
|
||||
float factor = 1.0;
|
||||
#else
|
||||
float factor = max(inSnowy, inDry);
|
||||
#endif
|
||||
|
||||
float fogFactor = 4.0;
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
fogFactor += 2.0 * inDry;
|
||||
#endif
|
||||
fogFactor *= 0.5 + 0.5 * sunVisibility;
|
||||
|
||||
float fogIntense = pow2(1.0 - exp(-lViewPos * fogFactor / ATM_FOG_DISTANCE));
|
||||
fog = mix(fog, fogIntense / altitudeFactor, 0.8 * rainFactor * factor);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CAVE_FOG
|
||||
fog *= 0.2 + 0.8 * sqrt2(eyeBrightnessM);
|
||||
fog *= 1.0 - GetCaveFactor();
|
||||
#else
|
||||
fog *= eyeBrightnessM;
|
||||
#endif
|
||||
#else
|
||||
fog *= 0.5;
|
||||
#endif
|
||||
|
||||
fog *= altitudeFactor;
|
||||
|
||||
if (fog > 0.01 + 0.0025 * dither) {
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 fogColorM = GetAtmFogColor(altitudeFactorRaw, VdotS);
|
||||
#else
|
||||
vec3 fogColorM = endSkyColor * 1.5;
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
fogColorM *= atmColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
fogColorM *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
color = mix(color, vec4(fogColorM, 0.0), fog);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "/lib/atmospherics/fog/waterFog.glsl"
|
||||
|
||||
void DoWaterFog(inout vec4 color, float lViewPos) {
|
||||
float fog = GetWaterFog(lViewPos);
|
||||
color = mix(color, vec4(waterFogColor, 0), fog);
|
||||
}
|
||||
|
||||
void DoLavaFog(inout vec4 color, float lViewPos) {
|
||||
#ifndef VOXY_PATCH
|
||||
float fog = (lViewPos * 3.0 - gl_Fog.start) * gl_Fog.scale;
|
||||
|
||||
#ifdef LESS_LAVA_FOG
|
||||
fog = sqrt(fog) * 0.4;
|
||||
#endif
|
||||
|
||||
fog = 1.0 - exp(-fog);
|
||||
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
#else
|
||||
float fog = 1.0;
|
||||
#endif
|
||||
|
||||
color = mix(color, vec4(fogColor * 5.0, 0.0), fog);
|
||||
}
|
||||
|
||||
void DoPowderSnowFog(inout vec4 color, float lViewPos) {
|
||||
float fog = lViewPos;
|
||||
|
||||
#ifdef LESS_LAVA_FOG
|
||||
fog = sqrt(fog) * 0.4;
|
||||
#endif
|
||||
|
||||
fog *= fog;
|
||||
fog = 1.0 - exp(-fog);
|
||||
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
color = mix(color, vec4(fogColor, 0.0), fog);
|
||||
}
|
||||
|
||||
void DoBlindnessFog(inout vec4 color, float lViewPos) {
|
||||
float fog = lViewPos * 0.3 * blindness;
|
||||
fog *= fog;
|
||||
fog = 1.0 - exp(-fog);
|
||||
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
color *= 1.0 - fog;
|
||||
}
|
||||
|
||||
void DoDarknessFog(inout vec4 color, float lViewPos) {
|
||||
float fog = lViewPos * 0.075 * darknessFactor;
|
||||
fog *= fog;
|
||||
fog *= fog;
|
||||
color *= exp(-fog);
|
||||
}
|
||||
|
||||
void DoFog(inout vec4 color, inout float skyFade, float lViewPos, vec3 playerPos, float VdotU, float VdotS, float dither, bool isReflection, float lBlockPos) {
|
||||
#ifdef CAVE_FOG
|
||||
DoCaveFog(color, lViewPos);
|
||||
#endif
|
||||
#ifdef ATMOSPHERIC_FOG
|
||||
float lViewPosAtm = lViewPos;
|
||||
// Reduce fog if the reflecting block is already behind fog, and fogging the reflection would result in too much fog
|
||||
if (isReflection) lViewPosAtm *= max0(1.0 - lBlockPos / lViewPos);
|
||||
DoAtmosphericFog(color, playerPos, lViewPosAtm, VdotS, dither);
|
||||
#endif
|
||||
#ifdef BORDER_FOG
|
||||
DoBorderFog(color, skyFade, max(length(playerPos.xz), abs(playerPos.y)), VdotU, VdotS, dither);
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 1) DoWaterFog(color, lViewPos);
|
||||
else if (isEyeInWater == 2) DoLavaFog(color, lViewPos);
|
||||
else if (isEyeInWater == 3) DoPowderSnowFog(color, lViewPos);
|
||||
|
||||
if (blindness > 0.00001) DoBlindnessFog(color, lViewPos);
|
||||
if (darknessFactor > 0.00001) DoDarknessFog(color, lViewPos);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#ifndef INCLUDE_WATER_FOG
|
||||
#define INCLUDE_WATER_FOG
|
||||
|
||||
float GetWaterFog(float lViewPos) {
|
||||
#if WATER_FOG_MULT != 100
|
||||
#define WATER_FOG_MULT_M WATER_FOG_MULT * 0.01;
|
||||
lViewPos *= WATER_FOG_MULT_M;
|
||||
#endif
|
||||
|
||||
#if LIGHTSHAFT_QUALI > 0 && SHADOW_QUALITY > -1
|
||||
float fog = lViewPos / 48.0;
|
||||
fog *= fog;
|
||||
#else
|
||||
float fog = lViewPos / 32.0;
|
||||
#endif
|
||||
|
||||
return 1.0 - exp(-fog);
|
||||
}
|
||||
#endif
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#include "/lib/shaderSettings/netherFog.glsl"
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
#include "/mcwind/mcwind.glsl"
|
||||
#include "/lib/atmospherics/netherWind.glsl"
|
||||
#endif
|
||||
|
||||
vec3 GetNetherNoise(vec3 viewPos, float VdotU, float dither) {
|
||||
float visibility = clamp01(VdotU * 1.875 - 0.225);
|
||||
visibility *= 1.0 - VdotU * 0.75 - maxBlindnessDarkness;
|
||||
|
||||
if (visibility > 0.0) {
|
||||
vec3 spots = vec3(0.0);
|
||||
|
||||
float eyeAltitude1 = eyeAltitude * 0.005;
|
||||
float noiseHeightFactor = max(0.0, 1.5 - eyeAltitude1 / (eyeAltitude1 + 1.0));
|
||||
noiseHeightFactor *= noiseHeightFactor;
|
||||
float noiseHeight = noiseHeightFactor * 0.5;
|
||||
|
||||
vec3 wpos = (gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz;
|
||||
wpos.xz /= wpos.y;
|
||||
|
||||
vec2 cameraPositionM = cameraPosition.xz * 0.0075;
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
vec3 mcwWind = mcw_windAtFast(cameraPosition, mcw_windPhase, MCW_NF_NO_GROUND, mcw_flowAt(cameraPosition));
|
||||
vec2 mcwDrift = vec2(mcw_windDriftX, mcw_windDriftZ);
|
||||
cameraPositionM -= mod((mcwDrift * NETHER_FOG_LAYER_FAST
|
||||
+ mcwWind.xz * (MCW_NF_HAZE_LOCAL * MCW_NF_STILL_TIME)) * 0.0075,
|
||||
MCW_NF_HAZE_PERIOD);
|
||||
#else
|
||||
cameraPositionM.x += frameTimeCounter * 0.004;
|
||||
#endif
|
||||
|
||||
int sampleCount = 10;
|
||||
int sampleCountP = sampleCount + 5;
|
||||
float ditherM = dither + 5.0;
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
float wind = fract(mcw_windPhase * (120.0 / MCW_PHASE_WRAP)
|
||||
+ length(mcwDrift) * NETHER_FOG_LAYER_FAST * MCW_NF_HAZE_CHURN);
|
||||
#else
|
||||
float wind = fract(frameTimeCounter * 0.0125);
|
||||
#endif
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
float current = pow2((i + ditherM) / sampleCountP);
|
||||
|
||||
vec2 planePos = wpos.xz * (0.8 + current) * noiseHeight;
|
||||
planePos = (planePos * 0.5 + cameraPositionM * 0.5) * 1.5;
|
||||
float noiseSpots = texture2DLod(noisetex, planePos * 0.5, 0.0).g;
|
||||
vec3 noise = texture2DLod(noisetex, vec2(noiseSpots) + wind, 0.0).g * netherColor * 2.5 - netherColor * 1.3;
|
||||
|
||||
float currentM = 1.0 - current;
|
||||
spots += noise * currentM * 6.0;
|
||||
}
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
spots += 2.0 * isLightningActive();
|
||||
#endif
|
||||
|
||||
return spots * visibility / sampleCount;
|
||||
}
|
||||
|
||||
return vec3(0.0);
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
#include "/lib/shaderSettings/netherFog.glsl"
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
#include "/mcwind/mcwind.glsl"
|
||||
#include "/lib/atmospherics/netherWind.glsl"
|
||||
|
||||
#define NETHER_STORM_WIND_OCTAVE (2.0 * NETHER_FOG_WIND_CHURN)
|
||||
#else
|
||||
#define NETHER_STORM_WIND_OCTAVE (-2.0)
|
||||
#endif
|
||||
|
||||
vec4 GetNetherStorm(vec3 color, vec3 translucentMult, vec3 nPlayerPos, vec3 playerPos, float lViewPos, float lViewPos1, float dither) {
|
||||
if (isEyeInWater != 0) return vec4(0.0);
|
||||
vec4 netherStorm = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
|
||||
#ifdef BORDER_FOG
|
||||
float maxDist = min(renderDistance, NETHER_VIEW_LIMIT); // consistency9023HFUE85JG
|
||||
#else
|
||||
float maxDist = renderDistance;
|
||||
#endif
|
||||
|
||||
maxDist = min(maxDist, 512.0); // Going higher than 32 chunks causes way too much performance loss
|
||||
|
||||
#ifndef LOW_QUALITY_NETHER_STORM
|
||||
int sampleCount = int(maxDist / 8.0 + 0.001);
|
||||
|
||||
vec3 traceAdd = nPlayerPos * maxDist / sampleCount;
|
||||
vec3 tracePos = cameraPosition;
|
||||
tracePos += traceAdd * dither;
|
||||
#else
|
||||
int sampleCount = int(maxDist / 16.0 + 0.001);
|
||||
|
||||
vec3 traceAdd = 0.75 * nPlayerPos * maxDist / sampleCount;
|
||||
vec3 tracePos = cameraPosition;
|
||||
tracePos += traceAdd * dither;
|
||||
tracePos += traceAdd * sampleCount * 0.25;
|
||||
#endif
|
||||
|
||||
vec3 translucentMultM = pow(translucentMult, vec3(1.0 / sampleCount));
|
||||
float translucentMultM2 = GetLuminance(translucentMultM);
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
mcwNetherWind mcwWind = GetNetherWind(nPlayerPos, maxDist);
|
||||
vec3 mcwSlow0 = fract(-mcwWind.slow * 0.001 * vec3(2.0, 0.5, 2.0) + MCW_NF_LAYER_SPLIT);
|
||||
vec3 mcwFast0 = fract(-mcwWind.fast * 0.001 * vec3(2.0, 0.5, 2.0));
|
||||
vec3 mcwWarp = fract(-mcwWind.fast * 0.001);
|
||||
float mcwPoolAccum = 0.0;
|
||||
float mcwPoolWeight = 0.0;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
tracePos += traceAdd;
|
||||
|
||||
vec3 tracedPlayerPos = tracePos - cameraPosition;
|
||||
float lTracePos = length(tracedPlayerPos);
|
||||
if (lTracePos > lViewPos1) break;
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
float mcwAltitude = clamp((tracePos.y - NETHER_STORM_LOWER_ALT) / NETHER_STORM_HEIGHT, -1.0, 1.0);
|
||||
float mcwAlong = clamp(lTracePos / maxDist, 0.0, 1.0);
|
||||
vec3 mcwLocal = GetNetherLocalWind(mcwWind, tracePos, mcwAlong);
|
||||
#if NETHER_FOG_SKIN_DEPTH > 0
|
||||
mcwNetherProbe mcwProbe = GetNetherSkin(tracePos, mcwLocal);
|
||||
#else
|
||||
mcwNetherProbe mcwProbe;
|
||||
mcwProbe.skin = 0.0; mcwProbe.impact = 0.0; mcwProbe.deflect = vec3(0.0);
|
||||
#endif
|
||||
mcwNetherLayers mcwL = GetNetherLayers(mcwLocal, mcwAltitude, mcwProbe.skin, mcwProbe.impact);
|
||||
vec3 mcwDefl = mcwProbe.deflect * 0.001 * vec3(2.0, 0.5, 2.0);
|
||||
vec3 windSlow = fract(mcwSlow0 + mcwDefl);
|
||||
vec3 windFast = fract(mcwFast0 + mcwDefl);
|
||||
vec3 warp = mcwWarp;
|
||||
#else
|
||||
vec3 windFast = vec3(frameTimeCounter * 0.002);
|
||||
vec3 warp = windFast;
|
||||
#endif
|
||||
|
||||
vec3 tracePosM = tracePos * 0.001;
|
||||
tracePosM.y += tracePosM.x;
|
||||
tracePosM += Noise3D(tracePosM - warp) * 0.01;
|
||||
tracePosM = tracePosM * vec3(2.0, 0.5, 2.0);
|
||||
|
||||
float traceAltitudeM = abs(tracePos.y - NETHER_STORM_LOWER_ALT);
|
||||
if (tracePos.y < NETHER_STORM_LOWER_ALT) traceAltitudeM *= 10.0;
|
||||
traceAltitudeM = 1.0 - min1(abs(traceAltitudeM) / NETHER_STORM_HEIGHT);
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
float mcwBeforeA = netherStorm.a;
|
||||
#endif
|
||||
|
||||
for (int h = 0; h < 4; h++) {
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
float stormSample = pow2(mix(Noise3D(tracePosM + windSlow), Noise3D(tracePosM + windFast), mcwL.blend));
|
||||
#else
|
||||
float stormSample = pow2(Noise3D(tracePosM + windFast));
|
||||
#endif
|
||||
stormSample *= traceAltitudeM;
|
||||
stormSample = pow2(pow2(stormSample));
|
||||
stormSample *= sqrt1(max0(1.0 - lTracePos / maxDist));
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
stormSample *= mcwL.pool;
|
||||
#endif
|
||||
|
||||
netherStorm.a += stormSample;
|
||||
tracePosM *= 2.0;
|
||||
windFast *= NETHER_STORM_WIND_OCTAVE;
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
windSlow *= NETHER_STORM_WIND_OCTAVE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
float mcwContrib = netherStorm.a - mcwBeforeA;
|
||||
mcwPoolAccum += (mcwL.pool) * mcwContrib;
|
||||
mcwPoolWeight += mcwContrib;
|
||||
#endif
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
vec3 lightningPos = getLightningPos(tracePos - cameraPosition, lightningBoltPosition.xyz, false);
|
||||
vec2 lightningAdd = lightningFlashEffect(lightningPos, vec3(1.0), 150.0, 0.0, 0) * isLightningActive() * 8.0;
|
||||
netherStorm.rgb += lightningAdd.y;
|
||||
#endif
|
||||
|
||||
if (lTracePos > lViewPos) {
|
||||
netherStorm.rgb *= translucentMultM;
|
||||
netherStorm.a *= translucentMultM2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOW_QUALITY_NETHER_STORM
|
||||
netherStorm.a *= 1.8;
|
||||
#endif
|
||||
|
||||
float netherFogDensity = 1.0;
|
||||
#ifdef MCWIND_NETHER_FOG_INTERNAL
|
||||
if (mcwPoolWeight > 1.0e-6) netherFogDensity = max(netherFogDensity, mcwPoolAccum / mcwPoolWeight);
|
||||
#endif
|
||||
netherStorm.a = min1(netherStorm.a * NETHER_STORM_I * netherFogDensity);
|
||||
|
||||
netherStorm.rgb *= netherColor * 3.0 * (1.0 - maxBlindnessDarkness);
|
||||
|
||||
//if (netherStorm.a > 0.98) netherStorm.rgb = vec3(1,0,1);
|
||||
//netherStorm.a *= 1.0 - max0(netherStorm.a - 0.98) * 50.0;
|
||||
|
||||
return netherStorm;
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
// Thanks to PlunderPixels
|
||||
|
||||
#ifndef NETHER_WIND_GLSL
|
||||
#define NETHER_WIND_GLSL
|
||||
|
||||
#ifndef MCW_NF_MAG_LOW
|
||||
#define MCW_NF_MAG_LOW 0.10
|
||||
#endif
|
||||
#ifndef MCW_NF_MAG_HIGH
|
||||
#define MCW_NF_MAG_HIGH 0.70
|
||||
#endif
|
||||
#ifndef MCW_NF_HAZE_CHURN
|
||||
#define MCW_NF_HAZE_CHURN 0.0004
|
||||
#endif
|
||||
#ifndef MCW_NF_STILL_TIME
|
||||
#define MCW_NF_STILL_TIME 20.0
|
||||
#endif
|
||||
#ifndef MCW_NF_HAZE_LOCAL
|
||||
#define MCW_NF_HAZE_LOCAL 2.0
|
||||
#endif
|
||||
|
||||
#define MCW_NF_LAYER_SPLIT vec3(0.37, 0.23, 0.61)
|
||||
|
||||
#define MCW_NF_HAZE_PERIOD (8.0 / 3.0)
|
||||
|
||||
#ifndef MCW_NF_SKIN_INNER
|
||||
#define MCW_NF_SKIN_INNER 0.42
|
||||
#endif
|
||||
#ifndef MCW_NF_SKIN_GRAIN
|
||||
#define MCW_NF_SKIN_GRAIN 0.11
|
||||
#endif
|
||||
#ifndef MCW_NF_SKIN_EDGE_GRAIN
|
||||
#define MCW_NF_SKIN_EDGE_GRAIN 0.63
|
||||
#endif
|
||||
|
||||
#define MCW_NF_NO_GROUND (-1.0)
|
||||
|
||||
struct mcwNetherWind {
|
||||
vec3 flowNear;
|
||||
vec3 flowFar;
|
||||
vec3 slow;
|
||||
vec3 fast;
|
||||
float t;
|
||||
};
|
||||
|
||||
struct mcwNetherProbe {
|
||||
float skin;
|
||||
float impact;
|
||||
vec3 deflect;
|
||||
};
|
||||
|
||||
struct mcwNetherLayers {
|
||||
float blend;
|
||||
float pool;
|
||||
};
|
||||
|
||||
mcwNetherWind GetNetherWind(vec3 nPlayerPos, float maxDist) {
|
||||
mcwNetherWind w;
|
||||
w.t = mcw_windPhase;
|
||||
w.flowNear = mcw_flowAt(cameraPosition);
|
||||
w.flowFar = mcw_flowAt(cameraPosition + nPlayerPos * maxDist);
|
||||
|
||||
vec3 drift = vec3(mcw_windDriftX, 0.0, mcw_windDriftZ);
|
||||
w.slow = drift * NETHER_FOG_LAYER_SLOW;
|
||||
w.fast = drift * NETHER_FOG_LAYER_FAST;
|
||||
return w;
|
||||
}
|
||||
|
||||
vec3 GetNetherLocalWind(mcwNetherWind w, vec3 worldPos, float along) {
|
||||
return mcw_windAtFast(worldPos, w.t, MCW_NF_NO_GROUND, mix(w.flowNear, w.flowFar, along));
|
||||
}
|
||||
|
||||
#if NETHER_FOG_SKIN_DEPTH > 0
|
||||
mcwNetherProbe GetNetherSkin(vec3 worldPos, vec3 local) {
|
||||
mcwNetherProbe o;
|
||||
o.skin = 0.0;
|
||||
o.impact = 0.0;
|
||||
o.deflect = vec3(0.0);
|
||||
if (!mcw_hasOccupancy()) {
|
||||
return o;
|
||||
}
|
||||
float trust = mcw_caveTrust(worldPos);
|
||||
if (trust <= 0.0) {
|
||||
return o;
|
||||
}
|
||||
|
||||
float vary = mcw_noise(worldPos.xz * MCW_NF_SKIN_GRAIN)
|
||||
+ mcw_noise(vec2(worldPos.y, worldPos.x + 41.0) * MCW_NF_SKIN_GRAIN);
|
||||
float edge = mcw_noise(worldPos.xz * MCW_NF_SKIN_EDGE_GRAIN)
|
||||
+ mcw_noise(vec2(worldPos.y, worldPos.z + 19.0) * MCW_NF_SKIN_EDGE_GRAIN);
|
||||
float rOut = NETHER_FOG_SKIN_DEPTH
|
||||
+ (vary - 1.0) * (NETHER_FOG_SKIN_VARY * 0.5)
|
||||
+ (edge - 1.0) * (NETHER_FOG_SKIN_SOFTEN * 0.5);
|
||||
rOut = max(rOut, 1.0);
|
||||
float rIn = rOut * MCW_NF_SKIN_INNER;
|
||||
|
||||
float strong = 0.0;
|
||||
float weak = 0.0;
|
||||
vec3 rock = vec3(0.0);
|
||||
for (int a = 0; a < 3; a++) {
|
||||
vec3 axis = (a == 0) ? vec3(1.0, 0.0, 0.0) : ((a == 1) ? vec3(0.0, 1.0, 0.0) : vec3(0.0, 0.0, 1.0));
|
||||
for (int s = 0; s < 2; s++) {
|
||||
vec3 dir = (s == 0) ? axis : -axis;
|
||||
float hitOut = mcw_readVoxel(worldPos + dir * rOut, cameraPosition).solid ? 1.0 : 0.0;
|
||||
float hitIn = mcw_readVoxel(worldPos + dir * rIn, cameraPosition).solid ? 1.0 : 0.0;
|
||||
weak += hitOut;
|
||||
strong += hitOut * hitIn;
|
||||
rock += dir * (hitIn * 0.7 + hitOut * 0.3);
|
||||
}
|
||||
}
|
||||
o.skin = trust * clamp((strong + 0.5 * weak) * 0.5, 0.0, 1.0);
|
||||
|
||||
float wlen = length(local.xz);
|
||||
if (wlen < 1.0e-4) {
|
||||
return o;
|
||||
}
|
||||
vec3 flowDir = vec3(local.x, 0.0, local.z) / wlen;
|
||||
|
||||
float edgeA = mcw_noise(worldPos.xz * MCW_NF_SKIN_EDGE_GRAIN + vec2(53.0, 11.0))
|
||||
+ mcw_noise(vec2(worldPos.y + 7.0, worldPos.z - 23.0) * MCW_NF_SKIN_EDGE_GRAIN);
|
||||
float aOut = max(NETHER_FOG_SKIN_DEPTH + (edgeA - 1.0) * (NETHER_FOG_SKIN_SOFTEN * 0.5), 1.0);
|
||||
float aIn = aOut * MCW_NF_SKIN_INNER;
|
||||
float aheadFar = mcw_readVoxel(worldPos + flowDir * aOut, cameraPosition).solid ? 1.0 : 0.0;
|
||||
float aheadNear = mcw_readVoxel(worldPos + flowDir * aIn, cameraPosition).solid ? 1.0 : 0.0;
|
||||
o.impact = trust * clamp(aheadNear * 0.65 + aheadFar * 0.35, 0.0, 1.0);
|
||||
|
||||
float rlen = length(rock);
|
||||
if (rlen > 1.0e-4) {
|
||||
vec3 nOut = -rock / rlen;
|
||||
float into = min(dot(flowDir, nOut), 0.0);
|
||||
vec3 tangent = flowDir - nOut * dot(flowDir, nOut);
|
||||
float tlen = length(tangent);
|
||||
if (tlen > 1.0e-4) {
|
||||
o.deflect = (tangent / tlen) * ((-into) * o.impact * NETHER_FOG_WALL_SPREAD);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
#endif
|
||||
|
||||
mcwNetherLayers GetNetherLayers(vec3 local, float altitude, float shelter, float impact) {
|
||||
float mag = length(local.xz);
|
||||
float windiness = smoothstep(MCW_NF_MAG_LOW, MCW_NF_MAG_HIGH, mag);
|
||||
|
||||
float open = (1.0 - shelter)
|
||||
+ NETHER_FOG_LAYER_LIFT * altitude
|
||||
+ NETHER_FOG_LAYER_GUST * (windiness - 0.5);
|
||||
open = clamp(open, 0.0, 1.0);
|
||||
|
||||
mcwNetherLayers o;
|
||||
float edge = 0.5 / max(NETHER_FOG_LAYER_BIAS, 1.0);
|
||||
o.blend = smoothstep(0.5 - edge, 0.5 + edge, open);
|
||||
o.pool = max(1.0 - NETHER_FOG_WIND_POOL * (2.0 * open - 1.0), NETHER_FOG_OPEN_DENSITY)
|
||||
* (1.0 + NETHER_FOG_WALL_PILE * impact);
|
||||
return o;
|
||||
}
|
||||
|
||||
#endif
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
#include "/lib/atmospherics/stars.glsl"
|
||||
|
||||
// Nebula implementation by flytrap https://godotshaders.com/shader/2d-nebula-shader/
|
||||
#include "/lib/shaderSettings/stars.glsl"
|
||||
#include "/lib/shaderSettings/nightNebula.glsl"
|
||||
|
||||
#ifndef HQ_NIGHT_NEBULA
|
||||
const int OCTAVE = 5;
|
||||
#else
|
||||
const int OCTAVE = 8;
|
||||
#endif
|
||||
|
||||
const float timescale = 5.0;
|
||||
const float zoomScale = NEBULA_ZOOM_LEVEL;
|
||||
|
||||
const vec4 CLOUD1_COL = vec4(NEBULA_R_1, NEBULA_G_1, NEBULA_B_1, 0.4);
|
||||
const vec4 CLOUD2_COL = vec4(NEBULA_R_2, NEBULA_G_2, NEBULA_B_2, 0.2);
|
||||
const vec4 CLOUD3_COL = vec4(NEBULA_R_3, NEBULA_G_3, NEBULA_B_3, 1.0);
|
||||
|
||||
float sinM(float x) {
|
||||
return sin(mod(x, 2.0 * pi));
|
||||
}
|
||||
|
||||
float cosM(float x) {
|
||||
return cos(mod(x, 2.0 * pi));
|
||||
}
|
||||
|
||||
float rand(vec2 inCoord){
|
||||
return fract(sinM(dot(inCoord, vec2(23.5, 44.0))) * 42350.45);
|
||||
}
|
||||
|
||||
float perlin(vec2 inCoord){
|
||||
vec2 i = floor(inCoord);
|
||||
vec2 j = fract(inCoord);
|
||||
vec2 coord = smoothstep(0.0, 1.0, j);
|
||||
|
||||
float a = rand(i);
|
||||
float b = rand(i + vec2(1.0, 0.0));
|
||||
float c = rand(i + vec2(0.0, 1.0));
|
||||
float d = rand(i + vec2(1.0, 1.0));
|
||||
|
||||
return mix(mix(a, b, coord.x), mix(c, d, coord.x), coord.y);
|
||||
}
|
||||
|
||||
float fbmCloud(vec2 inCoord, float minimum){
|
||||
float value = 0.0;
|
||||
float scale = NEBULA_AMOUNT * 0.1 + 0.45;
|
||||
|
||||
for (int i = 0; i < OCTAVE; i++){
|
||||
value += perlin(inCoord) * scale;
|
||||
inCoord *= 2.0;
|
||||
scale *= 0.5;
|
||||
}
|
||||
|
||||
return smoothstep(0.0, 1.0, (smoothstep(minimum, 1.0, value) - minimum) / (1.0 - minimum));
|
||||
}
|
||||
|
||||
float fbmCloud2(vec2 inCoord, float minimum){
|
||||
float value = 0.0;
|
||||
float scale = (NEBULA_AMOUNT + 0.1) * 0.25 + 0.35;
|
||||
|
||||
for (int i = 0; i < OCTAVE; i++){
|
||||
value += perlin(inCoord) * scale;
|
||||
inCoord *= 2.0;
|
||||
scale *= 0.5;
|
||||
}
|
||||
|
||||
return (smoothstep(minimum, 1.0, value) - minimum) / (1.0 - minimum);
|
||||
}
|
||||
|
||||
vec2 warpCoords(vec2 coord, float warpAmount) {
|
||||
float angle = perlin(coord * 0.5) * 6.28318 * warpAmount;
|
||||
float strength = perlin(coord * 0.7 + 0.5) * warpAmount;
|
||||
vec2 offset = vec2(cos(angle), sin(angle)) * strength;
|
||||
return coord + offset;
|
||||
}
|
||||
|
||||
vec3 GetNightNebula(vec3 viewPos, float VdotU, float VdotS) {
|
||||
float VdotUFactor = max0(VdotU);
|
||||
float starsAroundSun = 1.0;
|
||||
#ifdef CELESTIAL_BOTH_HEMISPHERES
|
||||
VdotUFactor = VdotU;
|
||||
#ifdef SUN_MOON_HORIZON
|
||||
starsAroundSun = max0(sign(VdotU));
|
||||
#endif
|
||||
#endif
|
||||
float originalVdotUFactor = VdotUFactor;
|
||||
float horizonPower = NEBULA_HORIZON_STRENGTH * 0.05 + 0.5;
|
||||
|
||||
#if NEBULA_HORIZON_STRENGTH < 10
|
||||
VdotUFactor = pow(VdotUFactor, horizonPower);
|
||||
#endif
|
||||
|
||||
float nebulaFactor = pow2(VdotUFactor * min1(nightFactor * 2.0));
|
||||
|
||||
#if NEBULA_HORIZON_STRENGTH < 10
|
||||
float brightnessCompensation = 1.0 - (1.0 - horizonPower) * 0.5 * max0(originalVdotUFactor);
|
||||
nebulaFactor *= brightnessCompensation;
|
||||
#endif
|
||||
|
||||
#ifdef CLEAR_SKY_WHEN_RAINING
|
||||
nebulaFactor *= min1(invRainFactorDynamic + 0.4);
|
||||
#else
|
||||
nebulaFactor *= invRainFactorDynamic;
|
||||
#endif
|
||||
|
||||
nebulaFactor -= maxBlindnessDarkness;
|
||||
|
||||
#if NEBULA_MOON_CONDITION == 1
|
||||
if (moonPhase != 4) return vec3(0.0);
|
||||
#elif NEBULA_MOON_CONDITION == 2
|
||||
if (moonPhase != 0) return vec3(0.0);
|
||||
#elif NEBULA_MOON_CONDITION == 3
|
||||
if (moonPhase == 0 || moonPhase == 4) return vec3(0.0);
|
||||
#elif NEBULA_MOON_CONDITION == 4
|
||||
nebulaFactor *= step(0.5, hash11(float(worldDay) + float(moonPhase) * 37.0));
|
||||
#elif NEBULA_MOON_CONDITION == 5
|
||||
nebulaFactor *= clamp01(max(moonPhase, 1) % 4);
|
||||
#endif
|
||||
|
||||
if (nebulaFactor < 0.001) return vec3(0.0);
|
||||
|
||||
vec2 UV = GetStarCoord(viewPos, 0.75);
|
||||
float TIME = syncedTimeDynamic * 0.003 + 15.0;
|
||||
float timescaled = TIME * timescale;
|
||||
|
||||
float sinTime = sinM(0.07 * timescaled);
|
||||
float cosTime06 = cosM(0.06 * timescaled);
|
||||
float cosTime07 = cosM(0.07 * timescaled);
|
||||
|
||||
float tide = 0.05 * sinM(TIME);
|
||||
float tide2 = 0.06 * cosM(0.3 * TIME);
|
||||
|
||||
vec4 nebulaTexture = vec4(vec3(0.0), 0.5 + 0.2 * sinM(0.23 * TIME + UV.x - UV.y));
|
||||
|
||||
#if PIXELATED_NEBULA > 0
|
||||
float pixelFactor = PIXELATED_NEBULA * 2.0;
|
||||
vec2 baseUV = floor(UV * pixelFactor) / pixelFactor;
|
||||
#else
|
||||
vec2 baseUV = UV;
|
||||
#endif
|
||||
|
||||
vec2 scaledUV = baseUV * zoomScale;
|
||||
vec2 cloudUV2 = vec2(scaledUV.x + 0.03 * timescaled * sinTime, scaledUV.y + 0.03 * timescaled * cosTime06);
|
||||
vec2 cloudUV3 = vec2(scaledUV.x + 0.027 * timescaled * sinTime, scaledUV.y + 0.025 * timescaled * cosTime06);
|
||||
vec2 cloudUV4 = vec2(scaledUV.x + 0.021 * timescaled * sinTime, scaledUV.y + 0.021 * timescaled * cosTime07);
|
||||
|
||||
#if NEBULA_PATTERN_WARP > 0
|
||||
cloudUV2 = warpCoords(cloudUV2, NEBULA_PATTERN_WARP * 0.1);
|
||||
cloudUV3 = warpCoords(cloudUV3, NEBULA_PATTERN_WARP * 0.1);
|
||||
cloudUV4 = warpCoords(cloudUV4, NEBULA_PATTERN_WARP * 0.1);
|
||||
#endif
|
||||
|
||||
nebulaTexture += fbmCloud2(cloudUV3, 0.24 + tide) * CLOUD1_COL;
|
||||
nebulaTexture += fbmCloud(cloudUV2 * 0.9, 0.33 - tide) * CLOUD2_COL;
|
||||
nebulaTexture = mix(nebulaTexture, CLOUD3_COL, fbmCloud(vec2(0.9 * cloudUV4.x, 0.9 * cloudUV4.y), 0.25 + tide2));
|
||||
|
||||
nebulaFactor *= 1.0 - pow2(pow2(pow2(abs(VdotS)))) * starsAroundSun;
|
||||
nebulaTexture.a *= min1(pow2(pow2(nebulaTexture.a))) * nebulaFactor;
|
||||
|
||||
float starFactor = 1024.0;
|
||||
UV /= STAR_SIZE * (0.75 + 0.25 * NEBULA_STAR_SIZE);
|
||||
vec2 starCoord = floor(UV * 0.25 * starFactor) / starFactor;
|
||||
vec2 fractPart = fract(UV * 0.25 * starFactor);
|
||||
|
||||
float starAmount = (2.0 - NEBULA_STAR_AMOUNT) * 0.1;
|
||||
float starIntensity = GetStarNoise(starCoord) * GetStarNoise(starCoord + 0.1) - (starAmount + 0.5);
|
||||
starIntensity *= getStarEdgeFactor(fractPart, STAR_ROUNDNESS_OW / 10.0, STAR_SOFTNESS_OW);
|
||||
|
||||
#if TWINKLING_STARS > 0
|
||||
starIntensity *= getTwinklingStars(starCoord * 4, float(TWINKLING_STARS));
|
||||
#endif
|
||||
|
||||
float starGlow = pow2(clamp(starIntensity, 0.0, 0.3 + starAmount)) * starBrightness * NEBULA_STAR_BRIGHTNESS;
|
||||
|
||||
#ifdef NEBULA_ONLY_STARS
|
||||
nebulaTexture.rgb = vec3(10.0 * starGlow);
|
||||
#else
|
||||
nebulaTexture.rgb *= 1.5 + 10.0 * starGlow;
|
||||
#endif
|
||||
|
||||
#if NIGHT_NEBULA_I != 100
|
||||
#define NIGHT_NEBULA_IM NIGHT_NEBULA_I * 0.01
|
||||
nebulaTexture.a *= NIGHT_NEBULA_IM;
|
||||
#endif
|
||||
|
||||
#if NEBULA_SATURATION != 10
|
||||
nebulaTexture.rgb = rgb2hsv(nebulaTexture.rgb);
|
||||
nebulaTexture.g *= NEBULA_SATURATION * 0.1;
|
||||
nebulaTexture.rgb = hsv2rgb(nebulaTexture.rgb);
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
nebulaTexture.rgb *= sqrtAtmColorMult; // C72380KD - Reduced atmColorMult impact on some things
|
||||
#endif
|
||||
|
||||
return max(nebulaTexture.rgb * nebulaTexture.a, vec3(0.0));
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
|
||||
vec3 beamCol = normalize(ColorBeam) * 3.0 * (2.5 - 1.0 * vlFactor) * OVERWORLD_BEAMS_INTENSITY;
|
||||
|
||||
vec2 wind = vec2(frameTimeCounter * 0.0019);
|
||||
|
||||
float BeamNoise(vec2 planeCoord, vec2 wind) {
|
||||
float noise = texture2DLod(noisetex, planeCoord * 0.175 - wind, 0.0).b * 0.5;
|
||||
noise+= texture2DLod(noisetex, planeCoord * 0.04375 + wind * 0.5, 0.0).b * 2.0;
|
||||
noise+= texture2DLod(noisetex, planeCoord * 0.27 - wind, 0.0).b * 0.5;
|
||||
|
||||
return noise / 3.0;
|
||||
}
|
||||
|
||||
vec4 DrawOverworldBeams(vec3 playerPos, vec3 nViewPos, float scale) {
|
||||
float visibility = 1.0 - sunVisibility - maxBlindnessDarkness;
|
||||
#if OVERWORLD_BEAMS_CONDITION == 0
|
||||
visibility -= moonPhase;
|
||||
#endif
|
||||
if (visibility > 0.0) {
|
||||
float beamPowAfterAltitude = 1.35;
|
||||
float lPlayerPosXZ = length(playerPos.xz);
|
||||
|
||||
vec3 localBeamCol = beamCol;
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
localBeamCol = getAuroraAmbientColor(localBeamCol, nViewPos, 1.0, AURORA_CLOUD_INFLUENCE_INTENSITY, 0.85) * OVERWORLD_BEAMS_INTENSITY;
|
||||
#endif
|
||||
|
||||
vec2 planeCoordRaw = playerPos.xz + cameraPosition.xz;
|
||||
vec2 planeCoord = planeCoordRaw * 0.0014 * scale;
|
||||
|
||||
float noise = BeamNoise(planeCoord, wind);
|
||||
float fireNoise = texture2DLod(noisetex, abs(planeCoord * 0.1) - wind, 0.0).b;
|
||||
|
||||
float uncenteredDistance = 1.3 * (250.0 + 0.5 * lPlayerPosXZ);
|
||||
float altitude = playerPos.y + cameraPosition.y;
|
||||
float signedAltitude = altitude - oceanAltitude;
|
||||
float altitudeDis = abs(signedAltitude);
|
||||
float altitudeFactor = 0.5 * smoothstep(uncenteredDistance, 0.0, altitudeDis)
|
||||
+ 0.5 * smoothstep(4.0 * uncenteredDistance, 0.0, altitudeDis);
|
||||
|
||||
noise = pow2(noise) * 0.7 + 0.3 * fireNoise;
|
||||
noise *= pow(altitudeFactor, 3.0);
|
||||
noise = pow(noise, beamPowAfterAltitude);
|
||||
|
||||
vec3 beams = noise * localBeamCol * (1.0 + smoothstep(0.0, 128.0, lPlayerPosXZ));
|
||||
|
||||
if(any(isnan(beams))) beams = vec3(0.0);
|
||||
|
||||
float nearPlayerFactor = 1.0 - smoothstep(0.0, 256.0, lPlayerPosXZ);
|
||||
float beamAlpha = clamp01(noise * mix(1.0, 3.67, nearPlayerFactor));
|
||||
|
||||
beams.rgb *= pow3(beamAlpha) * 10.0;
|
||||
beams.rgb *= sqrt(beams.rgb);
|
||||
beams.rgb = sqrt(beams.rgb);
|
||||
|
||||
#if defined VOXY || defined DISTANT_HORIZONS
|
||||
beams.rgb *= 4.5;
|
||||
#endif
|
||||
|
||||
return vec4(beams, beamAlpha * visibility);
|
||||
}
|
||||
return vec4(0.0);
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#define RAINBOW_DIAMETER 1.00 //[0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 2.30 2.35 2.40 2.45 2.50 2.55 2.60 2.65 2.70 2.75 2.80 2.85 2.90 2.95 3.00 3.05 3.10 3.15 3.20 3.25 3.30 3.35 3.40 3.45 3.50 3.55 3.60 3.65 3.70 3.75 3.80 3.85 3.90 3.95 4.00 4.25 4.50 4.75 5.00 5.25 5.50 5.75 6.00 6.25 6.50 6.75 7.00 7.50 8.00]
|
||||
|
||||
vec3 GetRainbow(vec3 translucentMult, vec3 nViewPos, float z0, float z1, float lViewPos, float lViewPos1, float VdotL, float VdotU, float dither) {
|
||||
vec3 rainbow = vec3(0.0);
|
||||
|
||||
float rainbowTime = min1(max0(SdotU - 0.1) / 0.15);
|
||||
rainbowTime = clamp(rainbowTime - pow2(pow2(pow2(noonFactor))) * 8.0, 0.0, 0.85);
|
||||
#if RAINBOWS == 1 // After Rain
|
||||
rainbowTime *= sqrt2(max0(wetness - 0.333) * 1.5) * invRainFactorDynamic * inRainy;
|
||||
#endif
|
||||
|
||||
if (rainbowTime > 0.001) {
|
||||
float rainbowLength = far * 0.9;
|
||||
if (z1 == 1.0) lViewPos1 = rainbowLength;
|
||||
|
||||
float cloudLinearDepth = texelFetch(colortex5, texelCoord, 0).a;
|
||||
float cloudDisMult = pow2(cloudLinearDepth + OSIEBCA * dither);
|
||||
lViewPos1 *= cloudDisMult;
|
||||
|
||||
#if RAINBOW_STYLE == 1
|
||||
float pixelScale = 45.0;
|
||||
vec3 shadowDir = mat3(shadowModelView) * mat3(gbufferModelViewInverse) * nViewPos;
|
||||
|
||||
shadowDir.z += 0.0065 * (dither - 0.5); // Blurs the pixelation
|
||||
|
||||
shadowDir /= abs(shadowDir.z); // Corrects distortion
|
||||
shadowDir.xy = floor(shadowDir.xy * pixelScale) / pixelScale;
|
||||
|
||||
VdotL = shadowDir.z * inversesqrt(dot(shadowDir, shadowDir));
|
||||
#endif
|
||||
|
||||
float rainbowCoord = clamp01(1.0 - (VdotL + 0.75) / (0.0625 * RAINBOW_DIAMETER));
|
||||
float rainbowFactor = rainbowCoord * (1.0 - rainbowCoord);
|
||||
rainbowFactor = pow2(pow2(rainbowFactor * 3.7));
|
||||
rainbowFactor *= pow2(min1(lViewPos1 / rainbowLength));
|
||||
rainbowFactor *= rainbowTime;
|
||||
rainbowFactor *= 1.0 - GetCaveFactor();
|
||||
|
||||
if (rainbowFactor > 0.0) {
|
||||
float rainbowCoordM = pow(rainbowCoord, 1.4 + max(rainbowCoord - 0.5, 0.0) * 1.6);
|
||||
rainbowCoordM = smoothstep(0.0, 1.0, rainbowCoordM) * 0.85;
|
||||
rainbowCoordM += (dither - 0.5) * 0.1;
|
||||
|
||||
rainbow += clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbowCoordM += 0.1;
|
||||
rainbow += clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbowCoordM -= 0.2;
|
||||
rainbow += clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbow /= 3.0;
|
||||
|
||||
rainbow.r += pow2(max(rainbowCoord - 0.5, 0.0)) * (max(1.0 - rainbowCoord, 0.0)) * 26.0;
|
||||
rainbow = pow(rainbow, vec3(2.2)) * vec3(0.25, 0.075, 0.25) * 3.0;
|
||||
|
||||
if (z1 > z0 && lViewPos < rainbowLength)
|
||||
rainbow *= mix(translucentMult, vec3(1.0), lViewPos / rainbowLength);
|
||||
|
||||
if (isEyeInWater != 0) rainbow *= sqrt1(max0(VdotU));
|
||||
|
||||
rainbow *= rainbowFactor;
|
||||
}
|
||||
}
|
||||
|
||||
return rainbow;
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// Shooting stars implementation based on https://www.shadertoy.com/view/ttVXDy and also based on https://github.com/OUdefie17/Photon-GAMS
|
||||
|
||||
#define SHOOTING_STARS_SIZE 0.50 //[0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75]
|
||||
#define SHOOTING_STARS_SPEED 8.0 //[4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0]
|
||||
#define SHOOTING_STARS_CHANCE 0.5 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define SHOOTING_STARS_COUNT 4 //[1 2 3 4 5 6 7 8 9 10]
|
||||
#define SHOOTING_STARS_LINE_THICKNESS 0.60 //[0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00]
|
||||
#define SHOOTING_STARS_TRAIL_LENGTH 0.60 //[0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85]
|
||||
|
||||
// Calculate distance from point p to line segment from a to b
|
||||
float DistLine(vec2 p, vec2 a, vec2 b) {
|
||||
vec2 pa = p - a;
|
||||
vec2 ba = b - a;
|
||||
float t = clamp01(dot(pa, ba) / dot(ba, ba));
|
||||
return length(pa - ba * t);
|
||||
}
|
||||
|
||||
// Draw a line with smooth edges
|
||||
float DrawLine(vec2 p, vec2 a, vec2 b) {
|
||||
float d = DistLine(p, a, b);
|
||||
float m = smoothstep(SHOOTING_STARS_LINE_THICKNESS * 0.01, 0.00001, d);
|
||||
float d2 = length(a - b);
|
||||
m *= smoothstep(1.0, 0.5, d2) + smoothstep(0.04, 0.03, abs(d2 - 0.75));
|
||||
return m;
|
||||
}
|
||||
|
||||
// Generate a single shooting star
|
||||
float ShootingStar(vec2 uv, vec2 startPos, vec2 direction) {
|
||||
vec2 id = floor(uv * 0.5);
|
||||
float h = hash12(id);
|
||||
|
||||
float newMoonVisibility = 1.0 - abs(moonPhase - 4) / 4.0;
|
||||
float moonPhaseFactor = mix(0.8, 1.5, newMoonVisibility);
|
||||
|
||||
if (h >= pow1_5(SHOOTING_STARS_CHANCE * 0.065) * moonPhaseFactor) return 0.0;
|
||||
|
||||
vec2 gv = fract(uv * 0.5) * 2.0 - 1.0;
|
||||
float line = DrawLine(gv, startPos, startPos + direction * 0.9);
|
||||
|
||||
vec2 toStart = gv - startPos;
|
||||
float alongTrail = dot(toStart, direction);
|
||||
float trail = smoothstep(SHOOTING_STARS_TRAIL_LENGTH, -0.1, alongTrail);
|
||||
|
||||
float headBrightness = 1.0 + 3.0 / (1.0 + pow2((alongTrail - 1.0) * 8.0));
|
||||
|
||||
return line * trail * headBrightness;
|
||||
}
|
||||
|
||||
vec3 GetShootingStars(vec2 starCoord, float VdotU, float VdotS) {
|
||||
float starsAroundSun = 1.0;
|
||||
#ifdef CELESTIAL_BOTH_HEMISPHERES
|
||||
float starBelowHorizonBrightness = 1.0;
|
||||
float horizonFactor = exp(-pow(VdotU / 0.1, 2.0));
|
||||
#ifdef SUN_MOON_HORIZON
|
||||
starsAroundSun = max0(sign(VdotU));
|
||||
#endif
|
||||
#else
|
||||
if (VdotU < 0.0) return vec3(0.0);
|
||||
float starBelowHorizonBrightness = min1(VdotU * 3.0);
|
||||
float horizonFactor = 0.0;
|
||||
#endif
|
||||
|
||||
float visibility = max0(1.0 - 1.0 / (1.0 + abs(VdotS) * 1000.0) * starsAroundSun) * starBelowHorizonBrightness - horizonFactor * 0.5;
|
||||
|
||||
#ifndef DAYLIGHT_STARS
|
||||
visibility *= pow2(pow2(invNoonFactor2)) * (1.0 - 0.5 * sunVisibility);
|
||||
#endif
|
||||
|
||||
#ifdef CLEAR_SKY_WHEN_RAINING
|
||||
visibility *= min1(invRainFactorDynamic + 0.4);
|
||||
#else
|
||||
visibility *= invRainFactorDynamic;
|
||||
#endif
|
||||
|
||||
if (visibility <= 0.01) return vec3(0.0);
|
||||
|
||||
vec2 uv = starCoord * 6.0 * (1.0 - SHOOTING_STARS_SIZE);
|
||||
float speed = frameTimeCounter * SHOOTING_STARS_SPEED;
|
||||
|
||||
vec2 startPositions[10] = vec2[](
|
||||
vec2(-0.4, 0.3),
|
||||
vec2(0.2, 0.4),
|
||||
vec2(-0.1, -0.3),
|
||||
vec2(0.3, -0.2),
|
||||
vec2(-0.3, 0.1),
|
||||
vec2(0.5, 0.2),
|
||||
vec2(-0.5, -0.1),
|
||||
vec2(0.1, 0.5),
|
||||
vec2(-0.2, -0.4),
|
||||
vec2(0.4, -0.3)
|
||||
);
|
||||
|
||||
vec2 directions[10] = vec2[](
|
||||
vec2(0.7071, 0.7071),
|
||||
vec2(0.7071, -0.7071),
|
||||
vec2(-1.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.5299, 0.8480),
|
||||
vec2(-0.6000, 0.8000),
|
||||
vec2(0.9134, -0.4067),
|
||||
vec2(-0.8000, -0.6000),
|
||||
vec2(0.3015, 0.9535),
|
||||
vec2(-0.2000, -0.9798)
|
||||
);
|
||||
|
||||
float stars = 0.0;
|
||||
int dayIndex = int(worldDay) % 10;
|
||||
vec2 todayDirection = directions[dayIndex];
|
||||
|
||||
for (int i = 0; i < SHOOTING_STARS_COUNT; i++) {
|
||||
float offsetAngle = (hash12(vec2(i, worldDay)) - 0.5) * 0.66;
|
||||
vec2 starDirection = rotate(offsetAngle) * todayDirection;
|
||||
|
||||
vec2 offsetUV = uv + starDirection * speed * (0.8 + 0.04 * float(i));
|
||||
stars += ShootingStar(offsetUV, startPositions[i], starDirection);
|
||||
}
|
||||
|
||||
vec3 shootingStarColor = vec3(0.38, 0.4, 0.5) * 2.0 * starBrightness;
|
||||
float intensity = min(stars * visibility * 10.0, 1.0);
|
||||
return shootingStarColor * intensity;
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
#ifndef INCLUDE_SKY
|
||||
#define INCLUDE_SKY
|
||||
|
||||
#define SUN_GLARE_AMOUNT 10 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
|
||||
#define MOON_GLARE_AMOUNT 10 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
|
||||
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
#include "/lib/colors/skyColors.glsl"
|
||||
|
||||
#ifdef CAVE_FOG
|
||||
#include "/lib/atmospherics/fog/caveFactor.glsl"
|
||||
#endif
|
||||
|
||||
vec3 getCustomSkyColor(out bool isCustomSky) {
|
||||
isCustomSky = false;
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
vec4 skyColor = texelFetch(colortex13, texelCoord, 0);
|
||||
int hasCustomSky = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
|
||||
if (hasCustomSky == 238 || skyColor.rgb != vec3(0.0)) {
|
||||
isCustomSky = true;
|
||||
return skyColor.rgb;
|
||||
}
|
||||
#endif
|
||||
return vec3(0.0);
|
||||
}
|
||||
|
||||
vec3 GetSky(float VdotU, float VdotS, float dither, bool doGlare, bool doGround, out bool isCustomSky, bool skipCustomSky) {
|
||||
isCustomSky = false;
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
vec3 customSkyColor = getCustomSkyColor(isCustomSky);
|
||||
if (isCustomSky && !skipCustomSky) {
|
||||
return customSkyColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Prepare variables
|
||||
float nightFactorSqrt2 = sqrt2(nightFactor);
|
||||
float nightFactorM = sqrt2(nightFactorSqrt2) * 0.4;
|
||||
float VdotSM1 = pow2(max(VdotS, 0.0));
|
||||
float VdotSM2 = pow2(VdotSM1);
|
||||
float VdotSM3 = pow2(pow2(max(-VdotS, 0.0)));
|
||||
float VdotSML = sunVisibility > 0.5 ? VdotS : -VdotS;
|
||||
|
||||
float VdotUmax0 = max(VdotU, 0.0);
|
||||
float VdotUmax0M = 1.0 - pow2(VdotUmax0);
|
||||
|
||||
// Prepare colors
|
||||
float aroundMoonSkyFactor = 1.0;
|
||||
#ifndef EUPHORIA_PATCHES_IS_SPACE_MOD_INSTALLED
|
||||
aroundMoonSkyFactor = 1.5 - 0.5 * nightFactorSqrt2 + nightFactorM * VdotSM3 * 1.5;
|
||||
#endif
|
||||
vec3 upColor = mix(nightUpSkyColor * aroundMoonSkyFactor, dayUpSkyColor, sunFactor);
|
||||
vec3 middleColor = mix(nightMiddleSkyColor * (3.0 - 2.0 * nightFactorSqrt2), dayMiddleSkyColor * (1.0 + VdotSM2 * 0.3), sunFactor);
|
||||
vec3 downColor = mix(nightDownSkyColor, dayDownSkyColor, (sunFactor + sunVisibility) * 0.5);
|
||||
|
||||
// Mix the colors
|
||||
// Set sky gradient
|
||||
float scatteredGroundMixerMult = 1.0;
|
||||
float VdotUM1 = pow2(1.0 - VdotUmax0);
|
||||
VdotUM1 = pow(VdotUM1, (1.0 - VdotSM2 * 0.4) * (1.15 - 0.15 * rainFactor2));
|
||||
VdotUM1 = mix(VdotUM1, 1.0, rainFactor2 * 0.15);
|
||||
vec3 finalSky = mix(upColor, middleColor, VdotUM1);
|
||||
|
||||
// Add sunset color
|
||||
float VdotUM2 = pow2(1.0 - abs(VdotU));
|
||||
VdotUM2 = VdotUM2 * VdotUM2 * (3.0 - 2.0 * VdotUM2);
|
||||
VdotUM2 *= (0.7 - nightFactorM + VdotSM1 * (0.3 + nightFactorM)) * invNoonFactor * sunFactor;
|
||||
finalSky = mix(finalSky, sunsetDownSkyColorP * (1.0 + VdotSM1 * 0.3), VdotUM2 * invRainFactor);
|
||||
|
||||
// Add sky ground with fake light scattering
|
||||
float VdotUM3 = min(max0(-VdotU + 0.08) / 0.35, 1.0);
|
||||
VdotUM3 = smoothstep1(VdotUM3);
|
||||
vec3 scatteredGroundMixer = vec3(VdotUM3 * VdotUM3, sqrt1(VdotUM3), sqrt3(VdotUM3));
|
||||
scatteredGroundMixer = mix(vec3(VdotUM3), scatteredGroundMixer, 0.75 - 0.5 * rainFactor);
|
||||
finalSky = mix(finalSky, downColor, scatteredGroundMixer * scatteredGroundMixerMult);
|
||||
//
|
||||
|
||||
// Sky Ground
|
||||
if (doGround)
|
||||
finalSky *= smoothstep1(pow2(1.0 + min(VdotU, 0.0)));
|
||||
|
||||
// Apply Underwater Fog
|
||||
if (isEyeInWater == 1)
|
||||
finalSky = mix(finalSky * 3.0, waterFogColor, VdotUmax0M);
|
||||
|
||||
// Sun/Moon Glare
|
||||
#if (SUN_GLARE_AMOUNT > 0 || MOON_GLARE_AMOUNT > 0) && !defined EUPHORIA_PATCHES_IS_SPACE_MOD_INSTALLED
|
||||
if (doGlare) {
|
||||
if (0.0 < VdotSML) {
|
||||
float glareScatter = 3.0 * (2.0 - clamp01(VdotS * 1000.0));
|
||||
#ifndef SUN_MOON_DURING_RAIN
|
||||
glareScatter *= 1.0 - 0.75 * rainFactor2;
|
||||
#endif
|
||||
float VdotSM4 = pow(abs(VdotS), glareScatter);
|
||||
|
||||
float visfactor = 0.075;
|
||||
float glare = visfactor / (1.0 - (1.0 - visfactor) * VdotSM4) - visfactor;
|
||||
glare *= 0.7;
|
||||
|
||||
float glareWaterFactor = isEyeInWater * sunVisibility;
|
||||
vec3 glareColor = mix(vec3(0.38, 0.4, 0.5) * 0.3, vec3(1.5, 0.7, 0.3) + vec3(0.0, 0.5, 0.5) * noonFactor, sunVisibility);
|
||||
#if BLOOD_MOON > 0
|
||||
glareColor = mix(glareColor, vec3(0.6314, 0.0431, 0.0431), getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
glareColor = glareColor + glareWaterFactor * vec3(7.0);
|
||||
|
||||
#ifdef SUN_MOON_DURING_RAIN
|
||||
glare *= 1.0 - 0.6 * rainFactor;
|
||||
#else
|
||||
glare *= 1.0 - 0.8 * rainFactor;
|
||||
#endif
|
||||
#if RAIN_STYLE == 1
|
||||
float glareDesaturateFactor = 0.5 * rainFactor;
|
||||
#elif RAIN_STYLE == 2
|
||||
float glareDesaturateFactor = rainFactor;
|
||||
#endif
|
||||
glareColor = mix(glareColor, vec3(GetLuminance(glareColor)), glareDesaturateFactor);
|
||||
|
||||
glare *= mix(MOON_GLARE_AMOUNT * 0.1, SUN_GLARE_AMOUNT * 0.1, sunVisibility);
|
||||
|
||||
finalSky += glare * shadowTime * glareColor;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CAVE_FOG
|
||||
// Apply Cave Fog
|
||||
finalSky = mix(finalSky, caveFogColor, GetCaveFactor() * VdotUmax0M);
|
||||
#endif
|
||||
|
||||
// Dither to fix banding
|
||||
finalSky = max(finalSky + (dither - 0.5) / 128.0, vec3(0.0));
|
||||
|
||||
#if RETRO_LOOK == 1
|
||||
finalSky = vec3(0.0);
|
||||
#elif RETRO_LOOK ==2
|
||||
finalSky = mix(finalSky, vec3(0.0), nightVision);
|
||||
#endif
|
||||
|
||||
return finalSky;
|
||||
}
|
||||
|
||||
vec3 GetLowQualitySky(float VdotU, float VdotS, float dither, bool doGlare, bool doGround) {
|
||||
// Prepare variables
|
||||
float VdotUmax0 = max(VdotU, 0.0);
|
||||
float VdotUmax0M = 1.0 - pow2(VdotUmax0);
|
||||
|
||||
// Prepare colors
|
||||
vec3 upColor = mix(nightUpSkyColor, dayUpSkyColor, sunFactor);
|
||||
vec3 middleColor = mix(nightMiddleSkyColor, dayMiddleSkyColor, sunFactor);
|
||||
|
||||
// Mix the colors
|
||||
// Set sky gradient
|
||||
float VdotUM1 = pow2(1.0 - VdotUmax0);
|
||||
VdotUM1 = mix(VdotUM1, 1.0, rainFactor2 * 0.2);
|
||||
vec3 finalSky = mix(upColor, middleColor, VdotUM1);
|
||||
|
||||
// Add sunset color
|
||||
float VdotUM2 = pow2(1.0 - abs(VdotU));
|
||||
VdotUM2 *= invNoonFactor * sunFactor * (0.8 + 0.2 * VdotS);
|
||||
finalSky = mix(finalSky, sunsetDownSkyColorP * (shadowTime * 0.6 + 0.2), VdotUM2 * invRainFactor);
|
||||
//
|
||||
|
||||
// Sky Ground
|
||||
finalSky *= pow2(pow2(1.0 + min(VdotU, 0.0)));
|
||||
|
||||
// Apply Underwater Fog
|
||||
if (isEyeInWater == 1)
|
||||
finalSky = mix(finalSky, waterFogColor, VdotUmax0M);
|
||||
|
||||
// Sun/Moon Glare
|
||||
finalSky *= 1.0 + mix(nightFactor, 0.5 + 0.7 * noonFactor, VdotS * 0.5 + 0.5) * pow2(pow2(pow2(VdotS)));
|
||||
|
||||
#ifdef CAVE_FOG
|
||||
// Apply Cave Fog
|
||||
finalSky = mix(finalSky, caveFogColor, GetCaveFactor() * VdotUmax0M);
|
||||
#endif
|
||||
|
||||
#if RETRO_LOOK == 1 || RETRO_LOOK == 2
|
||||
finalSky = vec3(0.0);
|
||||
#endif
|
||||
|
||||
return finalSky;
|
||||
}
|
||||
|
||||
vec3 GetSkyReflected(float VdotU, float VdotS, float dither, bool doGlare, bool doGround, out bool isCustomSky) {
|
||||
vec3 regularSkyColor = GetSky(VdotU, VdotS, dither, doGlare, doGround, isCustomSky, true);
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
vec3 customSkyColor = getCustomSkyColor(isCustomSky);
|
||||
if (isCustomSky) {
|
||||
return mix(regularSkyColor, customSkyColor, 0.33);
|
||||
}
|
||||
#endif
|
||||
return regularSkyColor;
|
||||
}
|
||||
|
||||
vec3 GetLowQualitySkyReflected(float VdotU, float VdotS, float dither, bool doGlare, bool doGround, out bool isCustomSky) {
|
||||
vec3 regularSkyColor = GetLowQualitySky(VdotU, VdotS, dither, doGlare, doGround);
|
||||
isCustomSky = false;
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
vec3 customSkyColor = getCustomSkyColor(isCustomSky);
|
||||
if (isCustomSky) {
|
||||
return mix(regularSkyColor, customSkyColor, 0.33);
|
||||
}
|
||||
#endif
|
||||
return regularSkyColor;
|
||||
}
|
||||
|
||||
#endif //INCLUDE_SKY
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
#if !defined STARS_FILE_INCLUDED
|
||||
#define STARS_FILE_INCLUDED
|
||||
#include "/lib/colors/skyColors.glsl"
|
||||
#include "/lib/shaderSettings/stars.glsl"
|
||||
|
||||
#ifdef CELESTIAL_BOTH_HEMISPHERES
|
||||
vec2 GetStarCoordBothHemispheres(vec3 viewPos, float sphereness) {
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
|
||||
float ySign = sign(wpos.y);
|
||||
float yMagnitude = abs(wpos.y);
|
||||
|
||||
vec3 adjustedWpos = vec3(wpos.x, yMagnitude, wpos.z);
|
||||
vec3 starCoord = adjustedWpos / (adjustedWpos.y + length(adjustedWpos.xz) * sphereness);
|
||||
|
||||
if (ySign >= 0.0) {
|
||||
starCoord.x += 0.006 * syncedTime; // Top hemisphere (original direction)
|
||||
} else {
|
||||
starCoord.x = starCoord.x - 0.006 * syncedTime + 0.37; // Bottom hemisphere with offset
|
||||
starCoord.z += 0.21;
|
||||
}
|
||||
|
||||
return starCoord.xz;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec2 GetStarCoordUpperHemisphere(vec3 viewPos, float sphereness) {
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
|
||||
vec3 starCoord = wpos / (wpos.y + length(wpos.xz) * sphereness);
|
||||
starCoord.x += 0.006 * syncedTime;
|
||||
|
||||
return starCoord.xz;
|
||||
}
|
||||
|
||||
vec2 GetStarCoord(vec3 viewPos, float sphereness) {
|
||||
#ifdef CELESTIAL_BOTH_HEMISPHERES
|
||||
return GetStarCoordBothHemispheres(viewPos, sphereness);
|
||||
#else
|
||||
return GetStarCoordUpperHemisphere(viewPos, sphereness);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 GetStars(vec2 starCoord, float VdotU, float VdotS, float sizeMult, float starAmount) {
|
||||
#if NIGHT_STAR_AMOUNT == 0 || (defined EUPHORIA_PATCHES_IS_SPYGLASS_ASTRONOMY_INSTALLED && defined GBUFFERS_SKYBASIC)
|
||||
return vec3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
float starsAroundSun = 1.0;
|
||||
#ifdef CELESTIAL_BOTH_HEMISPHERES
|
||||
float starBelowHorizonBrightness = 1.0;
|
||||
float horizonFactor = exp(-pow(VdotU / 0.1, 2.0));
|
||||
#ifdef SUN_MOON_HORIZON
|
||||
starsAroundSun = max0(sign(VdotU));
|
||||
#endif
|
||||
#else
|
||||
if (VdotU < 0.0) return vec3(0.0);
|
||||
float starBelowHorizonBrightness = min1(VdotU * 3.0);
|
||||
float horizonFactor = 0.0;
|
||||
#endif
|
||||
|
||||
starCoord *= 0.2 / (STAR_SIZE * sizeMult);
|
||||
|
||||
const float starFactor = 1024.0;
|
||||
|
||||
vec2 fractPart = fract(starCoord * starFactor);
|
||||
|
||||
starCoord = floor(starCoord * starFactor) / starFactor;
|
||||
|
||||
float star = GetStarNoise(starCoord.xy) * GetStarNoise(starCoord.xy+0.1) * GetStarNoise(starCoord.xy+0.23);
|
||||
|
||||
#if NIGHT_STAR_AMOUNT == 1
|
||||
star -= 0.82;
|
||||
star *= 2.0;
|
||||
#elif NIGHT_STAR_AMOUNT == 2
|
||||
star -= 0.7;
|
||||
#elif NIGHT_STAR_AMOUNT == 3
|
||||
star -= 0.62;
|
||||
star *= 0.75;
|
||||
#elif NIGHT_STAR_AMOUNT == 4
|
||||
star -= 0.52;
|
||||
star *= 0.55;
|
||||
#endif
|
||||
|
||||
star = max0(star - starAmount * 0.1);
|
||||
star *= getStarEdgeFactor(fractPart, STAR_ROUNDNESS_OW / 10.0, STAR_SOFTNESS_OW);
|
||||
star *= star;
|
||||
|
||||
star *= max0(1.0 - pow(abs(VdotS) * 1.002, 100.0) * starsAroundSun) * starBelowHorizonBrightness - horizonFactor * 0.5;
|
||||
#ifndef DAYLIGHT_STARS
|
||||
star *= pow2(pow2(invNoonFactor2)) * (1.0 - 0.5 * sunVisibility);
|
||||
#endif
|
||||
|
||||
#ifdef CLEAR_SKY_WHEN_RAINING
|
||||
star *= min1(invRainFactorDynamic + 0.4);
|
||||
#else
|
||||
star *= invRainFactorDynamic;
|
||||
#endif
|
||||
|
||||
vec3 starColor = GetStarColor(starCoord,
|
||||
vec3(0.38, 0.4, 0.5),
|
||||
vec3(STAR_COLOR_1_OW_R, STAR_COLOR_1_OW_G, STAR_COLOR_1_OW_B),
|
||||
vec3(STAR_COLOR_2_OW_R, STAR_COLOR_2_OW_G, STAR_COLOR_2_OW_B),
|
||||
vec3(STAR_COLOR_3_OW_R, STAR_COLOR_3_OW_G, STAR_COLOR_3_OW_B),
|
||||
float(STAR_COLOR_VARIATION_OW));
|
||||
|
||||
vec3 stars = 40.0 * star * starColor * starBrightness;
|
||||
|
||||
#if TWINKLING_STARS > 0
|
||||
stars *= getTwinklingStars(starCoord, float(TWINKLING_STARS));
|
||||
#endif
|
||||
|
||||
return stars;
|
||||
}
|
||||
#endif
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#ifndef INCLUDE_ENDER_BEAMS
|
||||
#define INCLUDE_ENDER_BEAMS
|
||||
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
|
||||
vec2 wind = vec2(frameTimeCounter * 0.001 * END_BEAM_SPEED);
|
||||
|
||||
float BeamNoise(vec2 planeCoord, vec2 wind) {
|
||||
float noise = texture2DLod(noisetex, planeCoord * 0.175 - wind, 0.0).b * 0.5;
|
||||
noise+= texture2DLod(noisetex, planeCoord * 0.04375 + wind * 0.5, 0.0).b * 2.0;
|
||||
noise+= texture2DLod(noisetex, planeCoord * 0.7 - wind, 0.0).b * 0.5;
|
||||
|
||||
return noise / 3.0;
|
||||
}
|
||||
|
||||
vec3 DrawEnderBeams(float vlFactor, vec3 playerPos, vec3 nViewPos, float scale) {
|
||||
#ifndef END_BEAMS
|
||||
return vec3(0.0);
|
||||
#else
|
||||
float beamPowBeforeAltitude = 1.0;
|
||||
float beamPowAfterAltitude = END_BEAM_POW;
|
||||
float lPlayerPosXZ = length(playerPos.xz);
|
||||
float beamPurpleReducer = vlFactor;
|
||||
float beamOrangeIncreaser = vlFactor * 1.5;
|
||||
float beamHeightIncreaser = 1.0;
|
||||
|
||||
#if defined END_FLASHES && EP_END_FLASH % 2 == 0
|
||||
vec3 worldEndFlashPosition = mat3(gbufferModelViewInverse) * endFlashPosition;
|
||||
worldEndFlashPosition = normalize(vec3(worldEndFlashPosition.x, 0.0, worldEndFlashPosition.z));
|
||||
vec3 nViewPosWorld = mat3(gbufferModelViewInverse) * nViewPos;
|
||||
vec3 nViewPosWorldM = normalize(vec3(nViewPosWorld.x, 0.0, nViewPosWorld.z));
|
||||
|
||||
float endFlashDirectionFactor = pow(max0(dot(worldEndFlashPosition, nViewPosWorldM)), (32.0 - 24.0 * vlFactor) * END_BEAM_FLASH_NARROWNESS);
|
||||
float endFlashFactor = endFlashIntensityM * endFlashDirectionFactor;
|
||||
|
||||
endFlashFactor *= smoothstep(0.0, 512.0, lPlayerPosXZ);
|
||||
|
||||
beamOrangeIncreaser = mix(beamOrangeIncreaser, 1.5, endFlashFactor);
|
||||
beamPurpleReducer = mix(beamPurpleReducer, 1.5, endFlashFactor);
|
||||
beamHeightIncreaser = mix(beamHeightIncreaser, END_BEAM_FLASH_HEIGHT_MULTIPLIER, endFlashFactor);
|
||||
|
||||
beamPowBeforeAltitude *= 1.0 - endFlashFactor;
|
||||
beamPowAfterAltitude *= 1.0 - 0.4 * endFlashFactor * END_BEAM_FLASH_POW_MULTIPLIER; // make sure that it does not get <= 0
|
||||
#endif
|
||||
|
||||
vec3 beamPurple = baseBeamPurple * (2.5 - beamPurpleReducer);
|
||||
vec3 beamOrange = endOrangeCol * (300.0 + 700.0 * beamOrangeIncreaser);
|
||||
|
||||
vec2 planeCoordRaw = playerPos.xz + cameraPosition.xz;
|
||||
vec2 planeCoord = planeCoordRaw * 0.0007 * scale * END_BEAM_SCALE;
|
||||
|
||||
float noise = BeamNoise(planeCoord, wind);
|
||||
float fireNoise = texture2DLod(noisetex, abs(planeCoord * 0.1) - wind, 0.0).b;
|
||||
|
||||
float uncenteredDistance = (2000.0 * pow2(noise) + 40.0 * fireNoise) * 0.001 * END_BEAM_HEIGHT * beamHeightIncreaser * (250.0 + 0.5 * lPlayerPosXZ);
|
||||
float altitude = playerPos.y + cameraPosition.y;
|
||||
float signedAltitude = altitude - END_BEAM_CENTER_ALT;
|
||||
float altitudeDis = abs(signedAltitude);
|
||||
float altitudeFactor = 0.5 * smoothstep(uncenteredDistance, 0.0, altitudeDis)
|
||||
+ 0.5 * smoothstep(4.0 * uncenteredDistance, 0.0, altitudeDis);
|
||||
|
||||
noise = pow2(noise) * 0.7 + 0.3 * fireNoise;
|
||||
|
||||
#if END_BEAM_DIRECTION_BIAS != 0
|
||||
float beamDirectionBias = clamp(END_BEAM_DIRECTION_BIAS * 0.01, -1.0, 1.0);
|
||||
float directionTransitionWidth = max(uncenteredDistance * 0.115, 1.0);
|
||||
float aboveContribution = smoothstep(-directionTransitionWidth, directionTransitionWidth, signedAltitude);
|
||||
float belowContribution = 1.0 - aboveContribution;
|
||||
|
||||
float sideFactor = aboveContribution * (1.0 - max0(-beamDirectionBias)) // above fades out when bias is negative
|
||||
+ belowContribution * (1.0 - max0(beamDirectionBias)); // below fades out when bias is positive
|
||||
noise *= sideFactor + 0.000001;
|
||||
|
||||
#if END_BEAM_DIRECTION_BIAS == 100 || END_BEAM_DIRECTION_BIAS == -100
|
||||
// This brings some wave details, was some happy accident haha
|
||||
altitudeFactor *= pow6(sideFactor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
noise = pow(noise, beamPowBeforeAltitude);
|
||||
noise *= pow(altitudeFactor, 4.0);
|
||||
noise = pow(noise, beamPowAfterAltitude);
|
||||
|
||||
vec3 beamColor = beamPurple;
|
||||
beamColor += beamOrange * (0.0015 + 0.2 * smoothstep(0.0, 256.0, lPlayerPosXZ) * pow2(pow2(fireNoise - 0.5)));
|
||||
|
||||
vec3 beams = noise * END_BEAM_INTENSITY * beamColor * (1.0 + smoothstep(0.0, 128.0, lPlayerPosXZ));
|
||||
|
||||
if(any(isnan(beams))) beams = vec3(0.0);
|
||||
|
||||
return beams;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //INCLUDE_ENDER_BEAMS
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
#include "/lib/shaderSettings/volumetricLight.glsl"
|
||||
#include "/lib/shaderSettings/endBeams.glsl"
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
//#define BEDROCK_NOISE
|
||||
|
||||
vec4 DistortShadow(vec4 shadowpos, float distortFactor) {
|
||||
shadowpos.xy *= 1.0 / distortFactor;
|
||||
shadowpos.z = shadowpos.z * 0.2;
|
||||
shadowpos = shadowpos * 0.5 + 0.5;
|
||||
|
||||
return shadowpos;
|
||||
}
|
||||
|
||||
vec4 GetVolumetricLight(inout float vlFactor, vec3 translucentMult, float lViewPos0, float lViewPos1, vec3 nViewPos, float VdotL, float VdotU, float z0, float z1, float z1lod, float dither) {
|
||||
// ============================== Step 1: Prepare Factors ============================== //
|
||||
float vlMult = 1.0 - maxBlindnessDarkness;
|
||||
|
||||
#if defined BEDROCK_NOISE && defined OVERWORLD
|
||||
if ((cameraPosition.y < bedrockLevel) && (eyeBrightnessM < 0.4)) return vec4(0.0);
|
||||
#endif
|
||||
|
||||
#if RETRO_LOOK == 1
|
||||
return vec4(0.0);
|
||||
#elif RETRO_LOOK == 2
|
||||
if (nightVision > 0.999) return vec4(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 vlColor = lightColor;
|
||||
vec3 vlColorReducer = vec3(1.0);
|
||||
float vlSceneIntensity = isEyeInWater != 1 ? vlFactor : 1.0;
|
||||
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
vlSceneIntensity = mix(vlSceneIntensity, 1.0, inDry * rainFactor);
|
||||
vlColor *= 1.0 + 0.6 * inDry * rainFactor;
|
||||
#endif
|
||||
|
||||
if (sunVisibility < 0.5) {
|
||||
vlSceneIntensity = 0.0;
|
||||
|
||||
float vlMultNightModifier = (0.3 + 0.4 * rainFactor2 + 0.5 * max0(far - lViewPos1) / far);
|
||||
#if defined SPECIAL_PALE_GARDEN_LIGHTSHAFTS && MC_VERSION >= 12104
|
||||
vlMultNightModifier = mix(vlMultNightModifier, 1.0, inPaleGarden);
|
||||
#endif
|
||||
vlMult *= vlMultNightModifier;
|
||||
|
||||
vlColor = normalize(pow(vlColor, vec3(1.0 - max0(1.0 - 1.5 * nightFactor) + rainFactor)));
|
||||
vlColor *= 0.0766 + 0.0766 * vsBrightness;
|
||||
} else {
|
||||
vlColorReducer = 1.0 / sqrt(vlColor);
|
||||
}
|
||||
|
||||
#if BLOOD_MOON > 0
|
||||
vec3 hsvVlColor = rgb2hsv(vlColor);
|
||||
vlColor = mix(vlColor, hsv2rgb(vec3(0, max(0.8, hsvVlColor.y), hsvVlColor.z * 1.7)), getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
|
||||
#if defined SPECIAL_PALE_GARDEN_LIGHTSHAFTS && MC_VERSION >= 12104
|
||||
vlSceneIntensity = mix(vlSceneIntensity, 1.0, inPaleGarden);
|
||||
vlMult *= 1.0 + (3.0 * inPaleGarden) * (1.0 - sunVisibility);
|
||||
#endif
|
||||
|
||||
float rainyNight = (1.0 - sunVisibility) * rainFactor;
|
||||
float VdotLM = max((VdotL + 1.0) / 2.0, 0.0);
|
||||
float VdotUmax0 = max(VdotU, 0.0);
|
||||
float VdotUM = mix(pow2(1.0 - VdotUmax0), 1.0, 0.5 * vlSceneIntensity);
|
||||
VdotUM = smoothstep1(VdotUM);
|
||||
VdotUM = pow(VdotUM, min(lViewPos1 / far, 1.0) * (3.0 - 2.0 * vlSceneIntensity));
|
||||
|
||||
float vlTime = min(abs(SdotU) - 0.05, 0.15) / 0.15;
|
||||
vlMult *= mix(VdotUM * VdotLM, 1.0, 0.4 * rainyNight) * vlTime;
|
||||
|
||||
vlMult *= mix(invNoonFactor2 * 0.875 + 0.125, 1.0, max(vlSceneIntensity, rainFactor2));
|
||||
vlMult *= 1.4 - 0.4 * rainFactor;
|
||||
#elif defined END
|
||||
vec3 vlColorReducer = vec3(1.0);
|
||||
#endif
|
||||
|
||||
if (vlMult < 0.0001) return vec4(0.0);
|
||||
// ============================== End of Step 1 ============================== //
|
||||
|
||||
// ============================== Step 2: Prepare Tracing Variables ============================== //
|
||||
vec4 volumetricLight = vec4(0.0);
|
||||
|
||||
#if SHADOW_QUALITY > -1 && !defined IS_IRIS
|
||||
// Optifine for some reason doesn't provide correct shadowMapResolution if Shadow Quality isn't 1x
|
||||
vec2 shadowMapResolutionM = textureSize(shadowtex0, 0);
|
||||
#else
|
||||
vec2 shadowMapResolutionM = vec2(shadowMapResolution);
|
||||
#endif
|
||||
|
||||
bool sky = z1 == 1.0;
|
||||
#if defined VOXY || defined DISTANT_HORIZONS
|
||||
sky = sky && z1lod == 1.0;
|
||||
#endif
|
||||
|
||||
#if LIGHTSHAFT_QUALI_DEFINE == 0 || LIGHTSHAFT_QUALI_DEFINE == 1 // OFF - Function still active in the End dimension || Low
|
||||
#ifdef OVERWORLD
|
||||
int nearSamples = 6;
|
||||
#else
|
||||
int nearSamples = 10;
|
||||
#endif
|
||||
#elif LIGHTSHAFT_QUALI_DEFINE == 2 // Medium (Default)
|
||||
#ifdef OVERWORLD
|
||||
int nearSamples = 10;
|
||||
#else
|
||||
int nearSamples = 15;
|
||||
#endif
|
||||
#elif LIGHTSHAFT_QUALI_DEFINE == 3 // High
|
||||
#ifdef OVERWORLD
|
||||
int nearSamples = 15;
|
||||
#else
|
||||
int nearSamples = 20;
|
||||
#endif
|
||||
#elif LIGHTSHAFT_QUALI_DEFINE == 4 // Very High
|
||||
int nearSamples = 30;
|
||||
#endif
|
||||
|
||||
// Balance Defining Variables
|
||||
#ifdef OVERWORLD
|
||||
int farSamples = 1;
|
||||
float fogCurve = 0.9; // 1.0 = linear fog
|
||||
float fogCurveIntense = 0.5;
|
||||
float sampleDistribution = 2.0; // sample distribution power (higher values push near samples closer to camera)
|
||||
float sampleDistributionFar = 2.5;
|
||||
|
||||
float maxDistance = far * 0.98; // The distance where the fog is 1.0 and we stop tracing
|
||||
float qualityThreshold = min(far, shadowDistance) * 0.98; // Only use farSamples from this point on to hit our maxDistance. Set higher than maxDistance to disable far samples
|
||||
|
||||
#if defined VOXY || defined DISTANT_HORIZONS
|
||||
maxDistance = renderDistance * 0.5; // Covers lod chunks
|
||||
|
||||
fogCurve = 0.7;
|
||||
fogCurveIntense *= 1.0 - 0.5 * rainFactor;
|
||||
#endif
|
||||
|
||||
maxDistance = max(maxDistance, 128.0);
|
||||
|
||||
// Tweaks for intense situations
|
||||
if (isEyeInWater == 1) {
|
||||
maxDistance = mix(maxDistance, 128.0, isEyeInWater == 1);
|
||||
#if WATER_FOG_MULT != 100
|
||||
#define WATER_FOG_MULT_M WATER_FOG_MULT * 0.01;
|
||||
maxDistance /= WATER_FOG_MULT_M;
|
||||
#endif
|
||||
}
|
||||
qualityThreshold = mix(qualityThreshold, 100.0, vlSceneIntensity);
|
||||
fogCurve = mix(fogCurve, fogCurveIntense, max(vlSceneIntensity, rainFactor));
|
||||
nearSamples = int(mix(float(nearSamples), 1.5 * nearSamples, vlSceneIntensity));
|
||||
sampleDistribution = mix(sampleDistribution, 1.5, vlSceneIntensity);
|
||||
|
||||
#if !defined VOXY && !defined DISTANT_HORIZONS
|
||||
float beamScale = 1536.0 / maxDistance;
|
||||
#else
|
||||
float beamScale = 15360.0 / max(1536.0, maxDistance * 0.5);
|
||||
#endif
|
||||
|
||||
#elif defined END
|
||||
int farSamples = nearSamples;
|
||||
float fogCurve = 0.55;
|
||||
float sampleDistribution = 1.3;
|
||||
float sampleDistributionFar = 2.5;
|
||||
|
||||
nearSamples *= 3;
|
||||
|
||||
#if !defined VOXY && !defined DISTANT_HORIZONS
|
||||
float maxDistance = 1536 * END_BEAM_DISTANCE_MULTIPLIER; // 96 chunks
|
||||
float beamScale = 1.0;
|
||||
#else
|
||||
float maxDistance = max(1536.0, renderDistance * 0.5) * END_BEAM_DISTANCE_MULTIPLIER;
|
||||
float beamScale = 1536.0 / maxDistance;
|
||||
#endif
|
||||
|
||||
float qualityThreshold = min(far, shadowDistance) * 0.98;
|
||||
#endif
|
||||
|
||||
#ifdef COMPOSITE // Reflections
|
||||
nearSamples /= 2;
|
||||
farSamples /= 2;
|
||||
#endif
|
||||
|
||||
vec3 nViewPosInSceneSpace = normalize(mat3(gbufferModelViewInverse) * nViewPos);
|
||||
vec3 rayDirection = nViewPosInSceneSpace;
|
||||
float rayEnd = !sky ? min(lViewPos1, maxDistance) : maxDistance;
|
||||
float lastDistance = 0.0;
|
||||
|
||||
#ifdef END
|
||||
float fog = lViewPos0 / renderDistance;
|
||||
fog = pow2(pow2(fog));
|
||||
fog = 1.0 - exp(-3.0 * fog);
|
||||
|
||||
rayEnd = mix(rayEnd, maxDistance, fog * END_BEAM_FOG_BLEND);
|
||||
lViewPos0 = mix(lViewPos0, maxDistance, fog);
|
||||
#endif
|
||||
|
||||
#ifdef LIGHTSHAFT_SMOKE
|
||||
float smokePower = pow2(1.0 - rayEnd / maxDistance);
|
||||
#endif
|
||||
|
||||
float activeThreshold = min(qualityThreshold, maxDistance);
|
||||
int totalSamples = (rayEnd <= qualityThreshold) ? nearSamples : (nearSamples + farSamples);
|
||||
// ============================== End of Step 2 ============================== //
|
||||
|
||||
// ============================== Step 3: Execute Volumetric Tracing ============================== //
|
||||
for (int i = 0; i <= totalSamples; i++) {
|
||||
float nextDistance;
|
||||
vec3 scenePos;
|
||||
vec3 localDensity = vec3(1.0);
|
||||
|
||||
if (i <= nearSamples) { // Actual light shaft sampling near-field section
|
||||
float t = (float(i) + dither) / float(nearSamples);
|
||||
nextDistance = pow(t, sampleDistribution) * activeThreshold;
|
||||
scenePos = rayDirection * nextDistance;
|
||||
|
||||
if (nextDistance >= rayEnd) break;
|
||||
|
||||
// Shadow Sampling
|
||||
localDensity = vec3(1.0);
|
||||
#if SHADOW_QUALITY > -1 && defined COMPOSITE1
|
||||
vec3 shadowPos = GetShadowPos(scenePos);
|
||||
if (length(shadowPos.xy * 2.0 - 1.0) < 1.0) {
|
||||
// 28A3DK6 We need to use texelFetch here or a lot of Nvidia GPUs can't get a valid value
|
||||
float shadowSample = texelFetch(shadowtex0, ivec2(shadowPos.xy * shadowMapResolutionM), 0).x;
|
||||
shadowSample = clamp((shadowSample - shadowPos.z) * 65536.0, 0.0, 1.0);
|
||||
|
||||
localDensity = vec3(shadowSample);
|
||||
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
localDensity = mix(vec3(1.0), localDensity, endFlashIntensityM);
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 1
|
||||
if (shadowSample == 0.0) {
|
||||
float translucentShadowSample = shadow2D(shadowtex1, shadowPos.xyz).z;
|
||||
if (translucentShadowSample == 1.0) {
|
||||
vec3 shadowColorSample = texture2D(shadowcolor1, shadowPos.xy).rgb * 4.0;
|
||||
localDensity = pow2(shadowColorSample) * vlColorReducer;
|
||||
}
|
||||
} else {
|
||||
#ifdef OVERWORLD
|
||||
// For water-tinting the water surface when observed from below the surface
|
||||
if (translucentMult != vec3(1.0) && nextDistance > lViewPos0) {
|
||||
vec3 tinter = vec3(1.0);
|
||||
if (isEyeInWater == 1) {
|
||||
vec3 translucentMultM = translucentMult * 2.8;
|
||||
tinter = pow(translucentMultM, vec3(sunVisibility * 3.0 * clamp01(scenePos.y * 0.03)));
|
||||
} else {
|
||||
tinter = 0.1 + 0.9 * pow2(pow2(translucentMult * 1.7));
|
||||
}
|
||||
localDensity *= mix(vec3(1.0), tinter, clamp01(oceanAltitude - cameraPosition.y));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (isEyeInWater == 1 && translucentMult == vec3(1.0)) localDensity = vec3(0.0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
else { // Far field low sample section
|
||||
float t = (float(i - nearSamples) + dither) / float(farSamples);
|
||||
nextDistance = mix(activeThreshold, maxDistance, pow(t, sampleDistributionFar));
|
||||
scenePos = rayDirection * nextDistance;
|
||||
|
||||
if (nextDistance >= rayEnd) {
|
||||
nextDistance = rayEnd;
|
||||
#ifdef END
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OVERWORLD
|
||||
localDensity = vec3(eyeBrightnessM);
|
||||
#elif defined END
|
||||
localDensity = vec3(1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LIGHTSHAFT_SMOKE
|
||||
vec3 smokePos = 0.0015 * (scenePos + cameraPosition);
|
||||
vec3 smokeWind = frameTimeCounter * vec3(0.0, 0.001, -0.002);
|
||||
float smoke = 0.65 * Noise3D(smokePos + smokeWind)
|
||||
+ 0.25 * Noise3D((smokePos - smokeWind) * 3.0)
|
||||
+ 0.10 * Noise3D((smokePos + smokeWind) * 9.0);
|
||||
smoke = smoothstep1(smoothstep1(smoothstep1(smoke)));
|
||||
localDensity *= pow(smoke, smokePower);
|
||||
#endif
|
||||
|
||||
// For fog density to not move regardless of how we distribute the samples
|
||||
float currentWeight = smoothstep1(pow(lastDistance / maxDistance, fogCurve));
|
||||
float nextWeight = smoothstep1(pow(nextDistance / maxDistance, fogCurve));
|
||||
float sliceWeight = nextWeight - currentWeight;
|
||||
|
||||
vec4 stepResult = vec4(localDensity * sliceWeight, sliceWeight);
|
||||
|
||||
// Result Coloring
|
||||
if (nextDistance > lViewPos0) stepResult.rgb *= translucentMult;
|
||||
#ifdef END
|
||||
vec3 beamPos = scenePos;
|
||||
stepResult.rgb *= DrawEnderBeams(vlFactor, beamPos, nViewPos, beamScale);
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD && defined OVERWORLD_BEAMS
|
||||
vec4 overworldBeamSample = DrawOverworldBeams(scenePos, nViewPos, beamScale);
|
||||
stepResult.rgb *= mix(vec3(1.0), overworldBeamSample.rgb, overworldBeamSample.a);
|
||||
#endif
|
||||
|
||||
volumetricLight += stepResult;
|
||||
|
||||
lastDistance = nextDistance;
|
||||
}
|
||||
// ============================== End of Step 3 ============================== //
|
||||
|
||||
// ============================== Step 4: Calculate factor of Scene Aware Light Shafts ============================== //
|
||||
#if defined OVERWORLD && LIGHTSHAFT_BEHAVIOUR == 1 && SHADOW_QUALITY >= 1 && defined COMPOSITE1
|
||||
if (viewWidth + viewHeight - gl_FragCoord.x - gl_FragCoord.y < 1.5) {
|
||||
if (frameCounter % int(0.06666 / frameTimeSmooth + 0.5) == 0) { // Change speed is not too different above 10 fps
|
||||
int salsX = 5;
|
||||
int salsY = 5;
|
||||
float heightThreshold = 6.0;
|
||||
|
||||
vec2 viewM = 1.0 / vec2(salsX, salsY);
|
||||
float salsSampleSum = 0.0;
|
||||
int salsSampleCount = 0;
|
||||
for (float i = 0.25; i < salsX; i++) {
|
||||
for (float h = 0.45; h < salsY; h++) {
|
||||
vec2 coord = 0.3 + 0.4 * viewM * vec2(i, h);
|
||||
ivec2 icoord = ivec2(coord * shadowMapResolutionM);
|
||||
float salsSample = texelFetch(shadowtex0, icoord, 0).x; // read 28A3DK6
|
||||
if (salsSample < 0.55) {
|
||||
float sampledHeight = texture2D(shadowcolor1, coord).a;
|
||||
if (sampledHeight > 0.0) {
|
||||
sampledHeight = max0(sampledHeight - 0.25) / 0.05; // consistencyMEJHRI7DG
|
||||
salsSampleSum += sampledHeight;
|
||||
salsSampleCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float salsCheck = salsSampleSum / salsSampleCount;
|
||||
int reduceAmount = 2;
|
||||
|
||||
int skyCheck = 0;
|
||||
float translucentDistanceTreshold = 5.0 / far;
|
||||
for (float i = 0.1; i < 1.0; i += 0.2) {
|
||||
ivec2 checkCoord = ivec2(view.x * i, view.y * 0.9);
|
||||
float depth0Check = texelFetch(depthtex0, checkCoord, 0).x;
|
||||
|
||||
if (GetLinearDepth(depth0Check) < translucentDistanceTreshold) {
|
||||
float depth1Check = texelFetch(depthtex1, checkCoord, 0).x;
|
||||
|
||||
if (depth1Check == 1.0) {
|
||||
skyCheck += 1;
|
||||
}
|
||||
} else if (depth0Check == 1.0) {
|
||||
skyCheck += 1;
|
||||
}
|
||||
}
|
||||
if (skyCheck >= 3) {
|
||||
salsCheck = 0.0;
|
||||
reduceAmount = 3;
|
||||
}
|
||||
|
||||
if (salsCheck > heightThreshold) {
|
||||
vlFactor = min(vlFactor + OSIEBCA, 1.0);
|
||||
} else {
|
||||
vlFactor = max(vlFactor - OSIEBCA * reduceAmount, 0.0);
|
||||
}
|
||||
}
|
||||
} else vlFactor = 0.0;
|
||||
#endif
|
||||
// ============================== End of Step 4 ============================== //
|
||||
|
||||
// ============================== Step 5: Final Tweaks ============================== //
|
||||
#ifdef OVERWORLD
|
||||
vlColor = pow(vlColor, vec3(0.5 + (0.5 + LIGHTSHAFT_SUNSET_SATURATION * sunVisibility) * invNoonFactor * invRainFactor + 0.3 * rainFactor));
|
||||
vlColor *= 1.0 - (0.3 + 0.3 * noonFactor) * rainFactor - 0.5 * rainyNight + sunVisibility * pow2(invNoonFactor) * invRainFactor;
|
||||
|
||||
#if LIGHTSHAFT_NOON_I != 100 || LIGHTSHAFT_SUNSET_I != 100 || LIGHTSHAFT_NIGHT_I != 100 || LIGHTSHAFT_RAIN_I != 100
|
||||
#define LIGHTSHAFT_NOON_IM LIGHTSHAFT_NOON_I * 0.01
|
||||
#define LIGHTSHAFT_SUNSET_IM LIGHTSHAFT_SUNSET_I * 0.01
|
||||
#define LIGHTSHAFT_NIGHT_IM LIGHTSHAFT_NIGHT_I * 0.01
|
||||
#define LIGHTSHAFT_RAIN_IM LIGHTSHAFT_RAIN_I * 0.01
|
||||
|
||||
if (isEyeInWater == 0) {
|
||||
vlMult *= mix(LIGHTSHAFT_NIGHT_IM, mix(LIGHTSHAFT_SUNSET_IM, LIGHTSHAFT_NOON_IM, pow3(noonFactor)), sunVisibility);
|
||||
vlMult *= mix(1.0, LIGHTSHAFT_RAIN_IM, rainFactor);
|
||||
}
|
||||
#endif
|
||||
|
||||
volumetricLight.rgb *= vlColor;
|
||||
#elif defined END
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SULFUR_CAVE_FOG
|
||||
volumetricLight.rgb = mix(volumetricLight.rgb, vec3(GetLuminance(volumetricLight.rgb)) * vec3(1.0, 1.0, 0.5), inSulfurCaves);
|
||||
#endif
|
||||
|
||||
volumetricLight.rgb *= vlMult;
|
||||
|
||||
volumetricLight = max(volumetricLight, vec4(0.0)); // Fixes rare nans
|
||||
// ============================== End of Step 5 ============================== //
|
||||
|
||||
#if RETRO_LOOK == 2
|
||||
volumetricLight *= 1.0 - nightVision;
|
||||
#endif
|
||||
|
||||
return volumetricLight;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#include "/lib/shaderSettings/materials.glsl"
|
||||
#define BASE_BLOCKLIGHT (vec3(0.1775, 0.104, 0.077) * vec3(XLIGHT_R, XLIGHT_G, XLIGHT_B))
|
||||
|
||||
#define SOUL_VALLEY_COLOR vec3(0.05, 0.22, 0.25)
|
||||
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
vec3 blocklightCol = mix(BASE_BLOCKLIGHT, SOUL_VALLEY_COLOR, inSoulValley);
|
||||
#else
|
||||
vec3 blocklightCol = BASE_BLOCKLIGHT;
|
||||
#endif
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
#include "/lib/colors/blocklightColorsACT.glsl"
|
||||
#endif
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
|
||||
#ifdef PHOTONICS_LIGHTING
|
||||
#define LAVA_ACT_ALPHA 0.25
|
||||
#else
|
||||
#define LAVA_ACT_ALPHA 0.8
|
||||
#endif
|
||||
|
||||
vec3 fireSpecialLightColorCompBase = vec3(2.25, 0.83, 0.27) * 3.7;
|
||||
#if ACT_FIRE_COLOR_WARMNESS == 100
|
||||
vec3 fireSpecialLightColorBase = fireSpecialLightColorCompBase;
|
||||
#elif ACT_FIRE_COLOR_WARMNESS < 100
|
||||
vec3 fireSpecialLightColorBase = mix(blocklightCol * 25.0, fireSpecialLightColorCompBase, float(ACT_FIRE_COLOR_WARMNESS) * 0.01);
|
||||
#elif ACT_FIRE_COLOR_WARMNESS > 100
|
||||
vec3 fireSpecialLightColorBase = mix(fireSpecialLightColorCompBase, vec3(1.0, 0.2, 0.0) * 8.0, float(ACT_FIRE_COLOR_WARMNESS - 100) * 0.01);
|
||||
#endif
|
||||
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
vec3 fireSpecialLightColorGradient = mix(vec3(2.0, 0.87, 0.27) * 3.8, mix(vec3(2.5, 0.87, 0.27), vec3(0.5, 1.9, 2.1) * 3.8, 0.3), inSoulValley);
|
||||
vec3 torchBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27) * 3.8, mix(vec3(2.5, 0.87, 0.27), vec3(0.5, 1.9, 2.1) * 3.8, 0.5), inSoulValley);
|
||||
vec3 lanternBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27) * 3.8, mix(vec3(2.5, 0.87, 0.27), vec3(0.5, 1.9, 2.1) * 3.8, 0.4), inSoulValley);
|
||||
vec3 fireSpecialLightColor = mix(fireSpecialLightColorBase, vec3(0.5, 1.9, 2.1) * 3.8, inSoulValley);
|
||||
vec4 lavaSpecialLightColor = vec4(mix(vec3(3.25, 0.9, 0.2) * 3.9, vec3(0.5, 1.9, 2.1) * 4.0, inSoulValley), LAVA_ACT_ALPHA);
|
||||
vec4 brewingStandSpecialLightColor = vec4(mix(vec3(2.5, 1.2, 0.4) * 0.1, vec3(0.5, 1.9, 2.1) * 0.1, inSoulValley), 0.1);
|
||||
#elif defined PURPLE_END_FIRE_INTERNAL
|
||||
vec3 fireSpecialLightColor = vec3(0.6, 0.3, 2.4) * 3.8;
|
||||
vec3 fireSpecialLightColorGradient = mix(vec3(2.0, 0.77, 0.17) * 3.8, fireSpecialLightColor, clamp01(0.7 + max(0.0, clamp01(sin(pow2(texture2DLod(noisetex, vec2(frameTimeCounter * 0.01), 0.0).r))))));
|
||||
vec3 torchBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27), fireSpecialLightColor, clamp01(0.75)); // Super odd intel nan fix
|
||||
vec3 lanternBlockSpecialLightColor = fireSpecialLightColor;
|
||||
vec4 lavaSpecialLightColor = vec4(vec3(1.0, 0.5, 4.0) * 4.0, LAVA_ACT_ALPHA);
|
||||
vec4 brewingStandSpecialLightColor = vec4(vec3(0.10, 0.05, 0.4) * 0.4, 0.1);
|
||||
#else
|
||||
vec3 fireSpecialLightColor = fireSpecialLightColorBase;
|
||||
vec3 fireSpecialLightColorGradient = fireSpecialLightColor;
|
||||
vec3 torchBlockSpecialLightColor = fireSpecialLightColor;
|
||||
vec3 lanternBlockSpecialLightColor = fireSpecialLightColor;
|
||||
vec4 lavaSpecialLightColor = vec4(vec3(3.25, 0.9, 0.2) * 3.9, LAVA_ACT_ALPHA);
|
||||
vec4 brewingStandSpecialLightColor = vec4(vec3(2.5, 1.2, 0.4) * 0.1, 0.1);
|
||||
#endif
|
||||
#if defined NETHER && defined BIOME_COLORED_NETHER_PORTALS
|
||||
vec3 netherPortalSpecialLightColor = normalize(netherColor) * 2.0;
|
||||
vec3 respawnAnchorSpecialLightColor = normalize(netherColor) * 2.0;
|
||||
#else
|
||||
vec3 netherPortalSpecialLightColor = vec3(1.8, 0.4, 2.2) * 0.8;
|
||||
vec3 respawnAnchorSpecialLightColor = vec3(1.7, 0.9, 0.4) * 2.0;
|
||||
#endif
|
||||
vec3 redstoneSpecialLightColor = vec3(4.0, 0.1, 0.1);
|
||||
vec4 soulFireSpecialColor = vec4(vec3(0.3, 2.0, 2.2) * 1.0, 0.3);
|
||||
float candleColorMult = 2.0;
|
||||
float candleExtraLight = 0.004;
|
||||
#if END_ROD_COLOR_PROFILE == 1
|
||||
vec3 endRodSpacialColor = vec3(END_ROD_R, END_ROD_G, END_ROD_B) / 255 * END_ROD_I;
|
||||
#elif (END_ROD_COLOR_PROFILE == 2 || (END_ROD_COLOR_PROFILE == 3 && defined OVERWORLD)) && COLORED_LIGHTING_INTERNAL > 0
|
||||
vec3 endRodSpacialColor = vec3(pow2(getRainbowColor(vec2(0.0), float(END_ROD_RAINBOW_ANIMATE))));
|
||||
#else
|
||||
#ifdef END
|
||||
vec3 endRodSpacialColor = vec3(1.25, 0.5, 1.25); // End Rod in the End dimension
|
||||
#else
|
||||
vec3 endRodSpacialColor = vec3(1.0, 1.0, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EMISSIVE_ENCHANTING_TABLE
|
||||
vec3 enchantingTableSpecialLightColor = vec3(0.5, 2.0, 2.0) * 0.4;
|
||||
#else
|
||||
vec3 enchantingTableSpecialLightColor = vec3(1.4, 1.1, 0.5);
|
||||
#endif
|
||||
void AddSpecialLightDetail(inout vec3 light, vec3 albedo, float emission) {
|
||||
vec3 lightM = max(light, vec3(0.0));
|
||||
lightM /= (0.2 + 0.8 * GetLuminance(lightM));
|
||||
lightM *= (1.0 / (1.0 + emission)) * 0.22;
|
||||
light *= 0.9;
|
||||
light += pow2(lightM / (albedo + 0.1));
|
||||
}
|
||||
vec4 GetSpecialBlocklightColor(int mat) {
|
||||
/* Please note that these colors do not determine the intensity of the
|
||||
final light. Instead; higher values of color change how long the color
|
||||
will travel, and also how dominant it will be next to other colors.*/
|
||||
/* Additional feature: An alpha value bigger than 0 will make that
|
||||
block cast extra light regardless of the vanilla lightmap. Use this
|
||||
with caution though because our floodfill isn't as accurate as vanilla.*/
|
||||
|
||||
if (mat < 50) {
|
||||
if (mat < 26) {
|
||||
if (mat < 14) {
|
||||
if (mat < 8) {
|
||||
if (mat < 5) {
|
||||
if (mat == 2) return vec4(torchBlockSpecialLightColor, 0.0); // Torch
|
||||
if (mat == 3) return vec4(endRodSpacialColor * 4.0, 0.0); // End Rod - This is the base for all lights. Total value 12. vec3(1.0, 1.0, 1.0) * 4.0
|
||||
if (mat == 4) return vec4(vec3(0.7, 1.5, 2.0) * 3.0, 0.0); // Beacon
|
||||
} else {
|
||||
if (mat == 5) return vec4(fireSpecialLightColorGradient, 0.0); // Fire
|
||||
if (mat == 6) return vec4(vec3(0.7, 1.5, 1.5) * 1.7, 0.0); // Sea Pickle:Waterlogged
|
||||
if (mat == 7) return vec4(pow(vec3(1.1, 0.85, 0.35), vec3(FROGLIGHT_SATURATION * 0.5 + 0.5)) * 5.0, 0.0); // Ochre Froglight
|
||||
}
|
||||
} else {
|
||||
if (mat < 11) {
|
||||
if (mat == 8) return vec4(pow(vec3(0.6, 1.3, 0.6), vec3(FROGLIGHT_SATURATION * 0.5 + 0.5)) * 4.5, 0.0); // Verdant Froglight
|
||||
if (mat == 9) return vec4(pow(vec3(1.1, 0.5, 0.9), vec3(FROGLIGHT_SATURATION * 0.5 + 0.5)) * 4.5, 0.0); // Pearlescent Froglight
|
||||
if (mat == 10) return vec4(vec3(1.7, 0.9, 0.4) * 4.0, 0.0); // Glowstone
|
||||
} else {
|
||||
if (mat == 11) return vec4(fireSpecialLightColor, 0.0); // Jack o'Lantern
|
||||
if (mat == 12) return vec4(lanternBlockSpecialLightColor, 0.0); // Lantern
|
||||
if (mat == 13) return lavaSpecialLightColor; // Lava
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 20) {
|
||||
if (mat < 17) {
|
||||
if (mat == 14) return vec4(lavaSpecialLightColor.rgb, 0.0); // Lava Cauldron
|
||||
if (mat == 15) return vec4(fireSpecialLightColorGradient, 0.0); // Campfire:Lit
|
||||
if (mat == 16) return vec4(vec3(1.7, 0.9, 0.4) * 4.0, 0.0); // Redstone Lamp:Lit
|
||||
} else {
|
||||
if (mat == 17) return vec4(respawnAnchorSpecialLightColor, 0.0); // Respawn Anchor:Lit
|
||||
if (mat == 18) return vec4(vec3(1.0, 1.25, 1.5) * 3.4, 0.0); // Sea Lantern
|
||||
if (mat == 19) return vec4(vec3(3.0, 0.9, 0.2) * 3.0, 0.0); // Shroomlight
|
||||
}
|
||||
} else {
|
||||
if (mat < 23) {
|
||||
if (mat == 20) return vec4(vec3(2.3, 0.9, 0.2) * 3.4, 0.0); // Cave Vines:With Glow Berries
|
||||
if (mat == 21) return vec4(fireSpecialLightColor * 0.7, 0.0); // Furnace:Lit
|
||||
if (mat == 22) return vec4(fireSpecialLightColor * 0.7, 0.0); // Smoker:Lit
|
||||
} else {
|
||||
if (mat == 23) return vec4(fireSpecialLightColor * 0.7, 0.0); // Blast Furnace:Lit
|
||||
if (mat == 24) return vec4(fireSpecialLightColor * 0.25 * candleColorMult, candleExtraLight); // Standard Candles:Lit
|
||||
if (mat == 25) return vec4(netherPortalSpecialLightColor * 2.0, 0.4); // Nether Portal
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 38) {
|
||||
if (mat < 32) {
|
||||
if (mat < 29) {
|
||||
if (mat == 26) return vec4(netherPortalSpecialLightColor, 0.0); // Crying Obsidian
|
||||
if (mat == 27) return soulFireSpecialColor; // Soul Fire
|
||||
if (mat == 28) return soulFireSpecialColor; // Soul Torch
|
||||
} else {
|
||||
if (mat == 29) return soulFireSpecialColor; // Soul Lantern
|
||||
if (mat == 30) return soulFireSpecialColor; // Soul Campfire:Lit
|
||||
if (mat == 31) return vec4(redstoneSpecialLightColor * 0.5, 0.1 * ACT_ORE_INTENSITY); // Redstone Ores:Lit
|
||||
}
|
||||
} else {
|
||||
if (mat < 35) {
|
||||
if (mat == 32) return vec4(redstoneSpecialLightColor * 0.3, 0.1 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Redstone Ores:Unlit
|
||||
if (mat == 33) return vec4(enchantingTableSpecialLightColor, 0.05); // Enchanting Table
|
||||
#if GLOWING_LICHEN > 0
|
||||
if (mat == 34) return vec4(vec3(0.8, 1.1, 1.1), 0.05); // Glow Lichen with IntegratedPBR
|
||||
#else
|
||||
if (mat == 34) return vec4(vec3(0.4, 0.55, 0.55), 0.0); // Glow Lichen vanilla
|
||||
#endif
|
||||
} else {
|
||||
if (mat == 35) return vec4(redstoneSpecialLightColor * 0.25, 0.0); // Redstone Torch
|
||||
if (mat == 36) return vec4(vec3(0.325, 0.15, 0.425) * 2.0, 0.05); // Amethyst Cluster, Amethyst Buds, Calibrated Sculk Sensor
|
||||
if (mat == 37) return vec4(lavaSpecialLightColor.rgb * 0.1, 0.1); // Magma Block
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 44) {
|
||||
if (mat < 41) {
|
||||
#ifdef EMISSIVE_DRAGON_EGG
|
||||
if (mat == 38) return vec4(vec3(2.0, 0.5, 1.5) * 0.3, 0.1); // Dragon Egg
|
||||
#endif
|
||||
if (mat == 39) return vec4(vec3(2.0, 1.0, 1.5) * 0.25, 0.1); // Chorus Flower
|
||||
if (mat == 40) return brewingStandSpecialLightColor; // Brewing Stand
|
||||
} else {
|
||||
if (mat == 41) return vec4(redstoneSpecialLightColor * 0.4, 0.15); // Redstone Block
|
||||
if (mat == 42) return vec4(vec3(0.75, 0.75, 3.0) * 0.277, 0.15); // Lapis Block
|
||||
if (mat == 43) return vec4(vec3(1.7, 0.9, 0.4) * 0.45, 0.05 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Iron Ores
|
||||
}
|
||||
} else {
|
||||
if (mat < 47) {
|
||||
if (mat == 44) return vec4(vec3(1.7, 1.1, 0.2) * 0.45, 0.1 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Gold Ores
|
||||
if (mat == 45) return vec4(vec3(1.7, 0.8, 0.4) * 0.45, 0.05 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Copper Ores
|
||||
if (mat == 46) return vec4(vec3(0.75, 0.75, 3.0) * 0.2, 0.1 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Lapis Ores
|
||||
} else {
|
||||
if (mat == 47) return vec4(vec3(0.5, 3.5, 0.5) * 0.3, 0.1 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Emerald Ores
|
||||
if (mat == 48) return vec4(vec3(0.5, 2.0, 2.0) * 0.4, 0.15 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Diamond Ores
|
||||
if (mat == 49) return vec4(vec3(1.5, 1.5, 1.5) * 0.3, 0.05 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Nether Quartz Ore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 74) {
|
||||
if (mat < 62) {
|
||||
if (mat < 56) {
|
||||
if (mat < 53) {
|
||||
if (mat == 50) return vec4(vec3(1.7, 1.1, 0.2) * 0.45, 0.05 * ACT_ORE_INTENSITY) * GLOWING_ORE_MULT; // Nether Gold Ore
|
||||
if (mat == 51) return vec4(vec3(1.7, 1.1, 0.2) * 0.45, 0.05); // Gilded Blackstone
|
||||
if (mat == 52) return vec4(vec3(1.8, 0.8, 0.4) * 0.6, 0.15); // Ancient Debris
|
||||
} else {
|
||||
if (mat == 53) return vec4(vec3(1.4, 0.2, 1.4) * 0.3, 0.05); // Spawner
|
||||
if (mat == 54) return vec4(vec3(3.1, 1.1, 0.3) * 1.0, 0.1); // Trial Spawner:NotOminous:Active, Vault:NotOminous:Active
|
||||
if (mat == 55) return vec4(vec3(1.7, 0.9, 0.4) * 4.0, 0.0); // Copper Bulb:BrighterOnes:Lit
|
||||
}
|
||||
} else {
|
||||
if (mat < 59) {
|
||||
if (mat == 56) return vec4(vec3(1.7, 0.9, 0.4) * 2.0, 0.0); // Copper Bulb:DimmerOnes:Lit
|
||||
if (mat == 57) return vec4(vec3(0.1, 0.3, 0.4) * 0.5, 0.0005); // Sculk++
|
||||
if (mat == 58) return vec4(vec3(0.0, 1.4, 1.4) * 4.0, 0.15); // End Portal Frame:Active
|
||||
} else {
|
||||
if (mat == 59) return vec4(0.0); // Bedrock
|
||||
if (mat == 60) return vec4(vec3(3.1, 1.1, 0.3) * 0.125, 0.0125); // Command Block
|
||||
if (mat == 61) return vec4(vec3(3.0, 0.9, 0.2) * 0.125, 0.0125); // Warped Fungus, Crimson Fungus
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 68) {
|
||||
if (mat < 65) {
|
||||
if (mat == 62) return vec4(vec3(3.5, 0.6, 0.4) * 0.3, 0.05); // Crimson Stem, Crimson Hyphae
|
||||
if (mat == 63) return vec4(vec3(0.3, 1.9, 1.5) * 0.3, 0.05); // Warped Stem, Warped Hyphae
|
||||
if (mat == 64) return vec4(vec3(1.0, 1.0, 1.0) * 0.45, 0.1); // Structure Block, Jigsaw Block, Test Block, Test Instance Block
|
||||
} else {
|
||||
if (mat == 65) return vec4(vec3(3.0, 0.9, 0.2) * 0.125, 0.0125); // Weeping Vines Plant
|
||||
if (mat == 66) return vec4(redstoneSpecialLightColor * 0.05, 0.002); // Redstone Wire:Lit, Comparator:Unlit:Subtract
|
||||
if (mat == 67) return vec4(redstoneSpecialLightColor * 0.125, 0.0125); // Repeater:Lit, Comparator:Lit
|
||||
}
|
||||
} else {
|
||||
if (mat < 71) {
|
||||
if (mat == 68) return vec4(vec3(0.75), 0.0); // Vault:Inactive
|
||||
if (mat == 69) return vec4(vec3(1.3, 1.6, 1.6) * 1.0, 0.1); // Trial Spawner:Ominous:Active, Vault:Ominous:Active
|
||||
if (mat == 70) return vec4(vec3(1.0, 0.1, 0.1) * candleColorMult, candleExtraLight); // Red Candles:Lit
|
||||
} else {
|
||||
if (mat == 71) return vec4(vec3(1.0, 0.4, 0.1) * candleColorMult, candleExtraLight); // Orange Candles:Lit
|
||||
if (mat == 72) return vec4(vec3(1.0, 1.0, 0.1) * candleColorMult, candleExtraLight); // Yellow Candles:Lit
|
||||
if (mat == 73) return vec4(vec3(0.1, 1.0, 0.1) * candleColorMult, candleExtraLight); // Lime Candles:Lit
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 86) {
|
||||
if (mat < 80) {
|
||||
if (mat < 77) {
|
||||
if (mat == 74) return vec4(vec3(0.3, 1.0, 0.3) * candleColorMult, candleExtraLight); // Green Candles:Lit
|
||||
if (mat == 75) return vec4(vec3(0.3, 0.8, 1.0) * candleColorMult, candleExtraLight); // Cyan Candles:Lit
|
||||
if (mat == 76) return vec4(vec3(0.5, 0.65, 1.0) * candleColorMult, candleExtraLight); // Light Blue Candles:Lit
|
||||
} else {
|
||||
if (mat == 77) return vec4(vec3(0.1, 0.15, 1.0) * candleColorMult, candleExtraLight); // Blue Candles:Lit
|
||||
if (mat == 78) return vec4(vec3(0.7, 0.3, 1.0) * candleColorMult, candleExtraLight); // Purple Candles:Lit
|
||||
if (mat == 79) return vec4(vec3(1.0, 0.1, 1.0) * candleColorMult, candleExtraLight); // Magenta Candles:Lit
|
||||
}
|
||||
} else {
|
||||
if (mat < 83) {
|
||||
if (mat == 80) return vec4(vec3(1.0, 0.4, 1.0) * candleColorMult, candleExtraLight); // Pink Candles:Lit
|
||||
if (mat == 81) return vec4(vec3(2.8, 1.1, 0.2) * 0.125, 0.0125); // Open Eyeblossom
|
||||
if (mat == 82) return vec4(vec3(2.8, 1.1, 0.2) * 0.3, 0.05); // Creaking Heart: Active
|
||||
} else {
|
||||
if (mat == 83) return vec4(vec3(1.6, 1.6, 0.7) * 0.3, 0.05); // Firefly Bush
|
||||
if (mat == 84) return vec4(vec3(0.85, 1.3, 1.0) * 3.9, 0.0); // Copper Torch, Copper Lantern
|
||||
if (mat == 85) return vec4(0.0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 92) {
|
||||
if (mat < 89) {
|
||||
if (mat == 86) return vec4(0.0);
|
||||
if (mat == 87) return vec4(0.0);
|
||||
if (mat == 88) return vec4(0.0);
|
||||
} else {
|
||||
if (mat == 89) return vec4(0.0);
|
||||
if (mat == 90) return vec4(0.0);
|
||||
if (mat == 91) return vec4(0.0);
|
||||
}
|
||||
} else {
|
||||
if (mat < 95) {
|
||||
if (mat == 92) return vec4(0.0);
|
||||
if (mat == 93) return vec4(0.0);
|
||||
if (mat == 94) return vec4(0.0);
|
||||
} else {
|
||||
if (mat == 95) return vec4(0.0);
|
||||
if (mat == 96) return vec4(0.0);
|
||||
if (mat == 97) return vec4(vec3(1.0, 1.0, 1.0) * 4.0, candleExtraLight); // Modded White Light Source
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vec4(blocklightCol * 20.0, 0.0);
|
||||
}
|
||||
|
||||
vec3[] specialTintColor = vec3[](
|
||||
// 200: White
|
||||
vec3(1.0),
|
||||
// 201: Orange
|
||||
vec3(1.0, 0.3, 0.1),
|
||||
// 202: Magenta
|
||||
vec3(1.0, 0.1, 1.0),
|
||||
// 203: Light Blue
|
||||
vec3(0.5, 0.65, 1.0),
|
||||
// 204: Yellow
|
||||
vec3(1.0, 1.0, 0.1),
|
||||
// 205: Lime
|
||||
vec3(0.1, 1.0, 0.1),
|
||||
// 206: Pink
|
||||
vec3(1.0, 0.4, 1.0),
|
||||
// 207: Gray
|
||||
vec3(1.0),
|
||||
// 208: Light Gray
|
||||
vec3(1.0),
|
||||
// 209: Cyan
|
||||
vec3(0.3, 0.8, 1.0),
|
||||
// 210: Purple
|
||||
vec3(0.7, 0.3, 1.0),
|
||||
// 211: Blue
|
||||
vec3(0.1, 0.15, 1.0),
|
||||
// 212: Brown
|
||||
vec3(1.0, 0.75, 0.5),
|
||||
// 213: Green
|
||||
vec3(0.3, 1.0, 0.3),
|
||||
// 214: Red
|
||||
vec3(1.0, 0.1, 0.1),
|
||||
// 215: Black
|
||||
vec3(1.0),
|
||||
// 216: Ice
|
||||
vec3(0.5, 0.65, 1.0),
|
||||
// 217: Glass
|
||||
vec3(1.0),
|
||||
// 218: Glass Pane
|
||||
vec3(1.0),
|
||||
// 219++
|
||||
vec3(0.0)
|
||||
);
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
vec3 cloudRainColor = mix(nightMiddleSkyColor, dayMiddleSkyColor, sunFactor);
|
||||
|
||||
vec3 cloudAmbientColor = mix(ambientColor * (sunVisibility2 * (0.55 + vec3(0.2, 0.1, 0.0) * noonFactor) + 0.35), cloudRainColor * 0.5, rainFactor) * mix(CLOUD_NIGHT_AMBIENT_MULTIPLIER, CLOUD_AMBIENT_MULTIPLIER, sunVisibility2);
|
||||
|
||||
vec3 cloudLightColor = mix(
|
||||
lightColor * (
|
||||
1.3
|
||||
#ifdef CLOUDS_UNBOUND
|
||||
+ vec3(0.1, -0.1, -0.3) * noonFactor
|
||||
#endif
|
||||
),
|
||||
cloudRainColor * 0.45,
|
||||
noonFactor * rainFactor
|
||||
) * mix(CLOUD_NIGHT_LIGHT_MULTIPLIER, CLOUD_LIGHT_MULTIPLIER, sunVisibility2);
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#ifndef INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS
|
||||
#define INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS
|
||||
|
||||
#include "/lib/shaderSettings/colorMult.glsl"
|
||||
|
||||
vec3 GetLightColorMult() {
|
||||
vec3 lightColorMult;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 morningLightMult = vec3(LIGHT_MORNING_R, LIGHT_MORNING_G, LIGHT_MORNING_B) * LIGHT_MORNING_I;
|
||||
vec3 noonLightMult = vec3(LIGHT_NOON_R, LIGHT_NOON_G, LIGHT_NOON_B) * LIGHT_NOON_I;
|
||||
vec3 nightLightMult = vec3(LIGHT_NIGHT_R, LIGHT_NIGHT_G, LIGHT_NIGHT_B) * LIGHT_NIGHT_I;
|
||||
vec3 rainLightMult = vec3(LIGHT_RAIN_R, LIGHT_RAIN_G, LIGHT_RAIN_B) * LIGHT_RAIN_I;
|
||||
|
||||
lightColorMult = mix(noonLightMult, morningLightMult, invNoonFactor2);
|
||||
lightColorMult = mix(nightLightMult, lightColorMult, sunVisibility2);
|
||||
lightColorMult = mix(lightColorMult, dot(lightColorMult, vec3(0.33333)) * rainLightMult, rainFactor);
|
||||
#elif defined NETHER
|
||||
vec3 netherLightMult = vec3(LIGHT_NETHER_R, LIGHT_NETHER_G, LIGHT_NETHER_B) * LIGHT_NETHER_I;
|
||||
|
||||
lightColorMult = netherLightMult;
|
||||
#elif defined END
|
||||
vec3 endLightMult = vec3(LIGHT_END_R, LIGHT_END_G, LIGHT_END_B) * LIGHT_END_I;
|
||||
|
||||
lightColorMult = endLightMult;
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_MULTIPLIER_COMPARISON
|
||||
return gl_FragCoord.x < mix(0.5, 0.0, isSneaking) * viewWidth ? vec3(1.0) : lightColorMult;
|
||||
#else
|
||||
return lightColorMult;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 GetAtmColorMult() {
|
||||
vec3 atmColorMult;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
vec3 morningAtmMult = vec3(ATM_MORNING_R, ATM_MORNING_G, ATM_MORNING_B) * ATM_MORNING_I;
|
||||
vec3 noonAtmMult = vec3(ATM_NOON_R, ATM_NOON_G, ATM_NOON_B) * ATM_NOON_I;
|
||||
vec3 nightAtmMult = vec3(ATM_NIGHT_R, ATM_NIGHT_G, ATM_NIGHT_B) * ATM_NIGHT_I;
|
||||
vec3 rainAtmMult = vec3(ATM_RAIN_R, ATM_RAIN_G, ATM_RAIN_B) * ATM_RAIN_I;
|
||||
|
||||
atmColorMult = mix(noonAtmMult, morningAtmMult, invNoonFactor2);
|
||||
atmColorMult = mix(nightAtmMult, atmColorMult, sunVisibility2);
|
||||
atmColorMult = mix(atmColorMult, dot(atmColorMult, vec3(0.33333)) * rainAtmMult, rainFactor);
|
||||
#elif defined NETHER
|
||||
vec3 netherAtmMult = vec3(ATM_NETHER_R, ATM_NETHER_G, ATM_NETHER_B) * ATM_NETHER_I;
|
||||
|
||||
atmColorMult = netherAtmMult;
|
||||
#elif defined END
|
||||
vec3 endAtmMult = vec3(ATM_END_R, ATM_END_G, ATM_END_B) * ATM_END_I;
|
||||
|
||||
atmColorMult = endAtmMult;
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_MULTIPLIER_COMPARISON
|
||||
return gl_FragCoord.x < mix(0.5, 0.0, isSneaking) * viewWidth ? vec3(1.0) : atmColorMult;
|
||||
#else
|
||||
return atmColorMult;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 lightColorMult;
|
||||
vec3 atmColorMult;
|
||||
vec3 sqrtAtmColorMult;
|
||||
|
||||
#endif //INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
#ifndef INCLUDE_LIGHT_AND_AMBIENT_COLORS
|
||||
#define INCLUDE_LIGHT_AND_AMBIENT_COLORS
|
||||
|
||||
#include "/lib/shaderSettings/endBeams.glsl"
|
||||
#include "/lib/shaderSettings/lightAndAmbientColors.glsl"
|
||||
#include "/lib/shaderSettings/overworldBeams.glsl"
|
||||
|
||||
#if defined OVERWORLD
|
||||
#ifndef COMPOSITE1
|
||||
vec3 noonClearLightColor = vec3(0.65, 0.55, 0.375) * 2.05; //ground and cloud color
|
||||
#else
|
||||
vec3 noonClearLightColor = vec3(0.4, 0.75, 1.3); //light shaft color
|
||||
#endif
|
||||
vec3 noonClearAmbientColor = pow(skyColor, vec3(0.75)) * 0.85;
|
||||
|
||||
#ifndef COMPOSITE1
|
||||
vec3 sunsetClearLightColor = pow(vec3(0.64, 0.45, 0.3), vec3(1.5 + invNoonFactor)) * 5.0; //ground and cloud color
|
||||
#else
|
||||
vec3 sunsetClearLightColor = pow(vec3(0.62, 0.39, 0.24), vec3(1.5 + invNoonFactor)) * 6.8; //light shaft color
|
||||
#endif
|
||||
vec3 sunsetClearAmbientColor = noonClearAmbientColor * vec3(1.21, 0.92, 0.76) * 0.95;
|
||||
|
||||
#if !defined COMPOSITE1 && !defined DEFERRED1
|
||||
vec3 nightClearLightColor = 0.9 * vec3(0.15, 0.14, 0.20) * (0.4 + vsBrightness * 0.4); //ground color
|
||||
#elif defined DEFERRED1
|
||||
vec3 nightClearLightColor = 0.9 * vec3(0.11, 0.14, 0.20); //cloud color
|
||||
#else
|
||||
vec3 nightClearLightColor = vec3(0.08, 0.12, 0.23); //light shaft color
|
||||
#endif
|
||||
vec3 nightClearAmbientColor = 0.9 * vec3(0.09, 0.12, 0.17) * (1.55 + vsBrightness * 0.77);
|
||||
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
vec3 drlcSnowM = inSnowy * vec3(-0.06, 0.0, 0.04);
|
||||
vec3 drlcDryM = inDry * vec3(0.01, -0.035, -0.06);
|
||||
#else
|
||||
vec3 drlcSnowM = vec3(0.0), drlcDryM = vec3(0.0);
|
||||
#endif
|
||||
#if RAIN_STYLE == 2
|
||||
vec3 drlcRainMP = vec3(-0.03, 0.0, 0.02);
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
vec3 drlcRainM = inRainy * drlcRainMP;
|
||||
#else
|
||||
vec3 drlcRainM = drlcRainMP;
|
||||
#endif
|
||||
#else
|
||||
vec3 drlcRainM = vec3(0.0);
|
||||
#endif
|
||||
vec3 dayRainLightColor = vec3(0.21, 0.16, 0.13) * 0.85 + noonFactor * vec3(0.0, 0.02, 0.06)
|
||||
+ drlcRainM + drlcSnowM + drlcDryM;
|
||||
vec3 dayRainAmbientColor = vec3(0.2, 0.2, 0.25) * (1.8 + 0.5 * vsBrightness);
|
||||
|
||||
vec3 nightRainLightColor = vec3(0.03, 0.035, 0.05) * (0.5 + 0.5 * vsBrightness);
|
||||
vec3 nightRainAmbientColor = vec3(0.16, 0.20, 0.3) * (0.75 + 0.6 * vsBrightness);
|
||||
#ifndef COMPOSITE1
|
||||
float noonFactorDM = noonFactor; //ground and cloud factor
|
||||
#else
|
||||
float noonFactorDM = noonFactor * noonFactor; //light shaft factor
|
||||
#endif
|
||||
vec3 dayLightColor = mix(sunsetClearLightColor, noonClearLightColor, noonFactorDM);
|
||||
vec3 dayAmbientColor = mix(sunsetClearAmbientColor, noonClearAmbientColor, noonFactorDM);
|
||||
|
||||
vec3 clearLightColor = mix(nightClearLightColor, dayLightColor, sunVisibility2);
|
||||
vec3 clearAmbientColor = mix(nightClearAmbientColor, dayAmbientColor, sunVisibility2);
|
||||
|
||||
float rainShadowVisReduce = 0.0
|
||||
#ifdef SUN_MOON_DURING_RAIN
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
+ 0.2 * inSnowy + 0.2 * inDry
|
||||
#elif RAIN_STYLE == 2
|
||||
+ 0.2
|
||||
#endif
|
||||
#else
|
||||
+ 0.4
|
||||
#endif
|
||||
;
|
||||
|
||||
vec3 rainLightColor = mix(nightRainLightColor, dayRainLightColor * (1.0 - rainShadowVisReduce), sunVisibility2) * 2.5;
|
||||
vec3 rainAmbientColor = mix(nightRainAmbientColor, dayRainAmbientColor * (1.0 + rainShadowVisReduce), sunVisibility2);
|
||||
|
||||
vec3 lightColor = mix(clearLightColor, rainLightColor, rainFactor);
|
||||
#if SILHOUETTE == 0
|
||||
vec3 ambientColor = mix(clearAmbientColor, rainAmbientColor, rainFactor);
|
||||
#elif SILHOUETTE == 1
|
||||
vec3 ambientColor = mix(clearAmbientColor, rainAmbientColor, rainFactor) * mix(SILHOUETTE_BRIGHTNESS, 1.0, sunVisibility);
|
||||
#else
|
||||
vec3 ambientColor = mix(clearAmbientColor, rainAmbientColor, rainFactor) * SILHOUETTE_BRIGHTNESS;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD_BEAMS
|
||||
vec3 ambientColorBeam = sqrt(mix(clearAmbientColor, rainAmbientColor, rainFactor));
|
||||
vec3 ColorBeam = mix(vec3(OW_BEAM_R_NEW, OW_BEAM_G_NEW, OW_BEAM_B_NEW), ambientColorBeam, BEAMS_AMBIENT_INFLUENCE);
|
||||
#else
|
||||
vec3 ColorBeam = vec3(0.0);
|
||||
#endif
|
||||
#elif defined NETHER
|
||||
vec3 lightColor = vec3(0.0);
|
||||
vec3 ambientColor = (netherColor + 0.5 * lavaLightColor) * (0.9 + 0.45 * vsBrightness);
|
||||
#elif defined END
|
||||
float endFogLumina = dot(fogColor, vec3(0.299, 0.587, 0.114));
|
||||
vec3 endLightTempC = vec3(0.68, 0.51, 1.07); // Ensure the clamp below does not cap the max number here off... 1 year with too little blue smh
|
||||
vec3 endLightColor = clamp(mix(endLightTempC, fogColor * 0.6 + 0.3 * normalize(fogColor + 0.0001) + (0.25 - 0.25 * endFogLumina), (1.0 - inVanillaEnd) * float(END_SKY_FOG_INFLUENCE)), 0.0, 1.5);
|
||||
vec3 endOrangeCol = vec3(E_DRAGON_BEAM_R_NEW, E_DRAGON_BEAM_G_NEW, E_DRAGON_BEAM_B_NEW) * E_DRAGON_BEAM_I;
|
||||
float endLightBalancer = 0.2 * vsBrightness;
|
||||
vec3 lightColor = endLightColor * (0.35 - endLightBalancer);
|
||||
vec3 ambientTempC = endLightColor * (0.2 + endLightBalancer);
|
||||
vec3 ambientColor = mix(ambientTempC, vec3(END_AMBIENT_R_NEW, END_AMBIENT_G_NEW, END_AMBIENT_B_NEW), END_AMBIENT_INFLUENCE) * END_AMBIENT_I;
|
||||
vec3 endColorBeam = mix(vec3(E_BEAM_R_NEW, E_BEAM_G_NEW, E_BEAM_B_NEW), ambientTempC, E_BEAMS_AMBIENT_INFLUENCE);
|
||||
vec3 baseBeamPurple = normalize(endColorBeam * endColorBeam * endColorBeam) * E_BEAM_I;
|
||||
#endif
|
||||
|
||||
#endif //INCLUDE_LIGHT_AND_AMBIENT_COLORS
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#ifndef INCLUDE_MOON_PHASE_INF
|
||||
#define INCLUDE_MOON_PHASE_INF
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#if SUN_MOON_STYLE == 1
|
||||
float moonPhaseFactor = abs(moonPhase - 4.0) * 0.25;
|
||||
|
||||
float halfCheck = step(0.5, moonPhaseFactor);
|
||||
float firstHalf = mix(MOON_PHASE_DARK, MOON_PHASE_PARTIAL, smoothstep(0.0, 0.5, moonPhaseFactor));
|
||||
float secondHalf = mix(MOON_PHASE_PARTIAL, MOON_PHASE_FULL, smoothstep(0.5, 1.0, moonPhaseFactor));
|
||||
|
||||
float moonPhaseFactor2 = mix(firstHalf, secondHalf, halfCheck);
|
||||
float moonPhaseInfluence = mix(1.0, moonPhaseFactor2, 1.0 - sunVisibility2);
|
||||
#else
|
||||
float moonPhaseInfluence = mix(
|
||||
1.0,
|
||||
moonPhase == 0 ? MOON_PHASE_FULL : moonPhase != 4 ? MOON_PHASE_PARTIAL : MOON_PHASE_DARK,
|
||||
1.0 - sunVisibility2
|
||||
);
|
||||
#endif
|
||||
#else
|
||||
float moonPhaseInfluence = 1.0;
|
||||
#endif
|
||||
#endif
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#ifndef INCLUDE_SKY_COLORS
|
||||
#define INCLUDE_SKY_COLORS
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#ifdef SAVE_SKYBOX_DATA
|
||||
vec4 skyColorTexture = texelFetch(colortex14, texelCoord, 0);
|
||||
int hasCustomSky = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
|
||||
// float skyTextureLuminance = dot(skyColorTexture.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||
// float skyColorLuminance = dot(skyColor, vec3(0.2126, 0.7152, 0.0722));
|
||||
// vec3 skyColorTextureTweaked = nightFactor > 0
|
||||
// ? (skyTextureLuminance < skyColorLuminance ? skyColorTexture.rgb : skyColor)
|
||||
// : (skyTextureLuminance > skyColorLuminance ? skyColorTexture.rgb : skyColor);
|
||||
vec3 skyColorTweaked = hasCustomSky == 238 || skyColorTexture.rgb != vec3(0.0) ? skyColorTexture.rgb : skyColor;
|
||||
#else
|
||||
vec3 skyColorTweaked = skyColor;
|
||||
#endif
|
||||
|
||||
vec3 skyColorSqrt = sqrt(skyColorTweaked);
|
||||
// Doing these things because vanilla skyColor gets to 0 during a thunderstorm
|
||||
float invRainStrength2 = (1.0 - rainStrength) * (1.0 - rainStrength);
|
||||
vec3 skyColorM = mix(max(skyColorSqrt, vec3(0.63, 0.67, 0.73)), skyColorSqrt, invRainStrength2);
|
||||
vec3 skyColorM2 = mix(max(skyColorTweaked, sunFactor * vec3(0.265, 0.295, 0.35)), skyColorTweaked, invRainStrength2);
|
||||
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
vec3 nmscSnowM = inSnowy * vec3(-0.1, 0.3, 0.6);
|
||||
vec3 nmscDryM = inDry * vec3(-0.1, -0.2, -0.3);
|
||||
vec3 ndscSnowM = inSnowy * vec3(-0.25, -0.01, 0.25);
|
||||
vec3 ndscDryM = inDry * vec3(-0.05, -0.09, -0.1);
|
||||
#else
|
||||
vec3 nmscSnowM = vec3(0.0), nmscDryM = vec3(0.0), ndscSnowM = vec3(0.0), ndscDryM = vec3(0.0);
|
||||
#endif
|
||||
#if RAIN_STYLE == 2
|
||||
vec3 nmscRainMP = vec3(-0.15, 0.025, 0.1);
|
||||
vec3 ndscRainMP = vec3(-0.125, -0.005, 0.125);
|
||||
#ifdef SPECIAL_BIOME_WEATHER
|
||||
vec3 nmscRainM = inRainy * ndscRainMP;
|
||||
vec3 ndscRainM = inRainy * ndscRainMP;
|
||||
#else
|
||||
vec3 nmscRainM = ndscRainMP;
|
||||
vec3 ndscRainM = ndscRainMP;
|
||||
#endif
|
||||
#else
|
||||
vec3 nmscRainM = vec3(0.0), ndscRainM = vec3(0.0);
|
||||
#endif
|
||||
vec3 nuscWeatherM = vec3(0.1, 0.0, 0.1);
|
||||
vec3 nmscWeatherM = vec3(-0.1, -0.4, -0.6) + vec3(0.0, 0.06, 0.12) * noonFactor;
|
||||
vec3 ndscWeatherM = vec3(-0.15, -0.3, -0.42) + vec3(0.0, 0.02, 0.08) * noonFactor;
|
||||
|
||||
vec3 noonUpSkyColor = pow(skyColorM, vec3(2.9)) * (vec3(0.85, 0.92, 0.81) + rainFactor * nuscWeatherM);
|
||||
vec3 noonMiddleSkyColor = skyColorM * (vec3(1.4, 1.3, 1.3) + rainFactor * (nmscWeatherM + nmscRainM + nmscSnowM + nmscDryM))
|
||||
+ noonUpSkyColor * 0.25;
|
||||
vec3 noonDownSkyColor = skyColorM * (vec3(0.9) + rainFactor * (ndscWeatherM + ndscRainM + ndscSnowM + ndscDryM))
|
||||
+ noonUpSkyColor * 0.25;
|
||||
|
||||
vec3 sunsetUpSkyColor = skyColorM2 * (vec3(0.72, 0.522, 0.47) + vec3(0.1, 0.2, 0.35) * rainFactor2);
|
||||
vec3 sunsetMiddleSkyColor = skyColorM2 * (vec3(1.8, 1.3, 1.2) + vec3(0.15, 0.25, -0.05) * rainFactor2);
|
||||
vec3 sunsetDownSkyColorP = vec3(1.45, 0.86, 0.5) - vec3(0.8, 0.3, 0.0) * rainFactor;
|
||||
vec3 sunsetDownSkyColor = sunsetDownSkyColorP * 0.5 + 0.25 * sunsetMiddleSkyColor;
|
||||
|
||||
vec3 dayUpSkyColor = mix(noonUpSkyColor, sunsetUpSkyColor, invNoonFactor2);
|
||||
vec3 dayMiddleSkyColor = mix(noonMiddleSkyColor, sunsetMiddleSkyColor, invNoonFactor2);
|
||||
vec3 dayDownSkyColor = mix(noonDownSkyColor, sunsetDownSkyColor, invNoonFactor2);
|
||||
|
||||
vec3 nightColFactor = 0.9 * vec3(0.07, 0.14, 0.24) * (1.0 - 0.5 * rainFactor) + skyColorTweaked;
|
||||
vec3 nightUpSkyColor = pow(nightColFactor, vec3(0.90)) * 0.45;
|
||||
vec3 nightMiddleSkyColor = sqrt(nightUpSkyColor) * 0.65;
|
||||
vec3 nightDownSkyColor = nightMiddleSkyColor * vec3(0.82, 0.82, 0.88);
|
||||
#endif
|
||||
|
||||
#endif //INCLUDE_SKY_COLORS
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
vec3 DoBSLTonemap(vec3 color) {
|
||||
color = TM_EXPOSURE * color;
|
||||
color = color / pow(pow(color, vec3(TM_WHITE_CURVE)) + 1.0, vec3(1.0 / TM_WHITE_CURVE));
|
||||
color = pow(color, mix(vec3(T_LOWER_CURVE), vec3(T_UPPER_CURVE), sqrt(color)));
|
||||
|
||||
return pow(color, vec3(1.0 / 2.2));
|
||||
}
|
||||
|
||||
void linearToRGB(inout vec3 color) {
|
||||
const vec3 k = vec3(0.055);
|
||||
color = mix((vec3(1.0) + k) * pow(color, vec3(1.0 / 2.4)) - k, 12.92 * color, lessThan(color, vec3(0.0031308)));
|
||||
}
|
||||
|
||||
void doColorAdjustmentsWithoutExposure(inout vec3 color) {
|
||||
color = pow(color, mix(vec3(T_LOWER_CURVE - 0.10), vec3(T_UPPER_CURVE - 0.30), sqrt(color)));
|
||||
}
|
||||
|
||||
void doColorAdjustments(inout vec3 color) {
|
||||
color = TM_EXPOSURE * color;
|
||||
doColorAdjustmentsWithoutExposure(color);
|
||||
}
|
||||
|
||||
vec3 doSimpleTonemap(vec3 color) {
|
||||
color = TM_EXPOSURE * color;
|
||||
doColorAdjustmentsWithoutExposure(color);
|
||||
return pow(color, vec3(1.0 / 2.2));
|
||||
}
|
||||
|
||||
vec3 DoCompTonemap(inout vec3 color) {
|
||||
// Lottes tonemap modified for Complementary Shaders
|
||||
// Lottes 2016, "Advanced Techniques and Optimization of HDR Color Pipelines"
|
||||
// http://32ipi028l5q82yhj72224m8j.wpengine.netdna-cdn.com/wp-content/uploads/2016/03/GdcVdrLottes.pdf
|
||||
color = TM_EXPOSURE * color;
|
||||
|
||||
float colorMax = max(color.r, max(color.g, color.b));
|
||||
float initialLuminance = GetLuminance(color);
|
||||
|
||||
vec3 a = vec3(TM_CONTRAST); // General Contrast
|
||||
vec3 d = vec3(1.0); // Roll-off control
|
||||
vec3 hdrMax = vec3(8.0); // Maximum input brightness
|
||||
vec3 midIn = vec3(0.25); // Input middle gray
|
||||
vec3 midOut = vec3(0.25); // Output middle gray
|
||||
|
||||
vec3 a_d = a * d;
|
||||
vec3 hdrMaxA = pow(hdrMax, a);
|
||||
vec3 hdrMaxAD = pow(hdrMax, a_d);
|
||||
vec3 midInA = pow(midIn, a);
|
||||
vec3 midInAD = pow(midIn, a_d);
|
||||
vec3 HM1 = hdrMaxA * midOut;
|
||||
vec3 HM2 = hdrMaxAD - midInAD;
|
||||
|
||||
vec3 b = (-midInA + HM1) / (HM2 * midOut);
|
||||
vec3 c = (hdrMaxAD * midInA - HM1 * midInAD) / (HM2 * midOut);
|
||||
|
||||
vec3 colorOut = pow(color, a) / (pow(color, a_d) * b + c);
|
||||
|
||||
linearToRGB(colorOut);
|
||||
|
||||
// Remove tonemapping from darker colors for better readability
|
||||
const float darkLiftStart = 0.1;
|
||||
const float darkLiftMix = 0.75;
|
||||
float darkLift = smoothstep(darkLiftStart, 0.0, initialLuminance);
|
||||
vec3 smoothColor = pow(color, vec3(1.0 / 2.2));
|
||||
colorOut = mix(colorOut, smoothColor, darkLift * darkLiftMix * max0(0.55 - abs(1.05 - TM_CONTRAST)) / 0.55);
|
||||
|
||||
// Path to White
|
||||
const float wpInputCurveStart = 0.0;
|
||||
const float wpInputCurveMax = 16.0; // Increase this value to reduce the effect of white path
|
||||
float modifiedLuminance = pow(initialLuminance / wpInputCurveMax, 2.0 - TM_WHITE_PATH) * wpInputCurveMax;
|
||||
float whitePath = smoothstep(wpInputCurveStart, wpInputCurveMax, modifiedLuminance);
|
||||
colorOut = mix(colorOut, vec3(1.0), whitePath);
|
||||
|
||||
// Desaturate dark colors
|
||||
const float dpInputCurveStart = 0.1;
|
||||
const float dpInputCurveMax = 0.0;
|
||||
float desaturatePath = smoothstep(dpInputCurveStart, dpInputCurveMax, initialLuminance);
|
||||
colorOut = mix(colorOut, vec3(GetLuminance(colorOut)), desaturatePath * TM_DARK_DESATURATION);
|
||||
|
||||
doColorAdjustmentsWithoutExposure(colorOut);
|
||||
|
||||
color = clamp01(colorOut);
|
||||
return color;
|
||||
}
|
||||
|
||||
float rollOffBrightValues(vec3 color, float intensity) {
|
||||
float luminance = GetLuminance(color);
|
||||
float rolled = luminance / (1.0 + luminance * intensity);
|
||||
return rolled / max(luminance, 0.0001);
|
||||
}
|
||||
|
||||
float saturationTM = T_SATURATION;
|
||||
|
||||
vec3 LottesTonemap(vec3 color) {
|
||||
// Lottes 2016, "Advanced Techniques and Optimization of HDR Color Pipelines"
|
||||
// http://32ipi028l5q82yhj72224m8j.wpengine.netdna-cdn.com/wp-content/uploads/2016/03/GdcVdrLottes.pdf
|
||||
const vec3 a = vec3(1.3);
|
||||
const vec3 d = vec3(0.95);
|
||||
const vec3 hdrMax = vec3(8.0);
|
||||
const vec3 midIn = vec3(0.25);
|
||||
const vec3 midOut = vec3(0.25);
|
||||
|
||||
const vec3 a_d = a * d;
|
||||
const vec3 hdrMaxA = pow(hdrMax, a);
|
||||
const vec3 hdrMaxAD = pow(hdrMax, a_d);
|
||||
const vec3 midInA = pow(midIn, a);
|
||||
const vec3 midInAD = pow(midIn, a_d);
|
||||
const vec3 HM1 = hdrMaxA * midOut;
|
||||
const vec3 HM2 = hdrMaxAD - midInAD;
|
||||
|
||||
const vec3 b = (-midInA + HM1) / (HM2 * midOut);
|
||||
const vec3 c = (hdrMaxAD * midInA - HM1 * midInAD) / (HM2 * midOut);
|
||||
|
||||
color = pow(color, a) / (pow(color, a_d) * b + c);
|
||||
|
||||
doColorAdjustments(color);
|
||||
|
||||
linearToRGB(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
// From https://github.com/godotengine/godot/blob/master/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl
|
||||
// Adapted from https://github.com/TheRealMJP/BakingLab/blob/master/BakingLab/ACES.hlsl
|
||||
// (MIT License).
|
||||
vec3 ACESTonemap(vec3 color) {
|
||||
float white = ACES_WHITE;
|
||||
const float exposure_bias = ACES_EXPOSURE;
|
||||
|
||||
color *= rollOffBrightValues(color, ACES_BRIGHTNESS_ROLLOFF);
|
||||
|
||||
const float A = 0.0245786f;
|
||||
const float B = 0.000090537f;
|
||||
const float C = 0.983729f;
|
||||
const float D = 0.432951f;
|
||||
const float E = 0.238081f;
|
||||
|
||||
const mat3 rgb_to_rrt = mat3(
|
||||
vec3(0.59719f * exposure_bias, 0.35458f * exposure_bias, 0.04823f * exposure_bias),
|
||||
vec3(0.07600f * exposure_bias, 0.90834f * exposure_bias, 0.01566f * exposure_bias),
|
||||
vec3(0.02840f * exposure_bias, 0.13383f * exposure_bias, 0.83777f * exposure_bias));
|
||||
|
||||
const mat3 odt_to_rgb = mat3(
|
||||
vec3(1.60475f, -0.53108f, -0.07367f),
|
||||
vec3(-0.10208f, 1.10813f, -0.00605f),
|
||||
vec3(-0.00327f, -0.07276f, 1.07602f));
|
||||
color *= rgb_to_rrt;
|
||||
vec3 color_tonemapped = (color * (color + A) - B) / (color * (C * color + D) + E);
|
||||
color_tonemapped *= odt_to_rgb;
|
||||
|
||||
white *= exposure_bias;
|
||||
float white_tonemapped = (white * (white + A) - B) / (white * (C * white + D) + E);
|
||||
|
||||
color = color_tonemapped / white_tonemapped;
|
||||
color = clamp(color, vec3(0.0), vec3(1.0));
|
||||
doColorAdjustments(color);
|
||||
linearToRGB(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 ACESRedModified(vec3 color) {
|
||||
float white = ACES_WHITE;
|
||||
const float exposure_bias = ACES_EXPOSURE;
|
||||
|
||||
color *= rollOffBrightValues(color, ACES_BRIGHTNESS_ROLLOFF);
|
||||
|
||||
const float A = 0.0245786f;
|
||||
const float B = 0.000090537f;
|
||||
const float C = 0.983729f;
|
||||
const float D = 0.432951f;
|
||||
const float E = 0.238081f;
|
||||
|
||||
const mat3 rgb_to_rrt = mat3(
|
||||
vec3(0.50719f * exposure_bias, 0.40458f * exposure_bias, 0.03823f * exposure_bias),
|
||||
vec3(0.01300f * exposure_bias, 0.90834f * exposure_bias, 0.00966f * exposure_bias),
|
||||
vec3(0.00200f * exposure_bias, 0.15383f * exposure_bias, 0.83777f * exposure_bias));
|
||||
|
||||
const mat3 odt_to_rgb = mat3(
|
||||
vec3(1.60475f, -0.53108f, -0.07367f),
|
||||
vec3(-0.10208f, 1.10813f, -0.00605f),
|
||||
vec3(-0.00327f, -0.07276f, 1.07602f));
|
||||
color *= rgb_to_rrt;
|
||||
vec3 color_tonemapped = (color * (color + A) - B) / (color * (C * color + D) + E);
|
||||
color_tonemapped *= odt_to_rgb;
|
||||
|
||||
white *= exposure_bias;
|
||||
float white_tonemapped = (white * (white + A) - B) / (white * (C * white + D) + E);
|
||||
|
||||
color = color_tonemapped / white_tonemapped;
|
||||
color = clamp(color, vec3(0.0), vec3(1.0));
|
||||
doColorAdjustments(color);
|
||||
linearToRGB(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
// Filmic tonemapping operator made by Jim Hejl and Richard Burgess
|
||||
// Modified by Tech to not lose color information below 0.004
|
||||
vec3 BurgessTonemap(vec3 rgb) {
|
||||
rgb = rgb * min(vec3(1.0), 1.0 - 0.8 * exp(1.0/-0.004 * rgb));
|
||||
rgb = (rgb * (6.2 * rgb + 0.5)) / (rgb * (6.2 * rgb + 1.7) + 0.06);
|
||||
doColorAdjustments(rgb);
|
||||
return rgb;
|
||||
}
|
||||
|
||||
// Hable 2010, "Filmic Tonemapping Operators"
|
||||
vec3 Uncharted2(vec3 x) {
|
||||
x *= 16.0;
|
||||
const float A = 0.15;
|
||||
const float B = 0.50;
|
||||
const float C = 0.10;
|
||||
const float D = 0.20;
|
||||
const float E = 0.02;
|
||||
const float F = 0.30;
|
||||
|
||||
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
|
||||
}
|
||||
|
||||
// Filmic tonemapping operator made by John Hable for Uncharted 2
|
||||
vec3 uncharted2_tonemap_partial(vec3 color) {
|
||||
const float a = 0.15;
|
||||
const float b = 0.50;
|
||||
const float c = 0.10;
|
||||
const float d = 0.20;
|
||||
const float e = 0.02;
|
||||
const float f = 0.30;
|
||||
color = ((color * (a * color + (c * b)) + (d * e)) / (color * (a * color + b) + d * f)) - e / f;
|
||||
doColorAdjustments(color);
|
||||
linearToRGB(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 uncharted2_filmic(vec3 v) {
|
||||
float exposure_bias = 1.0f;
|
||||
vec3 curr = uncharted2_tonemap_partial(v * exposure_bias);
|
||||
|
||||
vec3 W = vec3(11.2f);
|
||||
vec3 white_scale = vec3(1.0f) / uncharted2_tonemap_partial(W);
|
||||
v = curr * white_scale;
|
||||
doColorAdjustments(v);
|
||||
linearToRGB(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vec3 reinhard2(vec3 x) {
|
||||
const float L_white = 4.0;
|
||||
linearToRGB(x);
|
||||
x = (x * (1.1 + x / (L_white * L_white))) / (1.0 + x);
|
||||
doColorAdjustments(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
vec3 filmic(vec3 x) {
|
||||
linearToRGB(x);
|
||||
vec3 X = max(vec3(0.0), x - 0.004);
|
||||
vec3 result = (X * (6.2 * X + 0.5)) / (X * (6.2 * X + 1.7) + 0.06);
|
||||
x = pow(result, vec3(2.2));
|
||||
doColorAdjustments(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
float GTTonemap(float x) { // source https://gist.github.com/shakesoda/1dcb3e159f586995ca076c8b21f05a67
|
||||
float m = 0.22; // linear section start
|
||||
float a = 1.0; // contrast
|
||||
float c = 1.33; // black brightness
|
||||
float P = 1.0; // maximum brightness
|
||||
float l = 0.4; // linear section length
|
||||
float l0 = ((P-m)*l) / a; // 0.312
|
||||
float S0 = m + l0; // 0.532
|
||||
float S1 = m + a * l0; // 0.532
|
||||
float C2 = (a*P) / (P - S1); // 2.13675213675
|
||||
float L = m + a * (x - m);
|
||||
float T = m * pow(x/m, c);
|
||||
float S = P - (P - S1) * exp(-C2*(x - S0)/P);
|
||||
float w0 = 1 - smoothstep(0.0, m, x);
|
||||
float w2 = (x < m+l)?0:1;
|
||||
float w1 = 1 - w0 - w2;
|
||||
return float(T * w0 + L * w1 + S * w2);
|
||||
}
|
||||
|
||||
// this costs about 0.2-0.3ms more than aces, as-is
|
||||
vec3 GTTonemap(vec3 x) {
|
||||
linearToRGB(x);
|
||||
x = vec3(GTTonemap(x.r), GTTonemap(x.g), GTTonemap(x.b));
|
||||
doColorAdjustments(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
vec3 uchimura(vec3 x, float P, float a, float m, float l, float c, float b) { //Uchimura, H. (2017). HDR Theory and practice. https://www.slideshare.net/nikuque/hdr-theory-and-practicce-jp; https://github.com/dmnsgn/glsl-tone-map/blob/main/uchimura.glsl
|
||||
float l0 = ((P - m) * l) / a;
|
||||
float L0 = m - m / a;
|
||||
float L1 = m + (1.0 - m) / a;
|
||||
float S0 = m + l0;
|
||||
float S1 = m + a * l0;
|
||||
float C2 = (a * P) / (P - S1);
|
||||
float CP = -C2 / P;
|
||||
|
||||
vec3 w0 = vec3(1.0 - smoothstep(0.0, m, x));
|
||||
vec3 w2 = vec3(step(m + l0, x));
|
||||
vec3 w1 = vec3(1.0 - w0 - w2);
|
||||
|
||||
vec3 T = vec3(m * pow(x / m, vec3(c)) + b);
|
||||
vec3 S = vec3(P - (P - S1) * exp(CP * (x - S0)));
|
||||
vec3 L = vec3(m + a * (x - m));
|
||||
|
||||
return T * w0 + L * w1 + S * w2;
|
||||
}
|
||||
|
||||
vec3 uchimura(vec3 color) {
|
||||
const float P = 1.0; // max display brightness
|
||||
const float a = 1.0; // contrast
|
||||
const float m = 0.22; // linear section start
|
||||
const float l = 0.4; // linear section length
|
||||
const float c = 1.33; // black
|
||||
const float b = 0.0; // pedestal
|
||||
linearToRGB(color);
|
||||
color = uchimura(color, P, a, m, l, c, b);
|
||||
doColorAdjustments(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 agxDefaultContrastApprox(vec3 x) {
|
||||
vec3 x2 = x * x;
|
||||
vec3 x4 = x2 * x2;
|
||||
|
||||
return x*(+0.12410293f
|
||||
+x*(+0.2078625f
|
||||
+x*(-5.9293431f
|
||||
+x*(+30.376821f
|
||||
+x*(-38.901506f
|
||||
+x*(+15.122061f))))));
|
||||
}
|
||||
|
||||
vec3 agx(vec3 val) {
|
||||
const mat3 agx_mat = mat3(
|
||||
0.842479062253094, 0.0423282422610123, 0.0423756549057051,
|
||||
0.0784335999999992, 0.878468636469772, 0.0784336,
|
||||
0.0792237451477643, 0.0791661274605434, 0.879142973793104);
|
||||
const float minEv = -12.47393f;
|
||||
const float maxEv = 4.026069f;
|
||||
|
||||
// Input transform
|
||||
val = agx_mat * val;
|
||||
|
||||
// Log2 space encoding
|
||||
val = clamp(log2(val), minEv, maxEv);
|
||||
val = (val - minEv) / (maxEv - minEv);
|
||||
|
||||
// Apply sigmoid function approximation
|
||||
val = agxDefaultContrastApprox(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
vec3 inv_agx(vec3 val) {
|
||||
const mat3 inv_agx_mat = mat3(
|
||||
1.1968790051201738155, -0.052896851757456180321, -0.052971635514443794537,
|
||||
-0.098020881140136776078, 1.1519031299041727435, -0.098043450117124120312,
|
||||
-0.099029744079720471434, -0.098961176844843346553, 1.1510736726411610622);
|
||||
|
||||
// Input transform
|
||||
val = inv_agx_mat * val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
vec3 agxLook(vec3 val) {
|
||||
const vec3 lw = vec3(0.2126, 0.7152, 0.0722);
|
||||
float luma = dot(val, lw);
|
||||
|
||||
vec3 offset = vec3(0.0);
|
||||
|
||||
#if AGX_LOOK == 0
|
||||
// Default
|
||||
const vec3 slope = vec3(1.0);
|
||||
const vec3 power = vec3(1.0);
|
||||
const float sat = 1.0;
|
||||
#elif AGX_LOOK == 1
|
||||
// Golden
|
||||
const vec3 slope = vec3(1.0, 0.9, 0.5);
|
||||
const vec3 power = vec3(0.8);
|
||||
const float sat = 0.8;
|
||||
#elif AGX_LOOK == 2
|
||||
// Punchy
|
||||
const vec3 slope = vec3(1.0);
|
||||
const vec3 power = vec3(1.35, 1.35, 1.35);
|
||||
const float sat = 1.4;
|
||||
#else
|
||||
const vec3 slope = vec3(AGX_R, AGX_G, AGX_B) / 256;
|
||||
const vec3 power = vec3(AGX_POWER);
|
||||
const float sat = AGX_SATURATION;
|
||||
#endif
|
||||
|
||||
// ASC CDL
|
||||
val = pow(val * slope + offset, power);
|
||||
return luma + sat * (val - luma);
|
||||
}
|
||||
|
||||
vec3 agxTonemap(vec3 color) { // Minimal version of Troy Sobotka's AgX by bwrensch https://www.shadertoy.com/view/mdcSDH
|
||||
color = agx(color);
|
||||
color = agxLook(color);
|
||||
color = inv_agx(color);
|
||||
doColorAdjustments(color);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 unreal(vec3 x) { // source: https://mini.gmshaders.com/p/tonemaps
|
||||
// Unreal 3, Documentation: "Color Grading"
|
||||
// Adapted to be close to Tonemap_ACES, with similar range
|
||||
// Gamma 2.2 correction is baked in, don't use with sRGB conversion!
|
||||
return x / (x + 0.155) * 1.019;
|
||||
}
|
||||
+1066
File diff suppressed because it is too large
Load Diff
+58
@@ -0,0 +1,58 @@
|
||||
#ifdef DEFERRED1
|
||||
#define causticsTex colortex3
|
||||
#else
|
||||
#define causticsTex gaux4
|
||||
#endif
|
||||
|
||||
float GetBlocklightCaustics(vec3 worldGeoNormal, vec3 worldPos) {
|
||||
if (isEyeInWater == 1) {
|
||||
float causticTime = frameTimeCounter * 0.045;
|
||||
mat2 rot = rotate(causticTime * 35);
|
||||
|
||||
vec3 absNormal = abs(worldGeoNormal);
|
||||
vec2 basePos = absNormal.y > max(absNormal.x, absNormal.z) ? worldPos.xz :
|
||||
absNormal.x > absNormal.z ? worldPos.yz : worldPos.xy;
|
||||
|
||||
basePos *= 1.35;
|
||||
|
||||
// Opposing directional movement for the two layers
|
||||
vec2 causticWind1 = vec2(causticTime * 0.3, causticTime * 0.15);
|
||||
vec2 causticWind2 = vec2(-causticTime * 0.17, -causticTime * 0.22);
|
||||
|
||||
vec2 cPos1 = basePos * 0.10 + causticWind1;
|
||||
vec2 cPos2 = basePos * 0.05 + causticWind2;
|
||||
|
||||
float gradientNoise = fract(52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y));
|
||||
#ifdef TAA
|
||||
gradientNoise = fract(gradientNoise + 0.618034 * mod(float(frameCounter), 3600.0));
|
||||
#endif
|
||||
|
||||
float caustic = 0.0;
|
||||
int causticSamples = 4;
|
||||
|
||||
for (int i = 0; i < causticSamples; i++) {
|
||||
vec2 offset1 = causticOffsetDist(gradientNoise + float(i), causticSamples);
|
||||
vec2 offset2 = causticOffsetDist(gradientNoise + float(i) + 0.5, causticSamples);
|
||||
|
||||
offset1 = rot * offset1;
|
||||
offset2 = rot * offset2;
|
||||
|
||||
vec4 sample1a = texture2D(causticsTex, cPos1 + offset1);
|
||||
vec4 sample1b = texture2D(causticsTex, cPos1 - offset1);
|
||||
vec4 sample2a = texture2D(causticsTex, cPos2 + offset2);
|
||||
vec4 sample2b = texture2D(causticsTex, cPos2 - offset2);
|
||||
|
||||
float caustic1 = dot(sample1a.rg - sample1b.rg, vec2(6.0));
|
||||
float caustic2 = dot(sample2a.rg - sample2b.rg, vec2(6.0));
|
||||
|
||||
caustic += caustic1 + caustic2;
|
||||
}
|
||||
|
||||
caustic /= causticSamples;
|
||||
caustic = clamp(caustic, -0.15, 2.0) * 0.52 + 0.587;
|
||||
|
||||
return caustic * WATER_CAUSTIC_STRENGTH;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#ifndef INCLUDE_CLOUD_SHADOWS
|
||||
#define INCLUDE_CLOUD_SHADOWS
|
||||
|
||||
#include "/lib/shaderSettings/cloudsAndLighting.glsl"
|
||||
#include "/lib/shaderSettings/clouds.glsl"
|
||||
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
#include "/lib/atmospherics/clouds/cloudCoord.glsl"
|
||||
#endif
|
||||
|
||||
float GetCloudShadow(vec3 playerPos) {
|
||||
#ifndef OVERWORLD
|
||||
return 1.0;
|
||||
#endif
|
||||
|
||||
float cloudShadow = 1.0;
|
||||
|
||||
vec3 worldPos = playerPos + cameraPosition;
|
||||
#if defined DO_PIXELATION_EFFECTS && defined PIXELATED_SHADOWS
|
||||
//worldPos = playerPosPixelated + cameraPosition; // Disabled for now because cloud shadows are too soft to notice pixelation
|
||||
#endif
|
||||
|
||||
#ifdef CLOUDS_REIMAGINED
|
||||
float EdotL = dot(eastVec, lightVec);
|
||||
float EdotLM = tan(acos(EdotL));
|
||||
|
||||
#if SUN_ANGLE != 0
|
||||
float NVdotLM = tan(acos(dot(northVec, lightVec)));
|
||||
#endif
|
||||
|
||||
float distToCloudLayer1 = cloudAlt1i - worldPos.y;
|
||||
vec3 cloudOffset1 = vec3(distToCloudLayer1 / EdotLM, 0.0, 0.0);
|
||||
#if SUN_ANGLE != 0
|
||||
cloudOffset1.z += distToCloudLayer1 / NVdotLM;
|
||||
#endif
|
||||
vec2 cloudPos1 = GetRoundedCloudCoord(ModifyTracePos(worldPos + cloudOffset1, cloudAlt1i).xz, CLOUD_SHADOW_ROUNDNESS);
|
||||
|
||||
#ifndef COMPOSITE
|
||||
float cloudSample = texture2D(gaux4, cloudPos1).b;
|
||||
#else
|
||||
float cloudSample = texture2D(cloudWaterTex, cloudPos1).b;
|
||||
#endif
|
||||
cloudSample *= clamp(distToCloudLayer1 * 0.1, 0.0, 1.0);
|
||||
|
||||
#ifdef DOUBLE_REIM_CLOUDS
|
||||
float distToCloudLayer2 = cloudAlt2i - worldPos.y;
|
||||
vec3 cloudOffset2 = vec3(distToCloudLayer2 / EdotLM, 0.0, 0.0);
|
||||
#if SUN_ANGLE != 0
|
||||
cloudOffset2.z += distToCloudLayer2 / NVdotLM;
|
||||
#endif
|
||||
vec2 cloudPos2 = GetRoundedCloudCoord(ModifyTracePos(worldPos + cloudOffset2, cloudAlt2i).xz, CLOUD_SHADOW_ROUNDNESS);
|
||||
|
||||
#ifndef COMPOSITE
|
||||
float cloudSample2 = texture2D(gaux4, cloudPos2).b;
|
||||
#else
|
||||
float cloudSample2 = texture2D(cloudWaterTex, cloudPos2).b;
|
||||
#endif
|
||||
cloudSample2 *= clamp(distToCloudLayer2 * 0.1, 0.0, 1.0);
|
||||
|
||||
cloudSample = 1.0 - (1.0 - cloudSample) * (1.0 - cloudSample2);
|
||||
#endif
|
||||
|
||||
cloudSample *= sqrt3(1.0 - abs(EdotL));
|
||||
cloudShadow = 1.0 - 0.85 * cloudSample;
|
||||
#else
|
||||
vec2 csPos = worldPos.xz + worldPos.y * 0.25;
|
||||
float wind = 4.0;
|
||||
#if CLOUD_SPEED_MULT == 100
|
||||
#define CLOUD_SPEED_MULT_M CLOUD_SPEED_MULT * 0.01
|
||||
wind *= syncedTimeDynamic;
|
||||
#else
|
||||
#define CLOUD_SPEED_MULT_M CLOUD_SPEED_MULT * 0.01
|
||||
wind *= frameTimeCounter * CLOUD_SPEED_MULT_M;
|
||||
#endif
|
||||
#if CLOUD_DIRECTION == 1
|
||||
csPos.xy = csPos.yx;
|
||||
#endif
|
||||
csPos.y -= wind;
|
||||
csPos *= 0.000002 * CLOUD_UNBOUND_SIZE_MULT;
|
||||
|
||||
vec2 shadowoffsets[8] = vec2[8](
|
||||
vec2( 0.0 , 1.0 ),
|
||||
vec2( 0.7071, 0.7071),
|
||||
vec2( 1.0 , 0.0 ),
|
||||
vec2( 0.7071,-0.7071),
|
||||
vec2( 0.0 ,-1.0 ),
|
||||
vec2(-0.7071,-0.7071),
|
||||
vec2(-1.0 , 0.0 ),
|
||||
vec2(-0.7071, 0.7071));
|
||||
float cloudSample = 0.0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
cloudSample += texture2DLod(noisetex, csPos + 0.005 * shadowoffsets[i], 0.0).b;
|
||||
}
|
||||
|
||||
cloudShadow = smoothstep1(pow2(min1(cloudSample * 0.2)));
|
||||
#endif
|
||||
|
||||
cloudShadow = mix(1.0, mix(cloudShadow, 1.0, NIGHT_CLOUD_UNBOUND_REMOVE * (1.0 - sunVisibility)), min1(CLOUD_TRANSPARENCY));
|
||||
cloudShadow = 1.0 - clamp01((1.0 - cloudShadow) * CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
#if CLOUD_SHADOW_FADE_DISTANCE > 0
|
||||
cloudShadow = mix(1.0, cloudShadow, clamp01(length(playerPos) / (CLOUD_SHADOW_FADE_DISTANCE * 10)));
|
||||
#endif
|
||||
|
||||
return cloudShadow;
|
||||
}
|
||||
|
||||
#endif
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#include "/lib/misc/reprojection.glsl"
|
||||
vec3 linearRGB_to_Oklab(vec3 c) {
|
||||
// Linear RGB to XYZ
|
||||
float l = 0.4122214708 * c.r + 0.5363325363 * c.g + 0.0514459929 * c.b;
|
||||
float m = 0.2119034982 * c.r + 0.6806995451 * c.g + 0.1073969566 * c.b;
|
||||
float s = 0.0883024619 * c.r + 0.2817188376 * c.g + 0.6299787005 * c.b;
|
||||
|
||||
// XYZ to Oklab
|
||||
float l_ = pow(l, 1.0/3.0);
|
||||
float m_ = pow(m, 1.0/3.0);
|
||||
float s_ = pow(s, 1.0/3.0);
|
||||
|
||||
return vec3(
|
||||
0.2104542553 * l_ + 0.7936177850 * m_ - 0.0040720468 * s_,
|
||||
1.9779984951 * l_ - 2.4285922050 * m_ + 0.4505937099 * s_,
|
||||
0.0259040371 * l_ + 0.7827717662 * m_ - 0.8086757660 * s_
|
||||
);
|
||||
}
|
||||
|
||||
vec3 Oklab_to_linearRGB(vec3 lab) {
|
||||
// Oklab to XYZ
|
||||
float l_ = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;
|
||||
float m_ = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;
|
||||
float s_ = lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z;
|
||||
|
||||
float l = l_*l_*l_;
|
||||
float m = m_*m_*m_;
|
||||
float s = s_*s_*s_;
|
||||
|
||||
// XYZ to linear RGB
|
||||
return vec3(
|
||||
+4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
||||
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
||||
-0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s
|
||||
);
|
||||
}
|
||||
|
||||
vec3 saturateMCBL(vec3 color) {
|
||||
vec3 oklab = linearRGB_to_Oklab(color);
|
||||
float L = oklab.x;
|
||||
vec2 ab = oklab.yz;
|
||||
float chroma = length(ab);
|
||||
float maxChroma = 0.11;
|
||||
float targetChroma = min(chroma * 1.7, maxChroma);
|
||||
|
||||
float chromaFactor = (chroma > 0.0001) ? min(targetChroma / chroma, 2.0) : 1.0;
|
||||
ab *= chromaFactor;
|
||||
|
||||
return Oklab_to_linearRGB(vec3(L, ab.xy));
|
||||
}
|
||||
|
||||
vec3 ApplyMultiColoredBlocklight(vec3 blocklightCol, vec3 screenPos, vec3 playerPos, float lmCoord) {
|
||||
float ACTDecider = 1.0;
|
||||
vec4 coloredLight = texture2D(colortex10, screenPos.xy);
|
||||
float lmCoordStep = step(0.1, lmCoord);
|
||||
float entityMask = 0.0;
|
||||
#if MCBL_MAIN_DEFINE == 3
|
||||
entityMask = step(0.5, sqrt3(coloredLight.a)) * lmCoordStep;
|
||||
#endif
|
||||
#if MCBL_MAIN_DEFINE == 2 && COLORED_LIGHTING_INTERNAL != 0
|
||||
vec3 absPlayerPos = abs(playerPos);
|
||||
float maxPlayerPos = max(absPlayerPos.x, max(absPlayerPos.y * 2.0, absPlayerPos.z));
|
||||
ACTDecider = pow2(min1(maxPlayerPos / min(effectiveACTdistance, far) * 2.0)); // this is to make the effect fade at the edge of ACT range
|
||||
if (entityMask < 0.5 && ACTDecider < 0.5) return blocklightCol;
|
||||
#endif
|
||||
|
||||
vec3 cameraOffset = cameraPosition - previousCameraPosition;
|
||||
cameraOffset *= float(screenPos.z * 2.0 - 1.0 > 0.56);
|
||||
|
||||
if (screenPos.z > 0.56) {
|
||||
screenPos.xy = Reprojection(screenPos, cameraOffset);
|
||||
}
|
||||
|
||||
coloredLight.rgb = saturateMCBL(coloredLight.rgb); // make colors pop!
|
||||
|
||||
vec3 coloredLightNormalized = normalize(coloredLight.rgb + 0.00001);
|
||||
|
||||
// do luminance correction for a seamless transition from the default blocklight color
|
||||
coloredLightNormalized *= GetLuminance(blocklightCol) / GetLuminance(coloredLightNormalized);
|
||||
|
||||
float coloredLightMix = min1((coloredLight.r + coloredLight.g + coloredLight.b) * 2048);
|
||||
coloredLightMix = mix(0, coloredLightMix, mix(ACTDecider, 1.0, entityMask));
|
||||
|
||||
// coloredLightNormalized = vec3(2,0,0);
|
||||
|
||||
|
||||
return mix(blocklightCol, coloredLightNormalized, coloredLightMix * clamp01(MCBL_INFLUENCE) * (1.0 - float(isnan(coloredLightNormalized))) * max(sign(lmCoord), 0.0));
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// GGX area light approximation from Horizon Zero Dawn
|
||||
float GetNoHSquared(float radiusTan, float NoL, float NoV, float VoL) {
|
||||
float radiusCos = 1.0 / sqrt(1.0 + radiusTan * radiusTan);
|
||||
|
||||
float RoL = 2.0 * NoL * NoV - VoL;
|
||||
if (RoL >= radiusCos)
|
||||
return 1.0;
|
||||
|
||||
float rOverLengthT = radiusCos * radiusTan / sqrt(1.0 - RoL * RoL);
|
||||
float NoTr = rOverLengthT * (NoV - RoL * NoL);
|
||||
float VoTr = rOverLengthT * (2.0 * NoV * NoV - 1.0 - RoL * VoL);
|
||||
|
||||
float triple = sqrt(clamp(1.0 - NoL * NoL - NoV * NoV - VoL * VoL + 2.0 * NoL * NoV * VoL, 0.0, 1.0));
|
||||
|
||||
float NoBr = rOverLengthT * triple, VoBr = rOverLengthT * (2.0 * triple * NoV);
|
||||
float NoLVTr = NoL * radiusCos + NoV + NoTr, VoLVTr = VoL * radiusCos + 1.0 + VoTr;
|
||||
float p = NoBr * VoLVTr, q = NoLVTr * VoLVTr, s = VoBr * NoLVTr;
|
||||
float xNum = q * (-0.5 * p + 0.25 * VoBr * NoLVTr);
|
||||
float xDenom = p * p + s * ((s - 2.0 * p)) + NoLVTr * ((NoL * radiusCos + NoV) * VoLVTr * VoLVTr +
|
||||
q * (-0.5 * (VoLVTr + VoL * radiusCos) - 0.5));
|
||||
float twoX1 = 2.0 * xNum / (xDenom * xDenom + xNum * xNum);
|
||||
float sinTheta = twoX1 * xDenom;
|
||||
float cosTheta = 1.0 - twoX1 * xNum;
|
||||
NoTr = cosTheta * NoTr + sinTheta * NoBr;
|
||||
VoTr = cosTheta * VoTr + sinTheta * VoBr;
|
||||
|
||||
float newNoL = NoL * radiusCos + NoTr;
|
||||
float newVoL = VoL * radiusCos + VoTr;
|
||||
float NoH = NoV + newNoL;
|
||||
float HoH = 2.0 * newVoL + 2.0;
|
||||
return clamp(NoH * NoH / HoH, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float GGX(vec3 normalM, vec3 viewPos, vec3 lightVec, float NdotLmax0, float smoothnessG, float f0) {
|
||||
smoothnessG = sqrt1(smoothnessG * 0.9 + 0.1);
|
||||
float roughnessP = (1.35 - smoothnessG);
|
||||
float roughness = pow2(pow2(roughnessP));
|
||||
|
||||
vec3 halfVec = normalize(lightVec - viewPos);
|
||||
|
||||
float dotLH = clamp(dot(halfVec, lightVec), 0.0, 1.0);
|
||||
float dotNV = dot(normalM, -viewPos);
|
||||
|
||||
#if WATER_REFLECT_QUALITY >= 2
|
||||
float dotNH = GetNoHSquared(0.01, NdotLmax0, dotNV, dot(-viewPos, lightVec));
|
||||
#else
|
||||
float dotNH = pow2(min1(2.0 * NdotLmax0 * dotNV * length(halfVec) - dot(-viewPos, lightVec)));
|
||||
#endif
|
||||
|
||||
float denom = dotNH * roughness - dotNH + 1.0;
|
||||
float D = roughness / (3.141592653589793 * pow2(denom));
|
||||
float F = exp2((-5.55473 * dotLH - 6.98316) * dotLH) * (1.0 - f0) + f0;
|
||||
|
||||
float NdotLmax0M = sqrt3(NdotLmax0 * max0(dot(normal, lightVec)));
|
||||
float specular = max0(NdotLmax0M * D * F / pow2(dotLH));
|
||||
specular = specular / (0.125 * specular + 1.0);
|
||||
|
||||
return specular;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
float getHeldLightFlicker() {
|
||||
vec2 flickerNoiseHand = texture2DLod(noisetex, vec2(frameTimeCounter * 0.06), 0.0).rb;
|
||||
float flickerMix = mix(1.0, min1(max(flickerNoiseHand.r, flickerNoiseHand.g) * 1.7), pow2(HAND_BLOCKLIGHT_FLICKERING * 0.1));
|
||||
|
||||
return flickerMix;
|
||||
}
|
||||
|
||||
void getHeldLight(out float heldLight, out float heldLight2) {
|
||||
heldLight = heldBlockLightValue;
|
||||
heldLight2 = heldBlockLightValue2;
|
||||
|
||||
#ifndef IS_IRIS
|
||||
if (heldLight > 15.1) heldLight = 0.0;
|
||||
if (heldLight2 > 15.1) heldLight2 = 0.0;
|
||||
#endif
|
||||
|
||||
if (heldItemId == 45032) heldLight = 15; // Lava Bucket
|
||||
if (heldItemId2 == 45032) heldLight2 = 15;
|
||||
}
|
||||
|
||||
vec3 GetHeldLighting(vec3 playerPos, vec3 color, inout float emission, vec3 worldGeoNormal, vec3 normalM, vec3 viewPos) {
|
||||
float heldLight = 0; float heldLight2 = 0;
|
||||
getHeldLight(heldLight, heldLight2);
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL == 0
|
||||
vec3 heldLightCol = blocklightCol; vec3 heldLightCol2 = blocklightCol;
|
||||
#else
|
||||
vec3 heldLightCol = GetSpecialBlocklightColor(heldItemId - 44000).rgb;
|
||||
vec3 heldLightCol2 = GetSpecialBlocklightColor(heldItemId2 - 44000).rgb;
|
||||
|
||||
if (heldItemId == 45032) heldLightCol = lavaSpecialLightColor.rgb; // Lava Bucket
|
||||
if (heldItemId2 == 45032) heldLightCol2 = lavaSpecialLightColor.rgb;
|
||||
|
||||
#if COLORED_LIGHT_SATURATION != 100
|
||||
heldLightCol = mix(blocklightCol, heldLightCol, COLORED_LIGHT_SATURATION * 0.01);
|
||||
heldLightCol2 = mix(blocklightCol, heldLightCol2, COLORED_LIGHT_SATURATION * 0.01);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 playerPosLightM = playerPos + relativeEyePosition;
|
||||
playerPosLightM.y += 0.7;
|
||||
float lViewPosL = length(playerPosLightM) + 6.0;
|
||||
#if HELD_LIGHTING_MODE == 1
|
||||
lViewPosL *= 1.5;
|
||||
#endif
|
||||
|
||||
#ifdef SPACEAGLE17
|
||||
if (heldLight == 0 && heldLight2 == 0 && !bool(firstPersonCamera) && entityId != 50017 && !bool(is_invisible) && currentPlayerArmor < 0.4 && bool(isOnGround)) {
|
||||
float powVal = 1.0 + 1.0 * (cos(frameTimeCounter * 1.5) * 0.5 + 0.5);
|
||||
float anim = 2.8 * max(pow(0.8, powVal), 0.12);
|
||||
heldLight = anim;
|
||||
heldLight2 = anim;
|
||||
heldLightCol = vec3(0.2392, 0.8235, 0.8667);
|
||||
heldLightCol2 = vec3(0.2392, 0.8235, 0.8667);
|
||||
playerPosLightM.y += 0.8;
|
||||
lViewPosL = length(playerPosLightM) + 6.0;
|
||||
lViewPosL = sqrt2(lViewPosL * 0.35) * 1.2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_LIGHTMAP_NORMALS
|
||||
vec3 cameraHeldLightPos = (gbufferModelView * vec4(-relativeEyePosition, 1.0)).xyz;
|
||||
cameraHeldLightPos.x += 0.66 * (float(heldLight > 0) - float(heldLight2 > 0)); // Held light position offset
|
||||
|
||||
float dirHandLightmap = clamp01(dot(normalize(cameraHeldLightPos - viewPos), normalM));
|
||||
float dirHandLightmapMaxInfluence = DIRECTIONAL_LIGHTMAP_NORMALS_HANDHELD_STRENGTH * 0.25;
|
||||
|
||||
dirHandLightmap = 2.0 * dirHandLightmap * dirHandLightmapMaxInfluence - dirHandLightmapMaxInfluence;
|
||||
dirHandLightmap = 1.0 + dirHandLightmap;
|
||||
|
||||
heldLight *= dirHandLightmap;
|
||||
heldLight2 *= dirHandLightmap;
|
||||
#endif
|
||||
|
||||
heldLight = pow2(pow2(heldLight * 0.47 / lViewPosL));
|
||||
heldLight2 = pow2(pow2(heldLight2 * 0.47 / lViewPosL));
|
||||
|
||||
vec3 heldLighting = pow2(heldLight * DoLuminanceCorrection(heldLightCol))
|
||||
+ pow2(heldLight2 * DoLuminanceCorrection(heldLightCol2));
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
AddSpecialLightDetail(heldLighting, color.rgb, emission);
|
||||
#endif
|
||||
|
||||
#if HAND_BLOCKLIGHT_FLICKERING > 0
|
||||
heldLighting *= getHeldLightFlicker();
|
||||
#endif
|
||||
|
||||
return heldLighting;
|
||||
}
|
||||
+872
@@ -0,0 +1,872 @@
|
||||
#include "/lib/shaderSettings/mainLighting.glsl"
|
||||
#include "/lib/shaderSettings/cloudsAndLighting.glsl"
|
||||
#ifdef AURORA_INFLUENCE
|
||||
#include "/lib/atmospherics/auroraBorealis.glsl"
|
||||
#endif
|
||||
|
||||
//Lighting Includes//
|
||||
#include "/lib/colors/lightAndAmbientColors.glsl"
|
||||
#include "/lib/lighting/ggx.glsl"
|
||||
#include "/lib/lighting/minimumLighting.glsl"
|
||||
|
||||
#if SHADOW_QUALITY > -1 && (defined OVERWORLD || defined END) && !defined DH_TERRAIN && !defined DH_WATER && !defined VOXY_PATCH
|
||||
#include "/lib/lighting/shadowSampling.glsl"
|
||||
#endif
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
#include "/lib/lighting/heldLighting.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef BLOCKLIGHT_CAUSTICS
|
||||
#include "/lib/lighting/blocklightCaustics.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef CLOUD_SHADOWS
|
||||
#include "/lib/lighting/cloudShadows.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
#include "/lib/colors/colorMultipliers.glsl"
|
||||
#endif
|
||||
|
||||
#if defined MOON_PHASE_INF_LIGHT || defined MOON_PHASE_INF_REFLECTION
|
||||
#include "/lib/colors/moonPhaseInfluence.glsl"
|
||||
#endif
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
#include "/lib/voxelization/lightVoxelization.glsl"
|
||||
#endif
|
||||
|
||||
#if DRAGON_DEATH_EFFECT_INTERNAL > 0
|
||||
#define ENDCRYSTAL_SAMPLER_DEFINE
|
||||
uniform isampler2D endcrystal_sampler;
|
||||
#endif
|
||||
|
||||
#ifdef PHOTONICS_LIGHTING
|
||||
#include "/lib/shaderSettings/photonics.glsl"
|
||||
#endif
|
||||
|
||||
vec3 highlightColor = normalize(pow(lightColor, vec3(0.37))) * (0.3 + 1.5 * sunVisibility2) * (1.0 - 0.85 * rainFactor);
|
||||
|
||||
//Lighting//
|
||||
void DoLighting(inout vec4 color, inout vec3 shadowMult, vec3 playerPos, vec3 viewPos, float lViewPos, vec3 geoNormal, vec3 normalM, float dither,
|
||||
vec3 worldGeoNormal, vec2 lightmap, bool noSmoothLighting, bool noDirectionalShading, bool noVanillaAO,
|
||||
bool centerShadowBias, int subsurfaceMode, float smoothnessG, float highlightMult, float emission, inout float purkinjeOverwrite, bool isLightSource,
|
||||
inout float enderDragonDead, vec3 metalHighlightTint) {
|
||||
#ifdef WORLD_CURVATURE
|
||||
playerPos.y += doWorldCurvature(playerPos.xz);
|
||||
#endif
|
||||
|
||||
vec2 oldLightmap = lightmap.xy;
|
||||
#ifdef PHOTONICS_LIGHTING
|
||||
float phRtCoverage = getPhotonicsFade(playerPos);
|
||||
#endif
|
||||
|
||||
#ifdef DO_PIXELATION_EFFECTS
|
||||
vec2 pixelationOffset = ComputeTexelOffset(tex, texCoord);
|
||||
|
||||
#if defined PIXELATED_SHADOWS || defined PIXELATED_BLOCKLIGHT
|
||||
#if PIXELATED_SHADOWS_MODE == 0
|
||||
vec3 playerPosPixelated = TexelSnap(playerPos, pixelationOffset);
|
||||
#else
|
||||
vec3 playerPosPixelated = floor((playerPos + cameraPosition) * PIXELATED_SHADOWS_MODE + 0.001) / PIXELATED_SHADOWS_MODE - cameraPosition + 0.5 / PIXELATED_SHADOWS_MODE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PIXELATED_SHADOWS
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
if (entityId == 50076) { // Boats
|
||||
playerPosPixelated.y += 0.38; // consistentBOAT2176
|
||||
}
|
||||
#endif
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (subsurfaceMode == 1) {
|
||||
playerPosPixelated.y += 0.05; // Fixes grounded foliage having dark bottom pixels depending on the random y-offset
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PIXELATED_BLOCKLIGHT
|
||||
if (!noSmoothLighting) {
|
||||
lightmap = clamp(TexelSnap(lightmap, pixelationOffset), 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float NdotN = dot(normalM, northVec);
|
||||
float absNdotN = abs(NdotN);
|
||||
float NdotE = dot(normalM, eastVec);
|
||||
float absNdotE = abs(NdotE);
|
||||
float NdotL = dot(normalM, lightVec);
|
||||
|
||||
float lightmapY2 = pow2(lightmap.y);
|
||||
float lightmapYM = smoothstep1(lightmap.y);
|
||||
float subsurfaceHighlight = 0.0;
|
||||
float ambientMult = 1.0;
|
||||
vec3 subsurfaceColor = vec3(1.0);
|
||||
#if defined AURORA_INFLUENCE && !(defined DEFERRED1 || defined COMPOSITE1)
|
||||
ambientColor = getAuroraAmbientColor(ambientColor, viewPos, 0.035, AURORA_TERRAIN_INFLUENCE_INTENSITY, 0.9);
|
||||
#endif
|
||||
|
||||
#if BLOOD_MOON > 0
|
||||
float bloodMoonFactor = getBloodMoon(sunVisibility);
|
||||
lightColor *= 1.0 + bloodMoonFactor * vec3(0.6, -0.3, -0.3);
|
||||
ambientColor *= 1.0 + bloodMoonFactor * vec3(0.6, -0.3, -0.3);
|
||||
subsurfaceColor = mix(vec3(1.0), vec3(1.3, 0.2, 0.2), bloodMoonFactor);
|
||||
#endif
|
||||
|
||||
vec3 lightColorM = lightColor;
|
||||
vec3 ambientColorM = ambientColor;
|
||||
vec3 nViewPos = normalize(viewPos);
|
||||
|
||||
#if defined LIGHT_COLOR_MULTS && !defined GBUFFERS_WATER // lightColorMult is defined early in gbuffers_water
|
||||
lightColorMult = GetLightColorMult();
|
||||
#endif
|
||||
vec2 lightningAdd = vec2(0.0);
|
||||
vec2 deathFlashAdd = vec2(0.0);
|
||||
vec3 lightningPos = vec3(0.0);
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
float lightningDistance = 550.0;
|
||||
lightningPos = getLightningPos(playerPos, lightningBoltPosition.xyz, false);
|
||||
float lightningFadeOut = max(1.0 - length(lightningPos) / lightningDistance, 0.0);
|
||||
float lightningFadeOutExp = exp((1.0 - lightningFadeOut) * -15.0);
|
||||
vec3 normalLightning = mat3(gbufferModelViewInverse) * mix(geoNormal, normalM, 0.25);
|
||||
float lightningNormalGradient = 0.12;
|
||||
if (subsurfaceMode == 1) lightningNormalGradient = mix(lightningNormalGradient, 0.45, lightningFadeOutExp);
|
||||
lightningAdd = (lightningFlashEffect(lightningPos, normalLightning, lightningDistance, lightningNormalGradient, subsurfaceMode) * 10.0 + mix(0.1, 0.0 , lightningFadeOut)) * isLightningActive();
|
||||
ambientColorM += lightningAdd.x;
|
||||
#endif
|
||||
#if DRAGON_DEATH_EFFECT_INTERNAL > 0
|
||||
vec3 dragonPosition = vec3(0, 80, 0) - cameraPosition;
|
||||
int isDying = texelFetch(endcrystal_sampler, ivec2(35, 0), 0).r;
|
||||
float dragonDeathFactor = 0.0001 * isDying;
|
||||
float deathFadeFactor = exp(-3.0 * (1.0 - dragonDeathFactor)) * dragonDeathFactor;
|
||||
|
||||
if (dragonDeathFactor < 0.99) {
|
||||
vec3 normalMDeath = mat3(gbufferModelViewInverse) * mix(geoNormal, normalM, 0.5);
|
||||
vec3 deathFlashPos = getLightningPos(playerPos, dragonPosition, true);
|
||||
float effectDistance = 800.0;
|
||||
deathFlashAdd = lightningFlashEffect(deathFlashPos, normalMDeath, effectDistance, 0.0, subsurfaceMode) * 35.0 * deathFadeFactor;
|
||||
ambientColorM *= mix(1.0, 0.0, deathFadeFactor) + deathFlashAdd.x * saturateColors(sqrt(endOrangeCol), 0.5);
|
||||
purkinjeOverwrite = 1.0 * deathFlashAdd.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined END && END_CENTER_LIGHTING > 0 && MC_VERSION >= 10900 && (defined GBUFFERS_BLOCK || defined GBUFFERS_ENTITIES || defined GBUFFERS_TERRAIN || defined GBUFFERS_HAND || defined GBUFFERS_WATER) && !defined VOXY_PATCH
|
||||
enderDragonDead = 1.0 - texelFetch(colortex5, ivec2(viewWidth-1, viewHeight-1), 0).a;
|
||||
vec3 endCenterCol = saturateColors(vec3(END_CENTER_LIGHTING_R, END_CENTER_LIGHTING_G, END_CENTER_LIGHTING_B) * 0.8, 1.1);
|
||||
vec3 endCenterPos = vec3(0.5, 60.5, 0.5) - (playerPos + cameraPositionBest);
|
||||
endCenterPos.y *= 0.66; // Make it a pill-shaped point light
|
||||
float rawDistance = length(endCenterPos);
|
||||
float endCenterLightDist = exp(-rawDistance * 0.22);
|
||||
|
||||
float endCenterTimeNoise = frameTimeCounter * 0.075;
|
||||
|
||||
// Get the direction of the noise
|
||||
float centerDistance = max(abs(endCenterPos.x), abs(endCenterPos.z)); // Square distance
|
||||
float angleOffset = endCenterTimeNoise * 0.75;
|
||||
vec2 rotatingDir = vec2(cos(angleOffset), sin(angleOffset));
|
||||
float blendFactor = smoothstep(0.5, 3.0, centerDistance); // Prevent artifacts at the center by creating square shape
|
||||
vec2 normalizedDir = mix(rotatingDir, normalize(endCenterPos.xz), blendFactor); // Blend square shape
|
||||
|
||||
vec2 endCenterNoiseBase = endCenterPos.xz * 0.03 + endCenterPos.y * 0.015;
|
||||
vec2 endCenterNoisePos = endCenterNoiseBase - normalizedDir * 0.3 + endCenterTimeNoise * 0.15;
|
||||
float endCenterIntensityNoise = texture2DLod(noisetex, endCenterNoisePos, 0.0).r;
|
||||
float endCenterNoiseVariation = sin(endCenterTimeNoise * 6.0 + dot(endCenterPos.xy, endCenterPos.yz) * 0.01);
|
||||
float endCenterNoiseIntensity = 0.7 + 0.35 * endCenterIntensityNoise + 0.2 * endCenterNoiseVariation;
|
||||
|
||||
// Hybrid lighting calculation - directional for walls, ambient for floors
|
||||
vec3 transformedNormal = mat3(gbufferModelViewInverse) * normalM;
|
||||
float normalDot = clamp01(dot(normalize(endCenterPos), transformedNormal));
|
||||
float isFloor = clamp01(dot(transformedNormal, vec3(0.0, 1.0, 0.0)) * 2.0);
|
||||
|
||||
// Strong directional lighting for walls, softer lighting for floors
|
||||
float directionalFactor = normalDot * 1.3;
|
||||
float floorFactor = 0.6 + 0.25 * normalDot;
|
||||
float endCenterLight = endCenterLightDist * mix(directionalFactor, floorFactor, isFloor);
|
||||
|
||||
ambientColorM += endCenterLight * endCenterCol * endCenterNoiseIntensity * 5.0 * enderDragonDead;
|
||||
#else
|
||||
enderDragonDead = 1.0;
|
||||
#endif
|
||||
|
||||
int oldSubsurfaceMode = subsurfaceMode;
|
||||
#if SSS_STRENGTH == 0
|
||||
subsurfaceMode = 0;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float skyLightShadowMult = pow2(pow2(lightmapY2));
|
||||
#else
|
||||
float skyLightShadowMult = 1.0;
|
||||
#endif
|
||||
|
||||
#if defined CUSTOM_PBR || defined GENERATED_NORMALS
|
||||
float NPdotU = abs(dot(geoNormal, upVec));
|
||||
#endif
|
||||
|
||||
// Shadows
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifdef GBUFFERS_WATER
|
||||
//NdotL = mix(NdotL, 1.0, 1.0 - color.a);
|
||||
#endif
|
||||
#ifdef CUSTOM_PBR
|
||||
float geoNdotL = dot(geoNormal, lightVec);
|
||||
float geoNdotLM = geoNdotL > 0.0 ? geoNdotL * 10.0 : geoNdotL;
|
||||
NdotL = min(geoNdotLM, NdotL);
|
||||
|
||||
NdotL *= 1.0 - 0.7 * (1.0 - pow2(pow2(NdotUmax0))) * NPdotU;
|
||||
#endif
|
||||
#if SHADOW_QUALITY == -1 && (defined GBUFFERS_TERRAIN || defined DH_TERRAIN || defined DH_WATER || defined VOXY_PATCH)
|
||||
if (subsurfaceMode == 1) {
|
||||
NdotU = 1.0;
|
||||
NdotUmax0 = 1.0;
|
||||
NdotL = dot(upVec, lightVec);
|
||||
} else if (subsurfaceMode == 2) {
|
||||
highlightMult *= NdotL;
|
||||
NdotL = mix(NdotL, 1.0, 0.35);
|
||||
}
|
||||
|
||||
subsurfaceMode = 0;
|
||||
#endif
|
||||
float NdotLmax0 = max0(NdotL);
|
||||
float NdotLM = NdotLmax0 * 0.9999;
|
||||
|
||||
#ifdef GBUFFERS_TEXTURED
|
||||
NdotLM = 1.0;
|
||||
#else
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (subsurfaceMode != 0) {
|
||||
#if defined CUSTOM_PBR && defined POM && POM_QUALITY >= 128 && POM_LIGHTING_MODE == 2
|
||||
shadowMult *= max(pow2(pow2(dot(normalM, geoNormal))), sqrt2(NdotLmax0));
|
||||
#endif
|
||||
NdotLM = 1.0;
|
||||
}
|
||||
#ifdef SIDE_SHADOWING
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SIDE_SHADOWING
|
||||
NdotLM = max0(NdotL + 0.4) * 0.714;
|
||||
|
||||
#ifdef END
|
||||
NdotLM = sqrt3(NdotLM);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENTITY_SHADOW == -1 && defined GBUFFERS_ENTITIES || ENTITY_SHADOW <= 1 && defined GBUFFERS_BLOCK
|
||||
lightColorM = mix(lightColorM * 0.75, ambientColorM, 0.5 * pow2(pow2(1.0 - NdotLM)));
|
||||
NdotLM = NdotLM * 0.75 + 0.25;
|
||||
#endif
|
||||
|
||||
if (shadowMult.r > 0.00001) {
|
||||
#if SHADOW_QUALITY > -1 && !defined DH_TERRAIN && !defined DH_WATER && !defined VOXY_PATCH
|
||||
if (NdotLM > 0.0001) {
|
||||
vec3 shadowMultBeforeLighting = shadowMult;
|
||||
float shadowLength = shadowDistance * 0.9166667 - lViewPos; //consistent08JJ622
|
||||
|
||||
if (shadowLength > 0.000001) {
|
||||
#if SHADOW_SMOOTHING == 4 || SHADOW_QUALITY == 0
|
||||
float offset = 0.00098;
|
||||
#elif SHADOW_SMOOTHING == 3
|
||||
float offset = 0.00075;
|
||||
#elif SHADOW_SMOOTHING == 2
|
||||
float offset = 0.0005;
|
||||
#elif SHADOW_SMOOTHING == 1
|
||||
float offset = 0.0003;
|
||||
#endif
|
||||
|
||||
vec3 playerPosM = playerPos;
|
||||
vec3 centerPlayerPos = floor(playerPos + cameraPosition + worldGeoNormal * 0.01) - cameraPosition + 0.5;
|
||||
|
||||
#if defined DO_PIXELATION_EFFECTS && defined PIXELATED_SHADOWS
|
||||
playerPosM = playerPosPixelated;
|
||||
offset *= 0.75;
|
||||
#endif
|
||||
|
||||
// Fix light leaking in caves //
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (centerShadowBias || subsurfaceMode == 1) {
|
||||
#ifdef OVERWORLD
|
||||
playerPosM = mix(centerPlayerPos, playerPosM, 0.5 + 0.5 * lightmapYM);
|
||||
#endif
|
||||
} else {
|
||||
float centerFactor = max(glColor.a, lightmapYM);
|
||||
|
||||
#if defined PERPENDICULAR_TWEAKS && SHADOW_QUALITY >= 2
|
||||
// Fake Variable Penumbra Shadows
|
||||
// Making centerFactor also work in daylight if AO gradient is facing towards sun
|
||||
if (geoNdotU > 0.99) {
|
||||
float dFdxGLCA = dFdx(glColor.a);
|
||||
float dFdyGLCA = dFdy(glColor.a);
|
||||
|
||||
if (abs(dFdxGLCA) + abs(dFdyGLCA) > 0.00001) {
|
||||
vec3 aoGradView = dFdxGLCA * normalize(dFdx(playerPos.xyz))
|
||||
+ dFdyGLCA * normalize(dFdy(playerPos.xyz));
|
||||
if (dot(normalize(aoGradView.xz), normalize(ViewToPlayer(lightVec).xz)) < 0.3 + 0.4 * dither)
|
||||
if (dot(lightVec, upVec) < 0.99999) centerFactor = sqrt1(max0(glColor.a - 0.55) / 0.45);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
playerPosM = mix(playerPosM, centerPlayerPos, 0.2 * (1.0 - pow2(pow2(centerFactor))));
|
||||
}
|
||||
#elif defined GBUFFERS_HAND
|
||||
playerPosM = mix(vec3(0.0), playerPosM, 0.2 + 0.8 * lightmapYM);
|
||||
#elif defined GBUFFERS_TEXTURED
|
||||
playerPosM = mix(centerPlayerPos, playerPosM + vec3(0.0, 0.02, 0.0), lightmapYM);
|
||||
#else
|
||||
playerPosM = mix(playerPosM, centerPlayerPos, 0.2 * (1.0 - lightmapYM));
|
||||
#endif
|
||||
|
||||
// Shadow bias without peter-panning //
|
||||
#ifndef GBUFFERS_TEXTURED
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (subsurfaceMode != 1)
|
||||
#endif
|
||||
{
|
||||
float distanceBias = pow(dot(playerPos, playerPos), 0.75);
|
||||
float NdotLmax0M = NdotLmax0;
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
NdotLmax0M = mix(NdotLmax0M, 1.0, endFlashIntensityM);
|
||||
#endif
|
||||
vec3 bias = worldGeoNormal * (0.12 + 0.0008 * distanceBias) * (2.0 - 0.95 * NdotLmax0M); // 0.95 fixes pink petals noon shadows
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
// WS752GH42G: "Water shadow outside water" fix. This calculation needs to be similar (but not the exact same) as water up-bias
|
||||
bias.y += lightmapYM * (1.0 - abs(geoNdotU)) * 0.015 * max0(lViewPos - 40.0);
|
||||
|
||||
if (subsurfaceMode == 2) {
|
||||
bias *= vec3(0.0, 0.0, -0.5);
|
||||
bias.z += 0.25 * signMidCoordPos.x * NdotE;
|
||||
}
|
||||
#endif
|
||||
|
||||
playerPosM += bias;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 shadowPos = GetShadowPos(playerPosM);
|
||||
|
||||
bool leaves = false;
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (subsurfaceMode == 0) {
|
||||
#if defined PERPENDICULAR_TWEAKS && defined SIDE_SHADOWING
|
||||
offset *= 1.0 + pow2(absNdotN);
|
||||
#endif
|
||||
} else {
|
||||
float VdotL = dot(nViewPos, lightVec);
|
||||
|
||||
float lightFactor = pow(max(VdotL, 0.0), 10.0) * float(isEyeInWater == 0);
|
||||
if (subsurfaceMode == 1) {
|
||||
offset = 0.0005235 * lightmapYM + 0.0009765;
|
||||
shadowPos.z -= max(NdotL * 0.0001, 0.0) * lightmapYM;
|
||||
subsurfaceHighlight = lightFactor * 0.8;
|
||||
#ifndef SHADOW_FILTERING
|
||||
shadowPos.z -= 0.0002;
|
||||
#endif
|
||||
} else if (subsurfaceMode == 2) {
|
||||
leaves = true;
|
||||
offset = 0.0005235 * lightmapYM + 0.0009765;
|
||||
shadowPos.z -= 0.000175 * lightmapYM;
|
||||
subsurfaceHighlight = lightFactor * 0.6;
|
||||
#ifndef SHADOW_FILTERING
|
||||
NdotLM = mix(NdotL, NdotLM, 0.5);
|
||||
#endif
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int shadowSampleBooster = int(subsurfaceMode > 0 && lViewPos < 10.0);
|
||||
#if SHADOW_QUALITY == 2 // Medium
|
||||
int shadowSamples = 2 + 2 * shadowSampleBooster;
|
||||
#elif SHADOW_QUALITY == 3 // High
|
||||
int shadowSamples = 4 + 4 * shadowSampleBooster;
|
||||
#elif SHADOW_QUALITY == 4 // Very High
|
||||
int shadowSamples = 8 + 8 * shadowSampleBooster;
|
||||
#elif SHADOW_QUALITY == 5 // Ultra
|
||||
int shadowSamples = 16 + 16 * shadowSampleBooster;
|
||||
#else
|
||||
int shadowSamples = 0;
|
||||
#endif
|
||||
|
||||
shadowMult *= GetShadow(shadowPos, lightmap.y, offset, shadowSamples, leaves, playerPos);
|
||||
}
|
||||
|
||||
float shadowSmooth = 16.0;
|
||||
if (shadowLength < shadowSmooth) {
|
||||
float shadowMixer = max0(shadowLength / shadowSmooth);
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (subsurfaceMode != 0) {
|
||||
float shadowMixerM = pow2(shadowMixer);
|
||||
|
||||
if (subsurfaceMode == 1) skyLightShadowMult *= mix(0.6 + 0.3 * pow2(noonFactor), 1.0, shadowMixerM);
|
||||
else skyLightShadowMult *= mix(NdotL * 0.4999 + 0.5, 1.0, shadowMixerM);
|
||||
|
||||
subsurfaceHighlight *= shadowMixer;
|
||||
}
|
||||
#endif
|
||||
|
||||
shadowMult = mix(vec3(skyLightShadowMult * shadowMultBeforeLighting), shadowMult, shadowMixer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if SHADOW_QUALITY == -1 || !defined VOXY_PATCH
|
||||
shadowMult *= skyLightShadowMult;
|
||||
#else
|
||||
// Screenspace shadows rendered in deferred1 of previous frame for Voxy
|
||||
// Previous frame reprojection from Chocapic13
|
||||
vec3 screenSpaceShadowPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
|
||||
vec4 viewPosPrev = vxProjInv * vec4(screenSpaceShadowPos * 2.0 - 1.0, 1.0);
|
||||
viewPosPrev /= viewPosPrev.w;
|
||||
|
||||
viewPosPrev = vxModelViewInv * viewPosPrev;
|
||||
|
||||
vec4 previousPosition = viewPosPrev + vec4(cameraPosition - previousCameraPosition, 0.0);
|
||||
previousPosition = vxModelViewPrev * previousPosition;
|
||||
previousPosition = vxProjPrev * previousPosition;
|
||||
screenSpaceShadowPos.xy = previousPosition.xy / previousPosition.w * 0.5 + 0.5;
|
||||
|
||||
float screenSpaceShadowSample = texture2D(colortex18, screenSpaceShadowPos.xy).r;
|
||||
if (screenSpaceShadowSample >= OSIEBCA) {
|
||||
if (subsurfaceMode == 1) {
|
||||
shadowMult *= 0.82 * (0.2 + 0.8 * sqrt2(max(SdotU, nightFactor)));
|
||||
} else if (subsurfaceMode == 2) {
|
||||
float baseLeafShadowMult = 1.0;
|
||||
|
||||
#ifdef LEAF_SHADOW_OPTIMISATION
|
||||
float extraLeafShadeMix = 0.25 + 0.125 * pow2(noonFactor);
|
||||
#else
|
||||
float extraLeafShadeMix = 0.125 + 0.125 * pow2(noonFactor);
|
||||
#endif
|
||||
|
||||
shadowMult *= mix(baseLeafShadowMult, NdotU, extraLeafShadeMix);
|
||||
}
|
||||
shadowMult *= screenSpaceShadowSample * skyLightShadowMult;
|
||||
} else {
|
||||
shadowMult *= skyLightShadowMult;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
shadowTime = mix(shadowTime, 1.0, endFlashIntensityM);
|
||||
#endif
|
||||
|
||||
#ifdef CLOUD_SHADOWS
|
||||
shadowMult *= GetCloudShadow(playerPos);
|
||||
#endif
|
||||
|
||||
shadowMult *= max(NdotLM * shadowTime, 0.0);
|
||||
}
|
||||
#ifdef GBUFFERS_WATER
|
||||
else { // Low Quality Water
|
||||
shadowMult = vec3(pow2(lightmapY2) * max(NdotLM * shadowTime, 0.0));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
vec3 endFlashShadowColor = END_FLASH_SHADOW * 0.12 * 0.82 + endOrangeCol * 0.18;
|
||||
shadowMult = mix(vec3(0.0), endFlashShadowColor * shadowMult, endFlashIntensityM) + 1;
|
||||
#endif
|
||||
|
||||
// Blocklight
|
||||
float lightmapXM = 0.0;
|
||||
#if defined LIGHTMAP_CURVES && !defined GBUFFERS_TEXTURED
|
||||
if (!noSmoothLighting || oldSubsurfaceMode > 0 && !isLightSource) {
|
||||
float lx4 = pow2(pow2(lightmap.x));
|
||||
float lx8 = pow2(lx4);
|
||||
float vsBrightFactor = 2.8 - 0.6 * vsBrightness + XLIGHT_CURVE;
|
||||
|
||||
float transitionFactor = ((UPPER_LIGHTMAP_CURVE * 0.1 + 0.9) - 1.0) *
|
||||
mix(1.0, 10.0, float(int(max(0.0, UPPER_LIGHTMAP_CURVE - 0.01))));
|
||||
|
||||
float transitions = (pow2(lx8) * (10 - vsBrightness) * 2 +
|
||||
lx8 * (2.8 + XLIGHT_CURVE - vsBrightness) * 0.8 +
|
||||
lx4 * (2.8 + XLIGHT_CURVE - vsBrightness * 0.7)) * transitionFactor;
|
||||
|
||||
float lightmapXMSteep = max(0.0, pow2(pow2(lightmap.x * lightmap.x)) * vsBrightFactor + transitions);
|
||||
float lightmapXMCalm = lightmap.x * (2.8 - XLIGHT_CURVE + 0.6 * vsBrightness) * LOWER_LIGHTMAP_CURVE;
|
||||
lightmapXM = pow(lightmapXMSteep + lightmapXMCalm, 2.25);
|
||||
} else {
|
||||
float xLightCurveM = XLIGHT_CURVE > 0.999 ? XLIGHT_CURVE : sqrt2(XLIGHT_CURVE);
|
||||
lightmapXM = pow(lightmap.x, 3.0 * xLightCurveM * pow2(UPPER_LIGHTMAP_CURVE)) * 10.0 * UPPER_LIGHTMAP_CURVE * (UPPER_LIGHTMAP_CURVE * 0.7 + 0.3);
|
||||
}
|
||||
#else
|
||||
if (!noSmoothLighting) {
|
||||
float lightmapXMSteep = pow2(pow2(lightmap.x * lightmap.x)) * (2.8 - 0.6 * vsBrightness + XLIGHT_CURVE);
|
||||
float lightmapXMCalm = lightmap.x * (2.8 + 0.6 * vsBrightness - XLIGHT_CURVE);
|
||||
lightmapXM = pow(lightmapXMSteep + lightmapXMCalm, 2.25);
|
||||
} else {
|
||||
float xLightCurveM = XLIGHT_CURVE > 0.999 ? XLIGHT_CURVE : sqrt2(XLIGHT_CURVE);
|
||||
lightmapXM = pow(lightmap.x, 3.0 * xLightCurveM) * 10.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
float daylightFactor = lightmapYM * invRainFactor * sunVisibility;
|
||||
emission *= 1.0 - 0.25 * daylightFactor; // Less emission under direct skylight
|
||||
|
||||
#ifdef GBUFFERS_TEXTURED
|
||||
lightmapXM *= 1.5 - 0.5 * daylightFactor; // Brighter lit particles
|
||||
#endif
|
||||
|
||||
#if defined DIRECTIONAL_LIGHTMAP_NORMALS && (defined GBUFFERS_TERRAIN || defined GBUFFERS_WATER || defined GBUFFERS_BLOCK)
|
||||
if (oldLightmap.x > 0.035 && mat != 32008) { // very specific value, do not change
|
||||
float lightmapDir = lightmapXM;
|
||||
#ifdef USE_FINE_DERIVATIVES
|
||||
vec2 dFdBlock = vec2(dFdxFine(oldLightmap.x), dFdyFine(oldLightmap.x)); // Get higher precision derivatives when available
|
||||
#else
|
||||
vec2 dFdBlock = vec2(dFdx(oldLightmap.x), dFdy(oldLightmap.x));
|
||||
#endif
|
||||
vec3 blockLightDir = vec3(0.0);
|
||||
|
||||
if (length(dFdBlock) < 1e-6) {
|
||||
vec3 blockCenterPos = floor(playerPos + cameraPosition + 0.001 * worldGeoNormal) - cameraPosition + 0.5; // + 0.001 fixes percision issues
|
||||
blockLightDir = blockCenterPos - worldGeoNormal * dot(worldGeoNormal, blockCenterPos - playerPos) - playerPos;
|
||||
blockLightDir = mat3(gbufferModelView) * blockLightDir;
|
||||
} else {
|
||||
#ifdef USE_FINE_DERIVATIVES
|
||||
blockLightDir = dFdxFine(viewPos) * dFdBlock.x + dFdyFine(viewPos) * dFdBlock.y; // Get higher precision derivatives when available
|
||||
#else
|
||||
blockLightDir = dFdx(viewPos) * dFdBlock.x + dFdy(viewPos) * dFdBlock.y;
|
||||
#endif
|
||||
}
|
||||
float dotNormal = dot(normalize(blockLightDir), normalM);
|
||||
|
||||
lightmapDir *= pow(dotNormal + 1.0, DIRECTIONAL_LIGHTMAP_NORMALS_BLOCK_STRENGTH_NEW + 0.25);
|
||||
lightmapXM = mix(lightmapXM, lightmapDir, 0.01 * max0(100.0 - lViewPos));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLOCKLIGHT_FLICKERING > 0
|
||||
vec2 flickerNoiseBlock = texture2DLod(noisetex, vec2(frameTimeCounter * 0.06), 0.0).rb;
|
||||
lightmapXM *= mix(1.0, min1(max(flickerNoiseBlock.r, flickerNoiseBlock.g) * 1.7), pow2(BLOCKLIGHT_FLICKERING * 0.1));
|
||||
#endif
|
||||
|
||||
#ifdef RANDOM_BLOCKLIGHT
|
||||
float RandR = texture2DLod(noisetex, 0.00016 * RANDOM_BLOCKLIGHT_SIZE * (playerPos.xz + cameraPosition.xz), 0.0).r * XLIGHT_R;
|
||||
float RandG = texture2DLod(noisetex, 0.00029 * RANDOM_BLOCKLIGHT_SIZE * (playerPos.xz + cameraPosition.xz), 0.0).r * XLIGHT_G;
|
||||
float RandB = texture2DLod(noisetex, 0.00034 * RANDOM_BLOCKLIGHT_SIZE * (playerPos.xz + cameraPosition.xz), 0.0).r * XLIGHT_B;
|
||||
blocklightCol = vec3(RandR, RandG, RandB) * 0.875;
|
||||
#endif
|
||||
|
||||
vec3 blockLighting = lightmapXM * blocklightCol;
|
||||
|
||||
#if defined PHOTONICS_LIGHTING && !defined GBUFFERS_WATER && !defined GBUFFERS_HAND && PHOTONICS_MAX_LIGHTS > 0
|
||||
// Keep a small vanilla fallback near camera so scenes do not go black if RT energy is weak.
|
||||
if (!isLightSource){
|
||||
blockLighting *= 1.0 - (1.0 - PHOTONICS_VANILLA_LIGHT_FALLBACK * 0.01) * phRtCoverage;
|
||||
lightmapXM *= 1.0 - (1.0 - PHOTONICS_VANILLA_LIGHT_FALLBACK * 0.01) * phRtCoverage;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
// Prepare
|
||||
#if defined GBUFFERS_HAND
|
||||
vec3 voxelPos = SceneToVoxel(vec3(0.0));
|
||||
#elif defined GBUFFERS_TEXTURED
|
||||
vec3 voxelPos = SceneToVoxel(playerPos);
|
||||
#else
|
||||
vec3 voxelPos = SceneToVoxel(playerPos);
|
||||
voxelPos = voxelPos + worldGeoNormal * 0.55; // should be close to 0.5 for ACT_CORNER_LEAK_FIX but 0.5 makes slabs flicker
|
||||
#endif
|
||||
|
||||
vec3 specialLighting = vec3(0.0);
|
||||
vec4 lightVolume = vec4(0.0);
|
||||
if (CheckInsideVoxelVolume(voxelPos)) {
|
||||
vec3 voxelPosM = clamp01(voxelPos / vec3(voxelVolumeSize));
|
||||
lightVolume = GetLightVolume(voxelPosM);
|
||||
lightVolume = sqrt(lightVolume);
|
||||
specialLighting = lightVolume.rgb;
|
||||
}
|
||||
|
||||
// Add extra articial light for blocks that request it
|
||||
lightmapXM = max(lightmapXM, mix(lightmapXM, 10.0, lightVolume.a));
|
||||
specialLighting *= 1.0 + 50.0 * lightVolume.a;
|
||||
|
||||
purkinjeOverwrite += 17.0 * lightVolume.a;
|
||||
|
||||
// Color Balance
|
||||
specialLighting = lightmapXM * 0.13 * DoLuminanceCorrection(specialLighting + blocklightCol * 0.05);
|
||||
|
||||
// Add some extra non-contrasty detail
|
||||
AddSpecialLightDetail(specialLighting, color.rgb, emission);
|
||||
|
||||
#if COLORED_LIGHT_SATURATION != 100
|
||||
specialLighting = mix(blockLighting, specialLighting, COLORED_LIGHT_SATURATION * 0.01);
|
||||
#endif
|
||||
|
||||
// Serve with distance fade
|
||||
vec3 absPlayerPosM = abs(playerPos);
|
||||
#if COLORED_LIGHTING_INTERNAL <= 512
|
||||
absPlayerPosM.y *= 2.0;
|
||||
#elif COLORED_LIGHTING_INTERNAL == 768
|
||||
absPlayerPosM.y *= 3.0;
|
||||
#elif COLORED_LIGHTING_INTERNAL == 1024
|
||||
absPlayerPosM.y *= 4.0;
|
||||
#endif
|
||||
float maxPlayerPos = max(absPlayerPosM.x, max(absPlayerPosM.y, absPlayerPosM.z));
|
||||
float blocklightDecider = pow2(min1(maxPlayerPos / effectiveACTdistance * 2.0));
|
||||
//if (heldItemId != 40000 || heldItemId2 == 40000) // Hold spider eye to see vanilla lighting
|
||||
blockLighting = mix(specialLighting, blockLighting, blocklightDecider);
|
||||
//if (heldItemId2 == 40000 && heldItemId != 40000) blockLighting = lightVolume.rgb; // Hold spider eye to see light volume
|
||||
#endif
|
||||
|
||||
#if defined END && END_CENTER_LIGHTING > 0 && MC_VERSION >= 10900 && defined END_CENTER_LIGHTING_AFFECT_BLOCKLIGHT && (defined GBUFFERS_BLOCK || defined GBUFFERS_ENTITIES || defined GBUFFERS_TERRAIN || defined GBUFFERS_HAND) && !defined VOXY_PATCH
|
||||
blockLighting = mix(blockLighting, lightmapXM * clamp01(saturateColors(endCenterCol, 1.3)), clamp01(endCenterLightDist) * enderDragonDead);
|
||||
#endif
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
#if !defined DO_PIXELATION_EFFECTS || !defined PIXELATED_BLOCKLIGHT
|
||||
vec3 playerPosForHeldLighting = playerPos;
|
||||
#else
|
||||
vec3 playerPosForHeldLighting = playerPosPixelated;
|
||||
#endif
|
||||
|
||||
#if defined PHOTONICS_LIGHTING && PHOTONICS_MAX_LIGHTS > 0 && PHOTONICS_HANDHELD_MODE != 0
|
||||
vec3 vanillaHeldLighting = GetHeldLighting(playerPosForHeldLighting, color.rgb, emission, worldGeoNormal, normalM, viewPos);
|
||||
vec3 heldLighting = vanillaHeldLighting * (1.0 - (1.0 - PHOTONICS_VANILLA_LIGHT_FALLBACK * 0.01) * phRtCoverage);
|
||||
#else
|
||||
vec3 heldLighting = GetHeldLighting(playerPosForHeldLighting, color.rgb, emission, worldGeoNormal, normalM, viewPos);
|
||||
#endif
|
||||
|
||||
#if HAND_BLOCKLIGHT_FLICKERING > 0 && defined GBUFFERS_HAND
|
||||
float heldLightHand1 = 0, heldLightHand2 = 0;
|
||||
getHeldLight(heldLightHand1, heldLightHand2);
|
||||
emission *= mix(1.0, getHeldLightFlicker(), min1(heldLightHand1 + heldLightHand2));
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_HAND
|
||||
blockLighting *= 0.5;
|
||||
heldLighting *= 2.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 minLighting = GetMinimumLighting(lightmapYM, playerPos);
|
||||
vec3 shadowLightMult = shadowMult;
|
||||
float shadowMultFloat = min1(GetLuminance(shadowMult));
|
||||
|
||||
// Lighting Tweaks
|
||||
#ifdef OVERWORLD
|
||||
ambientMult = mix(lightmapYM, pow2(lightmapYM) * lightmapYM, rainFactor);
|
||||
|
||||
#if SHADOW_QUALITY == -1
|
||||
float tweakFactor = 1.0 + 0.6 * (1.0 - pow2(pow2(pow2(noonFactor))));
|
||||
lightColorM /= tweakFactor;
|
||||
ambientMult *= mix(tweakFactor, 1.0, 0.5 * NdotUmax0);
|
||||
#endif
|
||||
|
||||
#if AMBIENT_MULT != 100
|
||||
#if AMBIENT_MULT < 100
|
||||
#define AMBIENT_MULT_M (AMBIENT_MULT - 100) * 0.006
|
||||
vec3 shadowMultP = shadowMult / (0.1 + 0.9 * sqrt2(max0(NdotLM)));
|
||||
ambientMult *= 1.0 + pow2(pow2(max0(1.0 - dot(shadowMultP, shadowMultP)))) * AMBIENT_MULT_M *
|
||||
(0.5 + 0.2 * sunFactor + 0.8 * noonFactor) * (1.0 - rainFactor * 0.5);
|
||||
#else
|
||||
#define AMBIENT_MULT_M (AMBIENT_MULT - 100) * 0.002
|
||||
shadowLightMult = mix(shadowLightMult, vec3(1.0), AMBIENT_MULT_M * ambientMult);
|
||||
lightColorM = mix(lightColorM, GetLuminance(lightColorM) * DoLuminanceCorrection(ambientColorM), (1.0 - shadowMultFloat) * AMBIENT_MULT_M);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (isEyeInWater != 1) {
|
||||
float lxFactor = (sunVisibility2 * 0.4 + (0.6 - 0.6 * pow2(invNoonFactor))) * (6.0 - 5.0 * rainFactor);
|
||||
lxFactor *= lightmapY2 + lightmapY2 * 2.0 * pow2(shadowMultFloat);
|
||||
lxFactor = max0(lxFactor - emission * 1000000.0);
|
||||
blockLighting *= pow(lightmapXM / 60.0 + 0.001, 0.09 * lxFactor);
|
||||
|
||||
// Less light in the distance / more light closer to the camera during rain or night to simulate thicker fog
|
||||
float rainLF = 0.1 * rainFactor;
|
||||
float lightFogTweaks = 1.0 + max0(96.0 - lViewPos) * (0.002 * (1.0 - sunVisibility2) + 0.0104 * rainLF) - rainLF;
|
||||
ambientMult *= lightFogTweaks;
|
||||
lightColorM *= lightFogTweaks;
|
||||
}
|
||||
#endif
|
||||
#ifdef END
|
||||
#ifdef END_FLASHES
|
||||
vec3 worldEndFlashPosition = mat3(gbufferModelViewInverse) * endFlashPosition;
|
||||
worldEndFlashPosition = normalize(vec3(
|
||||
worldEndFlashPosition.x,
|
||||
0.15 * (END_BEAM_CENTER_ALT - playerPos.y),
|
||||
worldEndFlashPosition.z
|
||||
));
|
||||
float endFlashDirectionFactor = max0(1.0 + dot(worldGeoNormal, normalize(worldEndFlashPosition))) * 0.5;
|
||||
endFlashDirectionFactor = pow2(pow2(endFlashDirectionFactor));
|
||||
|
||||
vec3 endFlashColor = (endOrangeCol + endLightColor) * endFlashIntensityM * pow2(lightmapYM);
|
||||
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
endFlashColor *= clamp01(shadowMult - 1);
|
||||
#endif
|
||||
|
||||
ambientColorM += endFlashColor * (0.2 * endFlashDirectionFactor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_HAND
|
||||
ambientMult *= 1.3; // To improve held map visibility
|
||||
#endif
|
||||
|
||||
#if defined PHOTONICS_LIGHTING && !defined GBUFFERS_WATER && PHOTONICS_INDIRECT_INTENSITY > 0
|
||||
float photonicsAmbientLightMult = 2.0 - PHOTONICS_AMBIENT_LIGHT_MULT;
|
||||
ambientMult *= 1.0 - mix(0.0, 0.367 * photonicsAmbientLightMult, PHOTONICS_INDIRECT_INTENSITY * 0.06) * phRtCoverage;
|
||||
#endif
|
||||
|
||||
// Directional Shading
|
||||
float directionShade = 1.0;
|
||||
#ifdef DIRECTIONAL_SHADING
|
||||
if (!noDirectionalShading) {
|
||||
float absNdotE2 = pow2(absNdotE);
|
||||
|
||||
#if !defined NETHER
|
||||
float NdotUM = 0.75 + NdotU * 0.25;
|
||||
#else
|
||||
float NdotUM = 0.75 + abs(NdotU + 0.5) * 0.16666;
|
||||
#endif
|
||||
float NdotNM = 1.0 + 0.075 * absNdotN;
|
||||
float NdotEM = 1.0 - 0.1 * absNdotE2;
|
||||
directionShade = NdotUM * NdotEM * NdotNM;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
lightColorM *= 1.0 + absNdotE2 * 0.75;
|
||||
#elif defined NETHER
|
||||
directionShade *= directionShade;
|
||||
ambientColorM += lavaLightColor * pow2(absNdotN * 0.5 + max0(-NdotU)) * (0.7 + 0.35 * vsBrightness);
|
||||
#endif
|
||||
|
||||
#if defined CUSTOM_PBR || defined GENERATED_NORMALS
|
||||
float cpbrAmbFactor = NdotN * NPdotU;
|
||||
cpbrAmbFactor = 1.0 - 0.3 * cpbrAmbFactor;
|
||||
ambientColorM *= cpbrAmbFactor;
|
||||
minLighting *= cpbrAmbFactor;
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD && defined PERPENDICULAR_TWEAKS && defined SIDE_SHADOWING
|
||||
// Fake bounced light
|
||||
ambientColorM = mix(ambientColorM, lightColorM, (0.05 + 0.03 * subsurfaceMode) * absNdotN * lightmapY2);
|
||||
|
||||
// Get a bit more natural looking lighting during noon
|
||||
lightColorM *= 1.0 + max0(1.0 - subsurfaceMode) * pow(noonFactor, 20.0) * (pow2(absNdotN) * 0.8 - absNdotE2 * 0.2);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Scene Lighting Stuff
|
||||
#ifdef GBUFFERS_VOXELS
|
||||
shadowLightMult = vec3(0.0);
|
||||
#endif
|
||||
|
||||
vec3 sceneLighting = lightColorM * shadowLightMult + ambientColorM * ambientMult;
|
||||
float dotSceneLighting = dot(sceneLighting, sceneLighting);
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
blockLighting = sqrt(pow2(blockLighting) + heldLighting);
|
||||
#endif
|
||||
|
||||
blockLighting *= XLIGHT_I;
|
||||
|
||||
#if defined BLOCKLIGHT_CAUSTICS && (defined GBUFFERS_BLOCK || defined GBUFFERS_ENTITIES || defined GBUFFERS_TERRAIN || defined GBUFFERS_HAND)
|
||||
vec3 worldPos = playerPos + cameraPosition;
|
||||
#if defined DO_PIXELATION_EFFECTS && defined PIXELATED_SHADOWS
|
||||
worldPos = playerPosPixelated + cameraPosition;
|
||||
#endif
|
||||
|
||||
blockLighting *= GetBlocklightCaustics(worldGeoNormal, worldPos);
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
sceneLighting *= lightColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_LIGHT
|
||||
sceneLighting *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_VOXELS
|
||||
blockLighting = vec3(0.0);
|
||||
#endif
|
||||
|
||||
// Vanilla Ambient Occlusion
|
||||
float vanillaAO = 1.0;
|
||||
#if VANILLAAO_I > 0 && !defined GBUFFERS_VOXELS
|
||||
vanillaAO = glColor.a;
|
||||
|
||||
#if defined DO_PIXELATION_EFFECTS && defined PIXELATED_AO
|
||||
vanillaAO = TexelSnap(vanillaAO, pixelationOffset);
|
||||
#endif
|
||||
|
||||
if (subsurfaceMode != 0) vanillaAO = mix(min1(vanillaAO * 1.15), 1.0, shadowMultFloat);
|
||||
else if (!noVanillaAO) {
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
vanillaAO = min1(vanillaAO + 0.08);
|
||||
#ifdef OVERWORLD
|
||||
vanillaAO = pow(
|
||||
pow1_5(vanillaAO),
|
||||
1.0 + dotSceneLighting * 0.02 + NdotUmax0 * (0.15 + 0.25 * pow2(noonFactor * pow2(lightmapY2)))
|
||||
);
|
||||
#elif defined NETHER
|
||||
vanillaAO = pow(
|
||||
pow1_5(vanillaAO),
|
||||
1.0 + NdotUmax0 * 0.5
|
||||
);
|
||||
#else
|
||||
vanillaAO = pow(
|
||||
vanillaAO,
|
||||
0.75 + NdotUmax0 * 0.25
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
vanillaAO = vanillaAO * 0.9 + 0.1;
|
||||
|
||||
#if VANILLAAO_I != 100
|
||||
#define VANILLAAO_IM VANILLAAO_I * 0.01
|
||||
vanillaAO = pow(vanillaAO, VANILLAAO_IM);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RAIN_ATMOSPHERE
|
||||
vanillaAO += lightningAdd.y * 0.1 * (-vanillaAO + 1);
|
||||
#endif
|
||||
|
||||
// Light Highlight
|
||||
vec3 lightHighlight = vec3(0.0);
|
||||
#ifdef LIGHT_HIGHLIGHT
|
||||
#ifdef BETTER_LABPBR_REFLECTIONS_INTERNAL
|
||||
float maxMetalHighlightTint = maxOf(metalHighlightTint);
|
||||
bool isHardCodedMetal = maxMetalHighlightTint < 0.999;
|
||||
float highlightF0 = isHardCodedMetal ? maxMetalHighlightTint : 0.05;
|
||||
highlightMult = isHardCodedMetal ? 1.0 : highlightMult;
|
||||
#else
|
||||
float highlightF0 = 0.05;
|
||||
#endif
|
||||
float specularHighlight = GGX(normalM, nViewPos, lightVec, NdotLmax0, smoothnessG, highlightF0);
|
||||
|
||||
specularHighlight *= highlightMult;
|
||||
|
||||
lightHighlight = isEyeInWater != 1 ? shadowMult : pow(shadowMult, vec3(0.25)) * 0.35;
|
||||
lightHighlight *= (subsurfaceHighlight * subsurfaceColor + specularHighlight * metalHighlightTint) * highlightColor;
|
||||
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
lightHighlight *= lightColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_REFLECTION
|
||||
lightHighlight *= pow2(moonPhaseInfluence);
|
||||
#endif
|
||||
#if BLOOD_MOON > 0
|
||||
lightHighlight *= mix(vec3(1.0), vec3(1.0, 0.1294, 0.1294), getBloodMoon(sunVisibility));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Mix Colors
|
||||
vec3 finalDiffuse = pow2(directionShade * vanillaAO) * (blockLighting + pow2(sceneLighting) + minLighting) + pow2(emission);
|
||||
finalDiffuse = sqrt(max(finalDiffuse, vec3(0.0))); // sqrt() for a bit more realistic light mix, max() to prevent NaNs
|
||||
|
||||
// Apply Lighting
|
||||
color.rgb *= finalDiffuse;
|
||||
color.rgb += lightHighlight;
|
||||
color.rgb *= pow2(1.0 - darknessLightFactor);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
vec3 GetMinimumLighting(float lightmapYM, vec3 playerPos) {
|
||||
float fadeMinLightDistance = 1.0;
|
||||
#if DISTANCE_MIN_LIGHT > 0
|
||||
float blockMinLightFadeDistance = 250;
|
||||
float distMinLightIntensity = DISTANCE_MIN_LIGHT * 0.1;
|
||||
fadeMinLightDistance = max(1.0 - length(playerPos) / blockMinLightFadeDistance, 0.0);
|
||||
fadeMinLightDistance = exp((1.0 - fadeMinLightDistance) * -15.0 * distMinLightIntensity) * (1.0 - nightVision) + nightVision;
|
||||
#endif
|
||||
|
||||
#if !defined END && CAVE_LIGHTING > 0
|
||||
vec3 minLighting = vec3(0.005625 + vsBrightness * 0.043) * fadeMinLightDistance;
|
||||
#if CAVE_LIGHTING != 100
|
||||
#define CAVE_LIGHTING_M CAVE_LIGHTING * 0.01
|
||||
minLighting *= CAVE_LIGHTING_M;
|
||||
#endif
|
||||
minLighting *= vec3(0.45, 0.475, 0.6);
|
||||
minLighting *= 1.0 - lightmapYM;
|
||||
#else
|
||||
vec3 minLighting = vec3(0.0);
|
||||
#endif
|
||||
|
||||
minLighting += nightVision * vec3(0.5, 0.5, 0.75);
|
||||
|
||||
return max(minLighting, vec3(0.0));
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
vec3 GetShadowPos(vec3 playerPos) {
|
||||
vec3 shadowPos = PlayerToShadow(playerPos);
|
||||
float distb = sqrt(shadowPos.x * shadowPos.x + shadowPos.y * shadowPos.y);
|
||||
float distortFactor = distb * shadowMapBias + (1.0 - shadowMapBias);
|
||||
shadowPos.xy /= distortFactor;
|
||||
shadowPos.z *= 0.2;
|
||||
return shadowPos * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
#ifndef COMPOSITE1
|
||||
vec3 SampleShadow(vec3 shadowPos, float colorMult, float colorPow) {
|
||||
float shadow0 = shadow2D(shadowtex0, vec3(shadowPos.st, shadowPos.z)).x;
|
||||
|
||||
vec3 shadowcol = vec3(0.0);
|
||||
if (shadow0 < 1.0) {
|
||||
float shadow1 = shadow2D(shadowtex1, vec3(shadowPos.st, shadowPos.z)).x;
|
||||
|
||||
if (shadow1 * 0.9999 > shadow0)
|
||||
{
|
||||
shadowcol = texture2D(shadowcolor0, shadowPos.st).rgb * shadow1;
|
||||
|
||||
shadowcol *= colorMult;
|
||||
shadowcol = pow(shadowcol, vec3(colorPow));
|
||||
}
|
||||
}
|
||||
|
||||
return shadowcol * (1.0 - shadow0) + shadow0;
|
||||
}
|
||||
|
||||
float InterleavedGradientNoiseForShadows() {
|
||||
float n = 52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y);
|
||||
#if !defined GBUFFERS_ENTITIES && !defined GBUFFERS_HAND && !defined GBUFFERS_TEXTURED && defined TAA
|
||||
return fract(n + goldenRatio * mod(float(frameCounter), 3600.0));
|
||||
#else
|
||||
return fract(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec2 offsetDist(float x, int s) {
|
||||
float n = fract(x * 2.427) * 3.1415;
|
||||
return vec2(cos(n), sin(n)) * 1.4 * x / s;
|
||||
}
|
||||
|
||||
vec3 SampleTAAFilteredShadow(vec3 shadowPos, float offset, int shadowSamples, bool leaves, float colorMult, float colorPow) {
|
||||
vec3 shadow = vec3(0.0);
|
||||
float gradientNoise = InterleavedGradientNoiseForShadows();
|
||||
|
||||
#if !defined GBUFFERS_ENTITIES && !defined GBUFFERS_HAND && !defined GBUFFERS_TEXTURED
|
||||
offset *= 1.3875;
|
||||
#else
|
||||
shadowSamples *= 2;
|
||||
offset *= 0.69375;
|
||||
#endif
|
||||
|
||||
float shadowPosZM = shadowPos.z;
|
||||
for (int i = 0; i < shadowSamples; i++) {
|
||||
vec2 offset2 = offsetDist(gradientNoise + i, shadowSamples) * offset;
|
||||
if (leaves) shadowPosZM = shadowPos.z - 0.12 * offset * (gradientNoise + i) / shadowSamples;
|
||||
shadow += SampleShadow(vec3(shadowPos.st + offset2, shadowPosZM), colorMult, colorPow);
|
||||
shadow += SampleShadow(vec3(shadowPos.st - offset2, shadowPosZM), colorMult, colorPow);
|
||||
}
|
||||
|
||||
shadow /= shadowSamples * 2.0;
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
vec2 shadowOffsets[4] = vec2[4](
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0, 1.0),
|
||||
vec2(-1.0, 0.0),
|
||||
vec2( 0.0,-1.0));
|
||||
|
||||
vec3 SampleFilteredShadow(vec3 shadowPos, float offset, float colorMult, float colorPow) {
|
||||
vec3 shadow = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
shadow += SampleShadow(vec3(offset * shadowOffsets[i] + shadowPos.st, shadowPos.z), colorMult, colorPow);
|
||||
}
|
||||
shadow += SampleShadow(shadowPos, colorMult, colorPow);
|
||||
|
||||
return shadow * 0.2;
|
||||
}
|
||||
|
||||
vec3 SampleBasicFilteredShadow(vec3 shadowPos, float offset) {
|
||||
float shadow = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
shadow += shadow2D(shadowtex0, vec3(offset * shadowOffsets[i] + shadowPos.st, shadowPos.z)).x;
|
||||
}
|
||||
|
||||
return vec3(shadow * 0.25);
|
||||
}
|
||||
|
||||
vec3 GetShadow(vec3 shadowPos, float lightmapY, float offset, int shadowSamples, bool leaves, vec3 playerPos) {
|
||||
#if SHADOW_QUALITY > 0
|
||||
#if ENTITY_SHADOW <= 1 && defined GBUFFERS_BLOCK
|
||||
offset *= 4.0;
|
||||
#else
|
||||
#ifdef OVERWORLD
|
||||
offset *= 1.0 + rainFactor2
|
||||
#ifdef SUN_MOON_DURING_RAIN
|
||||
* 2.0
|
||||
#else
|
||||
* 4.0
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
offset *= 3.0;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float lightmapY2 = pow2(lightmapY);
|
||||
float lightmapY4 = pow2(lightmapY2);
|
||||
|
||||
float colorMult = 2.5 + 5.5 * pow1_5(lightmapY) + 2.0 * lightmapY2; // 423HDSS: Shadow color strength is stored 10 times lower to allow for water shadows going above 1.0
|
||||
float colorPow = mix(1.5 + 0.5 * float(isEyeInWater == 0), 0.5, lightmapY4);
|
||||
|
||||
#if defined DISTANT_HORIZONS || defined VOXY
|
||||
float horizontalDistance = length(playerPos.xz);
|
||||
float verticalDistance = abs(playerPos.y);
|
||||
float fadeEndistance = max(horizontalDistance, verticalDistance);
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float farM = far * 0.8;
|
||||
#else
|
||||
float farM = far * 0.95;
|
||||
#endif
|
||||
float fade = smoothstep(far * 0.4, far * 0.9, fadeEndistance);
|
||||
|
||||
colorMult *= mix(1.0, 0.1 + 0.99 * pow2(pow2(lightmapY4)), fade);
|
||||
colorPow *= mix(1.0, 1.0 - 0.99 * lightmapY4, fade);
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2 && defined TAA // Medium and Above
|
||||
vec3 shadow = SampleTAAFilteredShadow(shadowPos, offset, shadowSamples, leaves, colorMult, colorPow);
|
||||
#elif SHADOW_QUALITY >= 1 // Low
|
||||
vec3 shadow = SampleFilteredShadow(shadowPos, offset, colorMult, colorPow);
|
||||
#elif SHADOW_QUALITY == 0 // Very Low
|
||||
vec3 shadow = SampleBasicFilteredShadow(shadowPos, offset);
|
||||
#endif
|
||||
|
||||
return shadow;
|
||||
}
|
||||
#endif
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
if (blockEntityId < 5028) {
|
||||
if (blockEntityId < 5012) {
|
||||
if (blockEntityId < 5004) {
|
||||
if (blockEntityId == 5000) { //
|
||||
|
||||
} else { // blockEntityId < 5000
|
||||
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId == 5004) { // Signs
|
||||
noSmoothLighting = true;
|
||||
|
||||
if (glColor.r + glColor.g + glColor.b <= 2.99 || lmCoord.x > 0.999) { // Sign Text
|
||||
#include "/lib/materials/specificMaterials/others/signText.glsl"
|
||||
}
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
} else /*if (blockEntityId == 5008)*/ { // Chest
|
||||
noSmoothLighting = true;
|
||||
|
||||
smoothnessG = pow2(color.g);
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
redstoneIPBR(color.rgb, emission);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId < 5020) {
|
||||
if (blockEntityId == 5012) { // Ender Chest
|
||||
noSmoothLighting = true;
|
||||
|
||||
float factor = min(pow2(color.g), 0.25);
|
||||
smoothnessG = factor * 2.0;
|
||||
|
||||
if (color.g > color.r || color.b > color.g)
|
||||
emission = pow2(factor) * 20.0;
|
||||
emission += 0.35;
|
||||
#if SEASONS == 1 || SEASONS == 4 || defined MOSS_NOISE_INTERNAL || defined SAND_NOISE_INTERNAL
|
||||
overlayNoiseIntensity = 0.7;
|
||||
if (dot(normal, upVec) > 0.99) {
|
||||
#if SNOW_CONDITION < 2 && SNOW_CONDITION != 0
|
||||
emission = mix(emission, emission * 0.8, inSnowy);
|
||||
#elif SNOW_CONDITION == 0
|
||||
emission = mix(emission, emission * 0.8, rainFactor * inSnowy);
|
||||
#else
|
||||
emission *= 0.8;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
} else /*if (blockEntityId == 5016)*/ { // Shulker Box+, Head+, Bed+
|
||||
noSmoothLighting = true;
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.2;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId == 5020) { // Conduit
|
||||
noSmoothLighting = true;
|
||||
lmCoordM.x = 0.9;
|
||||
|
||||
if (color.b > color.r) { // Conduit:Wind, Conduit:Blue Pixels of The Eye
|
||||
emission = color.r * 16.0;
|
||||
} else if (color.r > color.b * 2.5) { // Conduit:Red Pixels of The Eye
|
||||
emission = 20.0;
|
||||
color.rgb *= vec3(1.0, 0.25, 0.1);
|
||||
}
|
||||
overlayNoiseIntensity = 0.3;
|
||||
} else /*if (blockEntityId == 5024)*/ { // End Portal, End Gateway
|
||||
#ifdef SPECIAL_PORTAL_EFFECTS
|
||||
#include "/lib/materials/specificMaterials/others/endPortalEffect.glsl"
|
||||
#endif
|
||||
overlayNoiseIntensity = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId < 5044) {
|
||||
if (blockEntityId < 5036) {
|
||||
if (blockEntityId == 5028) { // Bell
|
||||
if (color.r + color.g > color.b + 0.5) { // Bell:Golden Part
|
||||
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/stone.glsl"
|
||||
}
|
||||
} else /*if (blockEntityId == 5032)*/ { // Copper Chest+, Copper Golem+
|
||||
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId == 5036) { // Banner+
|
||||
noSmoothLighting = true;
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.2;
|
||||
#endif
|
||||
noGeneratedNormals = true;
|
||||
} else /*if (blockEntityId == 5040)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId < 5052) {
|
||||
if (blockEntityId == 5044) { //
|
||||
|
||||
} else /*if (blockEntityId == 5048)*/ { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (blockEntityId == 5052) { //
|
||||
|
||||
} else if (blockEntityId == 10548) { // Enchanting Table:Book
|
||||
smoothnessG = pow2(color.g) * 0.35;
|
||||
|
||||
if (color.b < 0.0001 && color.r > color.g) {
|
||||
emission = color.g * 3.5;
|
||||
}
|
||||
overlayNoiseIntensity = 0.3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
#ifdef POM
|
||||
#include "/lib/materials/materialMethods/pomEffects.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/materials/materialMethods/customEmission.glsl"
|
||||
|
||||
#ifdef BETTER_LABPBR_POROSITY_INTERNAL
|
||||
void ApplyLabPBRPorosity(inout vec4 color, inout float smoothnessG, inout float smoothnessD, inout float materialMask, float porosity) {
|
||||
// Same as gbuffers_terrain puddleMixer
|
||||
float skyExposure = max0(lmCoord.y * 32.0 - 31.0) * clamp((1.0 - 1.15 * lmCoord.x) * 10.0, 0.0, 1.0);
|
||||
float wetness = skyExposure * inRainy * wetnessDynamic;
|
||||
|
||||
if (wetness <= 0.0 || porosity <= 0.0) return;
|
||||
|
||||
float puddleSmoothness = sqrt(1.0 - 0.75 * porosity);
|
||||
float puddleDarkening = 0.5 * porosity + 0.17;
|
||||
|
||||
smoothnessG = mix(smoothnessG, 1.0, wetness * puddleSmoothness);
|
||||
smoothnessD = mix(smoothnessD, 1.0, wetness * puddleSmoothness);
|
||||
materialMask = max(materialMask, wetness * 0.02 * OSIEBCA * 214.0); // Minimum reflectivity as water f0
|
||||
color.rgb *= 1.0 - wetness * puddleDarkening;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GetCustomMaterials(inout vec4 color, inout vec3 normalM, inout vec2 lmCoordM, inout float NdotU, inout vec3 shadowMult, inout float smoothnessG, inout float smoothnessD, inout float highlightMult, inout float emission, inout float materialMask, inout float materialAO, vec3 viewPos, float lViewPos) {
|
||||
vec2 texCoordM = texCoord;
|
||||
|
||||
#ifdef POM
|
||||
float parallaxFade, parallaxTexDepth;
|
||||
vec2 parallaxLocalCoord;
|
||||
vec3 parallaxTraceCoordDepth;
|
||||
vec4 normalMap;
|
||||
bool skipPom = false;
|
||||
|
||||
if (!skipPom) {
|
||||
texCoordM = vTexCoord.xy * vTexCoordAM.zw + vTexCoordAM.xy;
|
||||
|
||||
parallaxFade = pow2(lViewPos / POM_DISTANCE);
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
if (entityId == 50008) parallaxFade = 1.1; // Item Frame, Glow Item Frame
|
||||
#endif
|
||||
#ifdef GBUFFERS_BLOCK
|
||||
if (blockEntityId == 5004) parallaxFade = 1.1; // Signs
|
||||
#endif
|
||||
#ifdef GBUFFERS_HAND
|
||||
if (heldItemId == 40004 || heldItemId2 == 40004) parallaxFade = 1.1; // Filled Map
|
||||
#endif
|
||||
|
||||
parallaxTraceCoordDepth = vec3(texCoordM, 1.0);
|
||||
parallaxLocalCoord = vTexCoord.st;
|
||||
|
||||
normalMap = ReadNormal(vTexCoord.st);
|
||||
parallaxFade += pow(normalMap.a, 64.0);
|
||||
|
||||
if (parallaxFade < 1.0) {
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
#ifdef TAA
|
||||
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
|
||||
#endif
|
||||
|
||||
parallaxLocalCoord = GetParallaxCoord(parallaxFade, dither, texCoordM, parallaxTexDepth, parallaxTraceCoordDepth);
|
||||
|
||||
normalMap = textureGrad(normals, texCoordM, dcdx, dcdy);
|
||||
color = textureGrad(tex, texCoordM, dcdx, dcdy);
|
||||
#if !defined GBUFFERS_ENTITIES && !defined GBUFFERS_BLOCK
|
||||
color.rgb *= glColor.rgb;
|
||||
#else
|
||||
color *= glColor;
|
||||
#endif
|
||||
|
||||
shadowMult *= GetParallaxShadow(parallaxFade, dither, normalMap.a, parallaxLocalCoord, lightVec, tbnMatrix);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Normal Map
|
||||
#if NORMAL_MAP_STRENGTH != 0
|
||||
#ifdef POM
|
||||
else normalMap = texture2D(normals, texCoordM);
|
||||
#else
|
||||
vec4 normalMap = texture2D(normals, texCoordM);
|
||||
#endif
|
||||
|
||||
materialAO = normalMap.b;
|
||||
normalM = normalMap.xyz;
|
||||
normalM += vec3(0.5, 0.5, 0.0);
|
||||
normalM = pow(normalM, vec3(NORMAL_MAP_STRENGTH * 0.007)); // 70% strength by default
|
||||
normalM -= vec3(0.5, 0.5, 0.0);
|
||||
normalM = normalM * 2.0 - 1.0;
|
||||
|
||||
#if RP_MODE == 3 // labPBR
|
||||
if (normalM.x + normalM.y > -1.999) {
|
||||
if (length(normalM.xy) > 1.0) normalM.xy = normalize(normalM.xy);
|
||||
normalM.z = sqrt(1.0 - dot(normalM.xy, normalM.xy));
|
||||
normalM.xyz = normalize(clamp(normalM.xyz, vec3(-1.0), vec3(1.0)));
|
||||
} else normalM = vec3(0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined POM && POM_QUALITY >= 128 && POM_LIGHTING_MODE == 2
|
||||
if (!skipPom) {
|
||||
float slopeThreshold = max(1.0 / POM_QUALITY, 1.0/255.0);
|
||||
if (parallaxTexDepth - parallaxTraceCoordDepth.z > slopeThreshold) {
|
||||
vec3 slopeNormal = GetParallaxSlopeNormal(parallaxLocalCoord, parallaxTraceCoordDepth.z, viewVector);
|
||||
normalM = mix(normalM, slopeNormal, 0.5 * pow2(max0(1.0 - parallaxFade * 2.0)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
normalM = clamp(normalize(normalM * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
|
||||
NdotU = dot(normalM, upVec);
|
||||
NdotUmax0 = max0(NdotU);
|
||||
#endif
|
||||
|
||||
#if DIRECTIONAL_BLOCKLIGHT > 0
|
||||
mat3 lightmapTBN = mat3(normalize(dFdx(viewPos)), normalize(dFdy(viewPos)), vec3(0.0));
|
||||
lightmapTBN[2] = cross(lightmapTBN[0], lightmapTBN[1]);
|
||||
|
||||
float lmCoordXDir = lmCoordM.x;
|
||||
vec2 deriv = vec2(dFdx(lmCoordXDir), dFdy(lmCoordXDir)) * 256.0;
|
||||
vec3 dir = normalize(vec3(deriv.x * lightmapTBN[0] +
|
||||
0.0005 * lightmapTBN[2] +
|
||||
deriv.y * lightmapTBN[1]));
|
||||
|
||||
float pwr = clamp(dot(normalM, dir), -1.0, 1.0);
|
||||
float absPwr = abs(pwr);
|
||||
if (absPwr > 0.0) pwr = pow(absPwr, 9.0 / DIRECTIONAL_BLOCKLIGHT) * sign(pwr) * lmCoordXDir;
|
||||
if (length(deriv) > 0.001) lmCoordXDir = pow(max(lmCoordXDir, 0.00001), 1.0 - pwr);
|
||||
|
||||
lmCoordM.x = mix(lmCoordM.x, lmCoordXDir, 0.01 * max0(100.0 - pow2(lViewPos)));
|
||||
#endif
|
||||
|
||||
// Specular Map
|
||||
vec4 specularMap = texture2D(specular, texCoordM);
|
||||
|
||||
#ifdef BETTER_LABPBR_REFLECTIONS_INTERNAL
|
||||
float smoothnessM = specularMap.r; // ImprPBRPow2 - Don't square it here, we want the raw smoothness value
|
||||
#else
|
||||
float smoothnessM = pow2(specularMap.r);
|
||||
#endif
|
||||
smoothnessG = smoothnessM;
|
||||
smoothnessD = smoothnessM;
|
||||
highlightMult = 1.0 + 2.5 * specularMap.r;
|
||||
|
||||
#if RP_MODE == 3 // labPBR
|
||||
highlightMult *= 0.5 + 0.5 * specularMap.g;
|
||||
#endif
|
||||
|
||||
emission = GetCustomEmission(specularMap, texCoordM);
|
||||
|
||||
#ifndef GBUFFERS_WATER
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_HAND
|
||||
if (
|
||||
materialMask > OSIEBCA * 240.1
|
||||
&& specularMap.g < 0.01
|
||||
) return;
|
||||
#endif
|
||||
|
||||
#if RP_MODE == 2 // seuspbr
|
||||
materialMask = specularMap.g * OSIEBCA * 240.0;
|
||||
#elif RP_MODE == 3 // labPBR
|
||||
if (specularMap.g < OSIEBCA * 229.1) {
|
||||
materialMask = specularMap.g * OSIEBCA * 214.0;
|
||||
} else {
|
||||
materialMask = specularMap.g - OSIEBCA * 15.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BETTER_LABPBR_POROSITY_INTERNAL
|
||||
// Blue channel: 0-64 = porosity
|
||||
float porosity = specularMap.b <= 64.0 * OSIEBCA ? specularMap.b * (255.0 / 64.0) : 0.0;
|
||||
ApplyLabPBRPorosity(color, smoothnessG, smoothnessD, materialMask, porosity);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
if (abs(materialMaskInt - 149.5) < 50.0) { // Entity Reflection Handling (see common.glsl for details)
|
||||
materialMaskInt -= 100;
|
||||
entityOrParticle = true;
|
||||
}
|
||||
|
||||
if (materialMaskInt != 0) {
|
||||
if (materialMaskInt < 9) {
|
||||
if (materialMaskInt < 5) {
|
||||
if (materialMaskInt < 3) {
|
||||
if (materialMaskInt == 1) { // Intense Fresnel
|
||||
intenseFresnel = 1.0;
|
||||
} else /*if (materialMaskInt == 2)*/ { // Copper Fresnel
|
||||
intenseFresnel = 1.0;
|
||||
reflectColor = mix(vec3(0.5, 0.75, 0.5), vec3(1.0, 0.45, 0.3), sqrt1(smoothnessD));
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt == 3) { // Gold Fresnel
|
||||
intenseFresnel = 1.0;
|
||||
reflectColor = vec3(1.0, 0.8, 0.5);
|
||||
} else /*if (materialMaskInt == 4)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt < 7) {
|
||||
if (materialMaskInt == 5) { // Redstone Fresnel
|
||||
intenseFresnel = 1.0;
|
||||
reflectColor = vec3(1.0, 0.3, 0.2);
|
||||
} else /*if (materialMaskInt == 6)*/ { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt == 7) { //
|
||||
|
||||
} else /*if (materialMaskInt == 8)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt < 13) {
|
||||
if (materialMaskInt < 11) {
|
||||
if (materialMaskInt == 9) { //
|
||||
|
||||
} else /*if (materialMaskInt == 10)*/ { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt == 11) { //
|
||||
|
||||
} else /*if (materialMaskInt == 12)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt < 15) {
|
||||
if (materialMaskInt == 13) { //
|
||||
|
||||
} else /*if (materialMaskInt == 14)*/ { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (materialMaskInt == 15) { //
|
||||
|
||||
} else { // materialMaskInt >= 16 && <= 240
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
if (materialMaskInt <= 240) {
|
||||
#ifdef IPBR
|
||||
#include "/lib/materials/materialHandling/deferredIPBR.glsl"
|
||||
#elif defined CUSTOM_PBR
|
||||
#if RP_MODE == 2 // seuspbr
|
||||
float metalness = materialMaskInt / 240.0;
|
||||
|
||||
intenseFresnel = metalness;
|
||||
#elif RP_MODE == 3 // labPBR
|
||||
float metalness = float(materialMaskInt >= 215);
|
||||
|
||||
#ifdef BETTER_LABPBR_REFLECTIONS_INTERNAL
|
||||
bool isNamedMetal = materialMaskInt >= 215 && materialMaskInt <= 222;
|
||||
vec3 physicalMetalF0 = GetLabPBRMetalF0(materialMaskInt, color.rgb);
|
||||
|
||||
// Magnitude: Handled entirely by intenseFresnel to prevent double-darkening.
|
||||
// (rawAlbedoF0 scales the blend weight magnitude here instead of tinting reflectColor below)
|
||||
float metalF0Scalar = isNamedMetal ? maxOf(physicalMetalF0) * rawAlbedoF0 : rawAlbedoF0;
|
||||
intenseFresnel = mix(materialMaskInt / 240.0, metalF0Scalar, metalness);
|
||||
isHardcodedMetal = metalness;
|
||||
|
||||
// Hue tint: Separated from brightness so it only alters color, not magnitude
|
||||
vec3 albedoHue = color.rgb / (maxOf(color.rgb) + 0.00001);
|
||||
vec3 metalF0 = isNamedMetal ? physicalMetalF0 * albedoHue : vec3(1.0);
|
||||
float metalF0TintScalar = isNamedMetal ? maxOf(metalF0) : 1.0;
|
||||
#else
|
||||
intenseFresnel = materialMaskInt / 240.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BETTER_LABPBR_REFLECTIONS_INTERNAL
|
||||
// Peak-normalize metalF0 by metalF0TintScalar to isolate pure hue/tint (max channel = 1.0)
|
||||
reflectColor = mix(vec3(1.0), isNamedMetal ? metalF0 / (metalF0TintScalar + 0.00001) : color.rgb / (maxOf(color.rgb) + 0.00001), metalness);
|
||||
#else
|
||||
reflectColor = mix(vec3(1.0), color.rgb / (maxOf(color.rgb) + 0.00001), metalness);
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
if (materialMaskInt == 251) { // No SSAO, Reduce Reflection
|
||||
entityOrParticle = true;
|
||||
} else if (materialMaskInt == 254) { // No SSAO, No TAA, Reduce Reflection
|
||||
ssao = 1.0;
|
||||
entityOrParticle = true;
|
||||
}
|
||||
}
|
||||
+506
@@ -0,0 +1,506 @@
|
||||
#include "/lib/shaderSettings/entityMaterials.glsl"
|
||||
if (entityId < 50128) { // 50000 to 50128
|
||||
if (entityId < 50064) { // 50000 to 50064
|
||||
if (entityId < 50032) { // 50000 to 50032
|
||||
if (entityId < 50016) { // 50000 to 50016
|
||||
if (entityId < 50008) { // 50000 to 50008
|
||||
if (entityId == 50000) { // End Crystal
|
||||
lmCoordM.x *= 0.7;
|
||||
|
||||
if (color.g * 1.2 < color.r) {
|
||||
emission = 12.0 * color.g;
|
||||
color.r *= 1.1;
|
||||
}
|
||||
emission *= END_CRYSTAL_EMISSION;
|
||||
} else if (entityId == 50004) { // Lightning Bolt
|
||||
#include "/lib/materials/specificMaterials/others/lightningBolt.glsl"
|
||||
}
|
||||
} else { // 50008 to 50016
|
||||
if (entityId == 50008) { //
|
||||
|
||||
} else if (entityId == 50012) { // Iron Golem
|
||||
if (CheckForColor(color.rgb, vec3(141, 0, 42))) { // Eye - brighter bit
|
||||
color.rgb = vec3(1.0, 0.3, 0.4);
|
||||
emission = 1.0;
|
||||
} else if (CheckForColor(color.rgb, vec3(30, 0, 14))) { // Eye - dimmer bit
|
||||
color.rgb = vec3(0.2, 0.0, 0.0);
|
||||
emission = 0.35;
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
}
|
||||
|
||||
smoothnessD *= 0.4;
|
||||
} else { // 50015 - Armor Stand
|
||||
// Do nothing for now
|
||||
}
|
||||
}
|
||||
} else { // 50016 to 50032
|
||||
if (entityId < 50024) { // 50016 to 50024
|
||||
if (entityId == 50016 || entityId == 50017) { // Player
|
||||
if (entityColor.a < 0.001) {
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.5;
|
||||
#endif
|
||||
|
||||
if (CheckForColor(texelFetch(tex, ivec2(0, 0), 0).rgb, vec3(23, 46, 92))) {
|
||||
for (int i = 63; i >= 56; i--) {
|
||||
vec3 dif = color.rgb - texelFetch(tex, ivec2(i, 0), 0).rgb;
|
||||
if (dif == clamp(dif, vec3(-0.001), vec3(0.001))) {
|
||||
emission = 2.0 * texelFetch(tex, ivec2(i, 1), 0).r;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool selfCheck = false;
|
||||
#if IRIS_VERSION >= 10800
|
||||
if (entityId == 50017) {
|
||||
selfCheck = true;
|
||||
entitySSBLMask = 0.0;
|
||||
}
|
||||
#else
|
||||
if (length(playerPos) < 4.0) {
|
||||
selfCheck = true;
|
||||
entitySSBLMask = 0.0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else /*if (entityId == 50020)*/ { // Blaze
|
||||
lmCoordM = vec2(0.9, 0.0);
|
||||
emission = min(color.r, 0.7) * 1.4;
|
||||
|
||||
float dotColor = dot(color.rgb, color.rgb);
|
||||
if (abs(dotColor - 1.5) > 1.4) {
|
||||
emission = 5.0;
|
||||
} else {
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else { // 50024 to 50032
|
||||
if (entityId == 50024) { // Creeper
|
||||
emission = max0(color.b - color.g - color.r) * 10.0;
|
||||
} else /*if (entityId == 50028)*/ { // Drowned
|
||||
if (atlasSize.x < 900) {
|
||||
if (CheckForColor(color.rgb, vec3(143, 241, 215)) || // Adult drowned
|
||||
CheckForColor(color.rgb, vec3( 49, 173, 183)) ||
|
||||
CheckForColor(color.rgb, vec3(101, 224, 221)) ||
|
||||
CheckForColor(color.rgb, vec3(164, 255, 247)) || // Baby drowned
|
||||
CheckForColor(color.rgb, vec3(116, 255, 254)) ||
|
||||
CheckForColor(color.rgb, vec3( 56, 199, 210))) emission = 2.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50032 to 50064
|
||||
if (entityId < 50048) { // 50032 to 50048
|
||||
if (entityId < 50040) { // 50032 to 50040
|
||||
if (entityId == 50032) { // Guardian
|
||||
vec3 absDif = abs(vec3(color.r - color.g, color.g - color.b, color.r - color.b));
|
||||
float maxDif = max(absDif.r, max(absDif.g, absDif.b));
|
||||
if (maxDif < 0.1 && color.b > 0.5 && color.b < 0.88) {
|
||||
emission = pow2(pow1_5(color.b)) * 5.0;
|
||||
color.rgb *= color.rgb;
|
||||
}
|
||||
} else /*if (entityId == 50036)*/ { // Elder Guardian
|
||||
if (CheckForColor(color.rgb, vec3(203, 177, 165)) ||
|
||||
CheckForColor(color.rgb, vec3(214, 155, 126))) {
|
||||
emission = pow2(pow1_5(color.b)) * 10.0;
|
||||
color.r *= 1.2;
|
||||
}
|
||||
}
|
||||
} else { // 50040 to 50048
|
||||
if (entityId == 50040) { // Endermite
|
||||
if (CheckForColor(color.rgb, vec3(87, 23, 50))) {
|
||||
emission = 8.0;
|
||||
color.rgb *= color.rgb;
|
||||
}
|
||||
} else /*if (entityId == 50044)*/ { // Ghast
|
||||
if (entityColor.a < 0.001)
|
||||
emission = max0(color.r - color.g - color.b) * 6.0;
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
if (color.r > color.b * 2.0) color.rgb = changeColorFunction(color.rgb, 7.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
if (color.r > color.b * 2.0) color.rgb = changeColorFunction(color.rgb, 7.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else { // 50048 to 50064
|
||||
if (entityId < 50056) { // 50048 to 50056
|
||||
if (entityId == 50048) { // Glow Squid
|
||||
lmCoordM.x = 0.0;
|
||||
float dotColor = dot(color.rgb, color.rgb);
|
||||
emission = pow2(pow2(min(dotColor * 0.65, 1.5))) + 0.45;
|
||||
} else /*if (entityId == 50052)*/ { // Magma Cube
|
||||
emission = color.g * 6.0;
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
}
|
||||
} else { // 50056 to 50064
|
||||
if (entityId == 50056) { // Stray
|
||||
if (CheckForColor(color.rgb, vec3(230, 242, 246)) && texCoord.y > 0.35)
|
||||
emission = 1.75;
|
||||
} else /*if (entityId == 50060)*/ { // Vex
|
||||
lmCoordM = vec2(0.0);
|
||||
emission = pow2(pow2(color.r)) * 3.5 + 0.5;
|
||||
color.a *= color.a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50064 to 50128
|
||||
if (entityId < 50096) { // 50064 to 50096
|
||||
if (entityId < 50080) { // 50064 to 50080
|
||||
if (entityId < 50072) { // 50064 to 50072
|
||||
if (entityId == 50064) { // Witch
|
||||
emission = 2.0 * color.g * float(color.g * 1.5 > color.b + color.r);
|
||||
} else /*if (entityId == 50068)*/ { // Wither, Wither Skull
|
||||
lmCoordM.x = 0.9;
|
||||
emission = 3.0 * float(dot(color.rgb, color.rgb) > 1.0);
|
||||
}
|
||||
} else { // 50072 to 50080
|
||||
if (entityId == 50072) { // Experience Orb
|
||||
emission = 7.5;
|
||||
|
||||
color.rgb *= color.rgb;
|
||||
} else /*if (entityId == 50076)*/ { // Boats
|
||||
playerPos.y += 0.38; // consistentBOAT2176: to avoid water shadow and the black inner shadow bug
|
||||
}
|
||||
}
|
||||
} else { // 50080 to 50096
|
||||
if (entityId < 50088) { // 50080 to 50088
|
||||
if (entityId == 50080) { // Allay
|
||||
if (atlasSize.x < 900) {
|
||||
lmCoordM = vec2(0.0);
|
||||
emission = float(color.r > 0.9 && color.b > 0.9) * 5.0 + color.g;
|
||||
} else {
|
||||
lmCoordM.x = 0.8;
|
||||
}
|
||||
} else /*if (entityId == 50084)*/ { // Slime, Chicken
|
||||
//only code is in Vertex Shader for now
|
||||
}
|
||||
} else { // 50088 to 50096
|
||||
if (entityId == 50088) { // Entity Flame (Iris Feature)
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 3.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 3.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
emission = 1.3;
|
||||
} else if (entityId == 50089) { // fireball, small fireball, dragon fireball
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 4.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 4.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
} else /*if (entityId == 50092)*/ { // Trident Entity
|
||||
#if defined IS_IRIS || defined IS_ANGELICA && ANGELICA_VERSION >= 20000008
|
||||
// Only on Iris, because otherwise it would be inconsistent with the Trident item
|
||||
#include "/lib/materials/specificMaterials/others/trident.glsl"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50096 to 50128
|
||||
if (entityId < 50112) { // 50096 to 50112
|
||||
if (entityId < 50104) { // 50096 to 50104
|
||||
if (entityId == 50096) { // Minecart++
|
||||
if (atlasSize.x < 900 && color.r * color.g * color.b + color.b > 0.3) {
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
|
||||
smoothnessD *= 0.6;
|
||||
}
|
||||
} else /*if (entityId == 50100)*/ { // Bogged
|
||||
if (CheckForColor(color.rgb, vec3(239, 254, 194)))
|
||||
emission = 2.5;
|
||||
}
|
||||
} else { // 50104 to 50112
|
||||
if (entityId == 50104) { // Piglin++, Hoglin+
|
||||
if (atlasSize.x < 900) {
|
||||
if (CheckForColor(color.rgb, vec3(255)) || CheckForColor(color.rgb, vec3(255, 242, 246))) {
|
||||
vec2 tSize = textureSize(tex, 0);
|
||||
vec4 checkColorOneRight = texelFetch(tex, ivec2(texCoord * tSize) + ivec2(1, 0), 0);
|
||||
if (
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(201, 130, 101)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(241, 158, 152)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(223, 127, 119)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(241, 158, 152)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(165, 99, 80)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(213, 149, 122)) ||
|
||||
CheckForColor(checkColorOneRight.rgb, vec3(255))
|
||||
) {
|
||||
emission = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else /*if (entityId == 50108)*/ { // Creaking
|
||||
if (color.r > 0.7 && color.r > color.g * 1.2 && color.g > color.b * 2.0) { // Eyes
|
||||
lmCoordM.x = 0.5;
|
||||
emission = 5.0 * color.g;
|
||||
color.rgb *= color.rgb;
|
||||
purkinjeOverwrite = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50112 to 50128
|
||||
if (entityId < 50120) { // 50112 to 50120
|
||||
if (entityId == 50112) { // Name Tag
|
||||
noDirectionalShading = true;
|
||||
color.rgb *= 1.5;
|
||||
if (color.a < 0.5) {
|
||||
color.a = 0.12;
|
||||
color.rgb *= 5.0;
|
||||
}
|
||||
} else /*if (entityId == 50116)*/ { // Copper Golem
|
||||
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
|
||||
|
||||
smoothnessD *= 0.5;
|
||||
}
|
||||
} else { // 50120 to 50128
|
||||
if (entityId == 50120) { // Parched
|
||||
if (CheckForColor(color.rgb, vec3(254, 235, 194))) {
|
||||
vec2 tSize = textureSize(tex, 0);
|
||||
vec4 checkColorOneDown = texelFetch(tex, ivec2(texCoord * tSize) + ivec2(0, 1), 0);
|
||||
if (CheckForColor(checkColorOneDown.rgb, vec3(135, 126, 118)) ||
|
||||
CheckForColor(checkColorOneDown.rgb, vec3(106, 103, 98))
|
||||
) {
|
||||
emission = 1.75;
|
||||
}
|
||||
}
|
||||
} else /*if (entityId == 50124)*/ { // Zombie Nautilus
|
||||
if (CheckForColor(color.rgb, vec3(143, 241, 215)) || CheckForColor(color.rgb, vec3(101, 224, 221)))
|
||||
emission = 1.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50128 to 50256
|
||||
if (entityId < 50192) { // 50128 to 50192
|
||||
if (entityId < 50160) { // 50128 to 50160
|
||||
if (entityId < 50144) { // 50128 to 50144
|
||||
if (entityId < 50136) { // 50128 to 50136
|
||||
if (entityId < 50132) { // Item Frame
|
||||
noSmoothLighting = true;
|
||||
noDirectionalShading = true;
|
||||
} else { // Glow Item Frame
|
||||
noSmoothLighting = true;
|
||||
noDirectionalShading = true;
|
||||
lmCoordM.y = eyeBrightnessM;
|
||||
}
|
||||
} else { // 50136 to 50144
|
||||
if (entityId < 50140) { // 50136 to 50140
|
||||
// 50136
|
||||
// 50137
|
||||
// 50138
|
||||
// 50139
|
||||
} else { // 50140 to 50144
|
||||
// 50140
|
||||
// 50141
|
||||
// 50142
|
||||
// 50143
|
||||
}
|
||||
}
|
||||
} else { // 50144 to 50160
|
||||
if (entityId < 50152) { // 50144 to 50152
|
||||
if (entityId < 50148) { // 50144 to 50148
|
||||
// 50144
|
||||
// 50145
|
||||
// 50146
|
||||
// 50147
|
||||
} else { // 50148 to 50152
|
||||
// 50148
|
||||
// 50149
|
||||
// 50150
|
||||
// 50151
|
||||
}
|
||||
} else { // 50152 to 50160
|
||||
if (entityId < 50156) { // 50152 to 50156
|
||||
// 50152
|
||||
// 50153
|
||||
// 50154
|
||||
// 50155
|
||||
} else { // 50156 to 50160
|
||||
// 50156
|
||||
// 50157
|
||||
// 50158
|
||||
// 50159
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50160 to 50192
|
||||
if (entityId < 50176) { // 50160 to 50176
|
||||
if (entityId < 50168) { // 50160 to 50168
|
||||
if (entityId < 50164) { // 50160 to 50164
|
||||
// 50160
|
||||
// 50161
|
||||
// 50162
|
||||
// 50163
|
||||
} else { // 50164 to 50168
|
||||
// 50164
|
||||
// 50165
|
||||
// 50166
|
||||
// 50167
|
||||
}
|
||||
} else { // 50168 to 50176
|
||||
if (entityId < 50172) { // 50168 to 50172
|
||||
// 50168
|
||||
// 50169
|
||||
// 50170
|
||||
// 50171
|
||||
} else { // 50172 to 50176
|
||||
// 50172
|
||||
// 50173
|
||||
// 50174
|
||||
// 50175
|
||||
}
|
||||
}
|
||||
} else { // 50176 to 50192
|
||||
if (entityId < 50184) { // 50176 to 50184
|
||||
if (entityId < 50180) { // 50176 to 50180
|
||||
// 50176
|
||||
// 50177
|
||||
// 50178
|
||||
// 50179
|
||||
} else { // 50180 to 50184
|
||||
// 50180
|
||||
// 50181
|
||||
// 50182
|
||||
// 50183
|
||||
}
|
||||
} else { // 50184 to 50192
|
||||
if (entityId < 50188) { // 50184 to 50188
|
||||
// 50184
|
||||
// 50185
|
||||
// 50186
|
||||
// 50187
|
||||
} else { // 50188 to 50192
|
||||
// 50188
|
||||
// 50189
|
||||
// 50190
|
||||
// 50191
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50192 to 50256
|
||||
if (entityId < 50224) { // 50192 to 50224
|
||||
if (entityId < 50208) { // 50192 to 50208
|
||||
if (entityId < 50200) { // 50192 to 50200
|
||||
if (entityId < 50196) { // 50192 to 50196
|
||||
// 50192
|
||||
// 50193
|
||||
// 50194
|
||||
// 50195
|
||||
} else { // 50196 to 50200
|
||||
// 50196
|
||||
// 50197
|
||||
// 50198
|
||||
// 50199
|
||||
}
|
||||
} else { // 50200 to 50208
|
||||
if (entityId < 50204) { // 50200 to 50204
|
||||
// 50200
|
||||
// 50201
|
||||
// 50202
|
||||
// 50203
|
||||
} else { // 50204 to 50208
|
||||
// 50204
|
||||
// 50205
|
||||
// 50206
|
||||
// 50207
|
||||
}
|
||||
}
|
||||
} else { // 50208 to 50224
|
||||
if (entityId < 50216) { // 50208 to 50216
|
||||
if (entityId < 50212) { // 50208 to 50212
|
||||
// 50208
|
||||
// 50209
|
||||
// 50210
|
||||
// 50211
|
||||
} else { // 50212 to 50216
|
||||
// 50212
|
||||
// 50213
|
||||
// 50214
|
||||
// 50215
|
||||
}
|
||||
} else { // 50216 to 50224
|
||||
if (entityId < 50220) { // 50216 to 50220
|
||||
// 50216
|
||||
// 50217
|
||||
// 50218
|
||||
// 50219
|
||||
} else { // 50220 to 50224
|
||||
// 50220
|
||||
// 50221
|
||||
// 50222
|
||||
// 50223
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 50224 to 50256
|
||||
if (entityId < 50240) { // 50224 to 50240
|
||||
if (entityId < 50232) { // 50224 to 50232
|
||||
if (entityId < 50228) { // 50224 to 50228
|
||||
// 50224
|
||||
// 50225
|
||||
// 50226
|
||||
// 50227
|
||||
} else { // 50228 to 50232
|
||||
// 50228
|
||||
// 50229
|
||||
// 50230
|
||||
// 50231
|
||||
}
|
||||
} else { // 50232 to 50240
|
||||
if (entityId < 50236) { // 50232 to 50236
|
||||
// 50232
|
||||
// 50233
|
||||
// 50234
|
||||
// 50235
|
||||
} else { // 50236 to 50240
|
||||
// 50236
|
||||
// 50237
|
||||
// 50238
|
||||
// 50239
|
||||
}
|
||||
}
|
||||
} else { // 50240 to 50256
|
||||
if (entityId < 50248) { // 50240 to 50248
|
||||
if (entityId < 50244) { // 50240 to 50244
|
||||
// 50240
|
||||
// 50241
|
||||
// 50242
|
||||
// 50243
|
||||
} else { // 50244 to 50248
|
||||
// 50244
|
||||
// 50245
|
||||
// 50246
|
||||
// 50247
|
||||
}
|
||||
} else { // 50248 to 50256
|
||||
if (entityId < 50252) { // 50248 to 50252
|
||||
// 50248
|
||||
// 50249
|
||||
// 50250
|
||||
// 50251
|
||||
} else { // 50252 to 50256
|
||||
// 50252
|
||||
// 50253
|
||||
// 50254
|
||||
// 50255
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+531
@@ -0,0 +1,531 @@
|
||||
#include "/lib/shaderSettings/entityMaterials.glsl"
|
||||
int mat = currentRenderedItemId;
|
||||
|
||||
#ifdef GBUFFERS_HAND
|
||||
float lViewPos = 0.0;
|
||||
#endif
|
||||
|
||||
int subsurfaceMode;
|
||||
bool centerShadowBias;
|
||||
float noPuddles;
|
||||
|
||||
if (currentRenderedItemId < 45000) {
|
||||
#include "/lib/materials/materialHandling/terrainIPBR.glsl"
|
||||
} else
|
||||
|
||||
if (currentRenderedItemId < 45128) {
|
||||
if (currentRenderedItemId < 45064) {
|
||||
if (currentRenderedItemId < 45032) {
|
||||
if (currentRenderedItemId < 45016) {
|
||||
if (currentRenderedItemId < 45008) {
|
||||
if (currentRenderedItemId < 45004) { // Armor Trims
|
||||
smoothnessG = 0.5;
|
||||
highlightMult = 2.0;
|
||||
smoothnessD = 0.5;
|
||||
|
||||
#ifdef GLOWING_ARMOR_TRIM
|
||||
emission = 1.0;
|
||||
#endif
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
HideArmorDontSkip(color, playerPos);
|
||||
#endif
|
||||
#ifdef SITUATIONAL_GLOWING_TRIMS
|
||||
emission *= skyLightCheck;
|
||||
#endif
|
||||
} else { // Wooden Tools, Bow, Fishing Rod
|
||||
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
|
||||
smoothnessG = min(smoothnessG, 0.4);
|
||||
smoothnessD = smoothnessG;
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45012) { // Stone Tools
|
||||
if (CheckForStick(color.rgb)) {
|
||||
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/stone.glsl"
|
||||
}
|
||||
} else { // Iron Tools, Iron Armor, Iron Ingot, Iron Nugget, Iron Horse Armor, Flint and Steel, Flint, Spyglass, Shears, Chainmail Armor
|
||||
if (CheckForStick(color.rgb)) {
|
||||
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
}
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
if (currentRenderedItemId == 45013) { // Iron Armor, Chainmail Armor
|
||||
HideArmor(color, playerPos);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45024) {
|
||||
if (currentRenderedItemId < 45020) { // Golden Tools, Golden Armor, Gold Ingot, Gold Nugget, Golden Apple, Enchanted Golden Apple, Golden Carrot, Golden Horse Armor
|
||||
if (CheckForStick(color.rgb)) {
|
||||
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
|
||||
}
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
if (currentRenderedItemId == 45017) { // Gold Armor
|
||||
HideArmor(color, playerPos);
|
||||
}
|
||||
#endif
|
||||
} else { // Diamond Tools, Diamond Armor, Diamond, Diamond Horse Armor, Emerald
|
||||
if (CheckForStick(color.rgb)) {
|
||||
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/diamondBlock.glsl"
|
||||
}
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
if (currentRenderedItemId == 45021) { // Diamond Armor
|
||||
HideArmor(color, playerPos);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45028) { // Netherite Tools, Netherite Armor, Netherite Ingot
|
||||
materialMask = OSIEBCA; // Intense Fresnel
|
||||
smoothnessG = color.b * 1.65;
|
||||
smoothnessG = min1(smoothnessG);
|
||||
highlightMult = smoothnessG * 2.0;
|
||||
smoothnessD = smoothnessG * smoothnessG * 0.5;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.33;
|
||||
#endif
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
if (currentRenderedItemId == 45025) { // Netherite Armor
|
||||
HideArmor(color, playerPos);
|
||||
}
|
||||
if (currentRenderedItemId == 45026) { // Netherite Trim
|
||||
HideArmorDontSkip(color, playerPos);
|
||||
}
|
||||
#endif
|
||||
} else { // Trident Item
|
||||
#include "/lib/materials/specificMaterials/others/trident.glsl"
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45048) {
|
||||
if (currentRenderedItemId < 45040) {
|
||||
if (currentRenderedItemId < 45036) { // Lava Bucket
|
||||
if (color.r + color.g > color.b * 2.0) {
|
||||
emission = color.r + color.g - color.b * 1.5;
|
||||
emission *= 1.8;
|
||||
color.rg += color.b * vec2(0.4, 0.15);
|
||||
color.b *= 0.8;
|
||||
if (LAVA_TEMPERATURE != 0.0) maRecolor += LAVA_TEMPERATURE * 0.1;
|
||||
emission *= LAVA_EMISSION;
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
} else {
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
}
|
||||
} else { // Bucket++
|
||||
if (GetMaxColorDif(color.rgb) < 0.01) {
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
} else {
|
||||
float factor = color.b;
|
||||
smoothnessG = factor;
|
||||
highlightMult = factor * 2.0;
|
||||
smoothnessD = factor;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45044) { // Blaze Rod, Blaze Powder
|
||||
noSmoothLighting = false;
|
||||
lmCoordM.x = 0.85;
|
||||
emission = color.g;
|
||||
color.rgb = sqrt1(color.rgb);
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 2.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
} else { // Bottle o' Enchanting, Glow Inc Sac
|
||||
emission = color.b * 2.0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45056) {
|
||||
if (currentRenderedItemId < 45052) { // Fire Charge
|
||||
emission = max0(color.r + color.g - color.b * 0.5);
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 5.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
#ifdef PURPLE_END_FIRE_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 5.0, colorEndBreath, 1.0);
|
||||
#endif
|
||||
} else { // Chorus Fruit
|
||||
emission = max0(color.b * 2.0 - color.r) * 1.5;
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45060) { // Amethyst Shard
|
||||
materialMask = OSIEBCA; // Intense Fresnel
|
||||
float factor = pow2(color.r);
|
||||
smoothnessG = 0.8 - factor * 0.3;
|
||||
highlightMult = factor * 3.0;
|
||||
smoothnessD = factor;
|
||||
} else { // Shield
|
||||
float factor = min(color.r * color.g * color.b * 4.0, 0.7) * 0.7;
|
||||
smoothnessG = factor;
|
||||
highlightMult = factor * 3.0;
|
||||
smoothnessD = factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45096) {
|
||||
if (currentRenderedItemId < 45080) {
|
||||
if (currentRenderedItemId < 45072) {
|
||||
if (currentRenderedItemId < 45068) { // Turtle Shell
|
||||
float factor = color.g * 0.7;
|
||||
smoothnessG = factor;
|
||||
highlightMult = factor * 3.0;
|
||||
smoothnessD = factor;
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
HideArmor(color, playerPos);
|
||||
#endif
|
||||
} else { // Ender Pearl
|
||||
smoothnessG = 1.0;
|
||||
highlightMult = 2.0;
|
||||
smoothnessD = 1.0;
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45076) { // Eye of Ender
|
||||
smoothnessG = 1.0;
|
||||
highlightMult = 2.0;
|
||||
smoothnessD = 1.0;
|
||||
emission = max0(color.g - color.b * 0.25);
|
||||
color.rgb = pow(color.rgb, vec3(1.0 - 0.75 * emission));
|
||||
} else { // Clock
|
||||
if (
|
||||
CheckForColor(color.rgb, vec3(255, 255, 0)) ||
|
||||
CheckForColor(color.rgb, vec3(204, 204, 0)) ||
|
||||
CheckForColor(color.rgb, vec3(73, 104, 216)) ||
|
||||
CheckForColor(color.rgb, vec3(58, 83, 172)) ||
|
||||
CheckForColor(color.rgb, vec3(108, 108, 137)) ||
|
||||
CheckForColor(color.rgb, vec3(86, 86, 109))
|
||||
) {
|
||||
emission = 1.0;
|
||||
color.rgb += vec3(0.1);
|
||||
}
|
||||
|
||||
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45088) {
|
||||
if (currentRenderedItemId < 45084) { // Compass
|
||||
if (color.r - 0.1 > color.b + color.g) {
|
||||
emission = color.r * 1.5;
|
||||
}
|
||||
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
} else { // Echo Shard, Recovery Compass, Music Disc 5
|
||||
emission = max0(color.b + color.g - color.r * 2.0);
|
||||
|
||||
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45092) { // Nether Star
|
||||
emission = pow2(color.r + color.g) * 0.5;
|
||||
} else { // End Crystal
|
||||
if (color.g < color.r) {
|
||||
emission = 3.0;
|
||||
color.r *= 1.1;
|
||||
}
|
||||
emission *= END_CRYSTAL_EMISSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45112) {
|
||||
if (currentRenderedItemId < 45104) {
|
||||
if (currentRenderedItemId < 45100) { // Glow Berries
|
||||
// iris needs to add support
|
||||
} else { // Glowstone Dust
|
||||
emission = dot(color.rgb, color.rgb) * 0.5 + 1.0;
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45108) { // Prismarine Crystals
|
||||
emission = pow1_5(color.r) * 2.5 + 0.2;
|
||||
} else { // Totem of Undying
|
||||
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45120) {
|
||||
if (currentRenderedItemId < 45116) { // Trial Key, Ominous Trial Key
|
||||
emission = abs(color.r - color.b) * 3.0;
|
||||
color.rgb = pow(color.rgb, vec3(1.0 + 0.5 * sqrt(emission)));
|
||||
} else { // Copper Tools, Copper Armor, Copper Ingot, Copper Horse Armor
|
||||
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
|
||||
|
||||
smoothnessD *= 0.5;
|
||||
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
if (currentRenderedItemId == 45117) { // Copper Armor
|
||||
HideArmor(color, playerPos);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId == 45120) { // Ghast Harness+
|
||||
vec2 tSize = textureSize(tex, 0);
|
||||
vec4 checkColorOneDown = texelFetch(tex, ivec2(texCoord * tSize) + ivec2(0, 1), 0);
|
||||
if (
|
||||
CheckForColor(color.rgb, vec3(139, 193, 205)) ||
|
||||
CheckForColor(color.rgb, vec3(208, 234, 233)) ||
|
||||
CheckForColor(color.rgb, vec3(109, 152, 161)) ||
|
||||
CheckForColor(color.rgb, vec3(255)) && CheckForColor(checkColorOneDown.rgb, vec3(109, 152, 161)) ||
|
||||
CheckForColor(color.rgb, vec3(168, 208, 217))
|
||||
) {
|
||||
smoothnessG = 1.0;
|
||||
highlightMult = 2.0 - dot(color.rgb, vec3(0.25));
|
||||
smoothnessD = 1.0;
|
||||
}
|
||||
} else if (currentRenderedItemId == 45124) { // Elytra
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
HideElytra(color, playerPos);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45192) {
|
||||
if (currentRenderedItemId < 45160) {
|
||||
if (currentRenderedItemId < 45144) {
|
||||
if (currentRenderedItemId < 45136) {
|
||||
if (currentRenderedItemId < 45132) { // Leather Armor
|
||||
#if HIDE_ARMOR > 0 && defined GBUFFERS_ENTITIES
|
||||
HideArmor(color, playerPos);
|
||||
#endif
|
||||
} else { // 45132 to 45136
|
||||
// 45132
|
||||
// 45133
|
||||
// 45134
|
||||
// 45135
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45140) { // 45136 to 45140
|
||||
// 45136
|
||||
// 45137
|
||||
// 45138
|
||||
// 45139
|
||||
} else { // 45140 to 45144
|
||||
// 45140
|
||||
// 45141
|
||||
// 45142
|
||||
// 45143
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45152) {
|
||||
if (currentRenderedItemId < 45148) { // 45144 to 45148
|
||||
// 45144
|
||||
// 45145
|
||||
// 45146
|
||||
// 45147
|
||||
} else { // 45148 to 45152
|
||||
// 45148
|
||||
// 45149
|
||||
// 45150
|
||||
// 45151
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45156) { // 45152 to 45156
|
||||
// 45152
|
||||
// 45153
|
||||
// 45154
|
||||
// 45155
|
||||
} else { // 45156 to 45160
|
||||
// 45156
|
||||
// 45157
|
||||
// 45158
|
||||
// 45159
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45176) {
|
||||
if (currentRenderedItemId < 45168) {
|
||||
if (currentRenderedItemId < 45164) { // 45160 to 45164
|
||||
// 45160
|
||||
// 45161
|
||||
// 45162
|
||||
// 45163
|
||||
} else { // 45164 to 45168
|
||||
// 45164
|
||||
// 45165
|
||||
// 45166
|
||||
// 45167
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45172) { // 45168 to 45172
|
||||
// 45168
|
||||
// 45169
|
||||
// 45170
|
||||
// 45171
|
||||
} else { // 45172 to 45176
|
||||
// 45172
|
||||
// 45173
|
||||
// 45174
|
||||
// 45175
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45184) {
|
||||
if (currentRenderedItemId < 45180) { // 45176 to 45180
|
||||
// 45176
|
||||
// 45177
|
||||
// 45178
|
||||
// 45179
|
||||
} else { // 45180 to 45184
|
||||
// 45180
|
||||
// 45181
|
||||
// 45182
|
||||
// 45183
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45188) { // 45184 to 45188
|
||||
// 45184
|
||||
// 45185
|
||||
// 45186
|
||||
// 45187
|
||||
} else { // 45188 to 45192
|
||||
// 45188
|
||||
// 45189
|
||||
// 45190
|
||||
// 45191
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45224) {
|
||||
if (currentRenderedItemId < 45208) {
|
||||
if (currentRenderedItemId < 45200) {
|
||||
if (currentRenderedItemId < 45196) { // 45192 to 45196
|
||||
// 45192
|
||||
// 45193
|
||||
// 45194
|
||||
// 45195
|
||||
} else { // 45196 to 45200
|
||||
// 45196
|
||||
// 45197
|
||||
// 45198
|
||||
// 45199
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45204) { // 45200 to 45204
|
||||
// 45200
|
||||
// 45201
|
||||
// 45202
|
||||
// 45203
|
||||
} else { // 45204 to 45208
|
||||
// 45204
|
||||
// 45205
|
||||
// 45206
|
||||
// 45207
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45216) {
|
||||
if (currentRenderedItemId < 45212) { // 45208 to 45212
|
||||
// 45208
|
||||
// 45209
|
||||
// 45210
|
||||
// 45211
|
||||
} else { // 45212 to 45216
|
||||
// 45212
|
||||
// 45213
|
||||
// 45214
|
||||
// 45215
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45220) { // 45216 to 45220
|
||||
// 45216
|
||||
// 45217
|
||||
// 45218
|
||||
// 45219
|
||||
} else { // 45220 to 45224
|
||||
// 45220
|
||||
// 45221
|
||||
// 45222
|
||||
// 45223
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45240) {
|
||||
if (currentRenderedItemId < 45232) {
|
||||
if (currentRenderedItemId < 45228) { // 45224 to 45228
|
||||
// 45224
|
||||
// 45225
|
||||
// 45226
|
||||
// 45227
|
||||
} else { // 45228 to 45232
|
||||
// 45228
|
||||
// 45229
|
||||
// 45230
|
||||
// 45231
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45236) { // 45232 to 45236
|
||||
// 45232
|
||||
// 45233
|
||||
// 45234
|
||||
// 45235
|
||||
} else { // 45236 to 45240
|
||||
// 45236
|
||||
// 45237
|
||||
// 45238
|
||||
// 45239
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45248) {
|
||||
if (currentRenderedItemId < 45244) { // 45240 to 45244
|
||||
// 45240
|
||||
// 45241
|
||||
// 45242
|
||||
// 45243
|
||||
} else { // 45244 to 45248
|
||||
// 45244
|
||||
// 45245
|
||||
// 45246
|
||||
// 45247
|
||||
}
|
||||
} else {
|
||||
if (currentRenderedItemId < 45252) { // 45248 to 45252
|
||||
// 45248
|
||||
// 45249
|
||||
// 45250
|
||||
// 45251
|
||||
} else { // 45252 to 45256
|
||||
// 45252
|
||||
// 45253
|
||||
// 45254
|
||||
// 45255
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#if defined VOXY_PATCH
|
||||
#define BLOCK_LAVA_DEFINE (mat == 10068 || mat == 10070)
|
||||
#define BLOCK_LAVA_STILL_DEFINE (mat == 10068 || mat == 10070)
|
||||
#define BLOCK_LEAVES_SEASONS_DEFINE (mat == 10009 || mat == 10011)
|
||||
#elif defined DH_TERRAIN || defined DH_WATER
|
||||
#define BLOCK_LAVA_DEFINE mat == DH_BLOCK_LAVA
|
||||
#define BLOCK_LAVA_STILL_DEFINE mat == DH_BLOCK_LAVA
|
||||
#define BLOCK_LEAVES_SEASONS_DEFINE mat == DH_BLOCK_LEAVES
|
||||
#else
|
||||
#define BLOCK_LAVA_DEFINE (mat == 10068 || mat == 10070)
|
||||
#define BLOCK_LAVA_STILL_DEFINE mat == 10068
|
||||
#define BLOCK_LEAVES_SEASONS_DEFINE (mat == 10009 || mat == 10011)
|
||||
#endif
|
||||
+3701
File diff suppressed because it is too large
Load Diff
+102
@@ -0,0 +1,102 @@
|
||||
#ifdef VOXY_PATCH
|
||||
#undef GENERATED_NORMALS
|
||||
#undef COATED_TEXTURES
|
||||
#undef CUSTOM_PBR
|
||||
#ifndef IPBR_COMPAT_MODE
|
||||
#define IPBR_COMPAT_MODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IPBR
|
||||
vec3 maRecolor = vec3(0.0);
|
||||
#include "/lib/materials/materialHandling/terrainIPBR.glsl"
|
||||
|
||||
#ifdef REFLECTIVE_WORLD
|
||||
smoothnessD = 1.0;
|
||||
smoothnessG = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
if (!noGeneratedNormals) GenerateNormals(normalM, colorP);
|
||||
#endif
|
||||
|
||||
#if IPBR_EMISSIVE_MODE != 1 && !defined VOXY_PATCH
|
||||
emission = GetCustomEmissionForIPBR(color, glColor, emission);
|
||||
#endif
|
||||
#else
|
||||
#ifdef CUSTOM_PBR
|
||||
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMask, materialAO, viewPos, lViewPos);
|
||||
#endif
|
||||
|
||||
if (mat == 10001) { // No directional shading
|
||||
noDirectionalShading = true;
|
||||
} else if (mat == 10003 || mat == 10005 || mat == 10029 || mat == 10031) { // Grounded Waving Foliage
|
||||
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true, isFoliage = true;
|
||||
#if defined GBUFFERS_TERRAIN || defined VOXY_PATCH
|
||||
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
|
||||
#endif
|
||||
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
|
||||
} else if (uint(mat - 10007) <= 5u) { // Leaves (10007 to 10012)
|
||||
#include "/lib/materials/specificMaterials/terrain/leaves.glsl"
|
||||
} else if (mat == 11009 || mat == 10923) { // Vine, Pale Hanging Moss
|
||||
subsurfaceMode = 3, centerShadowBias = true; noSmoothLighting = true, isFoliage = true;
|
||||
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
|
||||
} else if (mat == 10015 || mat == 10017 || mat == 10019) { // Non-waving Foliage
|
||||
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true, isFoliage = true;
|
||||
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
|
||||
} else if (mat == 10021 || mat == 10023) { // Upper Waving Foliage
|
||||
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true, isFoliage = true;
|
||||
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
|
||||
#if defined GBUFFERS_TERRAIN || defined VOXY_PATCH
|
||||
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
|
||||
#endif
|
||||
} else if (mat == 10068 || mat == 10070) { // Lava
|
||||
vec3 previousLavaColor = color.rgb;
|
||||
if (emission < 1.0) emission = max(2.0, emission);
|
||||
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
|
||||
color.rgb = changeColorFunction(color.rgb, 3.0, colorSoul, inSoulValley);
|
||||
#endif
|
||||
vec3 lavaNoiseColor = color.rgb;
|
||||
#if LAVA_VARIATION > 0
|
||||
vec2 lavaPos = (floor(worldPos.xz * 16.0) + worldPos.y * 32.0) * 0.000666;
|
||||
vec2 wind = vec2(frameTimeCounter * 0.012, 0.0);
|
||||
lavaNoiseIntensity *= 0.95;
|
||||
#include "/lib/materials/specificMaterials/terrain/lavaNoise.glsl"
|
||||
color.rgb = lavaNoiseColor;
|
||||
#else
|
||||
if (LAVA_TEMPERATURE != 0.0) color.rgb += LAVA_TEMPERATURE * 0.3;
|
||||
#endif
|
||||
vec3 maxLavaColor = max(previousLavaColor, lavaNoiseColor);
|
||||
vec3 minLavaColor = min(previousLavaColor, lavaNoiseColor);
|
||||
#if RAIN_PUDDLES >= 1
|
||||
noPuddles = 1.0;
|
||||
#endif
|
||||
|
||||
#include "/lib/materials/specificMaterials/terrain/lavaEdge.glsl"
|
||||
|
||||
emission *= LAVA_EMISSION;
|
||||
} else if (mat > 20999 && mat < 21025){
|
||||
emission = DoAutomaticEmission(noSmoothLighting, noDirectionalShading, color.rgb, lmCoord.x, blockLightEmission, 1.0);
|
||||
} else if (mat > 21025 && mat < 21051) {
|
||||
emission = 3.0;
|
||||
}
|
||||
|
||||
#ifdef SNOWY_WORLD
|
||||
else if (mat == 10132) { // Grass Block:Normal
|
||||
if (glColor.b < 0.999) { // Grass Block:Normal:Grass Part
|
||||
snowMinNdotU = min(pow2(pow2(color.g)) * 1.9, 0.1);
|
||||
color.rgb = color.rgb * 0.5 + 0.5 * (color.rgb / glColor.rgb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (lmCoord.x > 0.99999) lmCoordM.x = 0.95;
|
||||
#endif
|
||||
|
||||
|
||||
if (mat == 10572) { // Dragon Egg
|
||||
overlayNoiseIntensity = 0.0;
|
||||
#ifndef EMISSIVE_DRAGON_EGG
|
||||
emission *= 0.0;
|
||||
#endif
|
||||
}
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
#include "/lib/shaderSettings/water.glsl"
|
||||
if (mat < 32008) {
|
||||
if (mat < 30016) {
|
||||
if (mat < 30008) {
|
||||
if (mat == 30000) { //
|
||||
|
||||
} else if (mat == 30004) { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (mat == 30008) { // Tinted Glass
|
||||
#ifdef CONNECTED_GLASS_EFFECT
|
||||
uint voxelID = uint(254);
|
||||
bool isPane = false;
|
||||
DoConnectedGlass(colorP, color, noGeneratedNormals, playerPos, worldGeoNormal, voxelID, isPane);
|
||||
#endif
|
||||
color.a = pow(color.a, 1.0 - fresnelM);
|
||||
reflectMult = 1.0;
|
||||
|
||||
#if MIRROR_TINTED_GLASS == 0
|
||||
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
|
||||
#elif MIRROR_TINTED_GLASS == 35
|
||||
color.a = color.a * 0.65 + 0.35;
|
||||
fresnelM = fresnelM * 0.75 + 0.25;
|
||||
reflectMult /= color.a * 0.5 + 0.5;
|
||||
noGeneratedNormals = true;
|
||||
#elif MIRROR_TINTED_GLASS == 70
|
||||
color.a = color.a * 0.3 + 0.7;
|
||||
fresnelM = fresnelM * 0.5 + 0.5;
|
||||
reflectMult /= color.a;
|
||||
noGeneratedNormals = true;
|
||||
#elif MIRROR_TINTED_GLASS == 100
|
||||
color.a = 0.99;
|
||||
fresnelM = 1.0;
|
||||
noGeneratedNormals = true;
|
||||
#endif
|
||||
overlayNoiseAlpha = 0.95;
|
||||
sandNoiseIntensity = 0.5;
|
||||
mossNoiseIntensity = 0.5;
|
||||
} else /*if (mat == 30012)*/ { // Slime Block
|
||||
translucentMultCalculated = true;
|
||||
reflectMult = 0.7;
|
||||
translucentMult.rgb = pow2(color.rgb) * 0.2;
|
||||
|
||||
smoothnessG = color.g * 0.7;
|
||||
highlightMult = 2.5;
|
||||
overlayNoiseAlpha = 0.6;
|
||||
sandNoiseIntensity = 0.5;
|
||||
mossNoiseIntensity = 0.5;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 32000) {
|
||||
if (mat < 31000) {
|
||||
if (mat == 30016) { // Honey Block
|
||||
translucentMultCalculated = true;
|
||||
reflectMult = 1.0;
|
||||
translucentMult.rgb = pow2(color.rgb) * 0.2;
|
||||
|
||||
smoothnessG = color.r * 0.7;
|
||||
highlightMult = 2.5;
|
||||
overlayNoiseAlpha = 0.4;
|
||||
sandNoiseIntensity = 0.5;
|
||||
mossNoiseIntensity = 0.5;
|
||||
} else /*if (mat == 30020)*/ { // Nether Portal
|
||||
#ifdef SPECIAL_PORTAL_EFFECTS
|
||||
#include "/lib/materials/specificMaterials/translucents/netherPortal.glsl"
|
||||
#endif
|
||||
overlayNoiseIntensity = 0.0;
|
||||
}
|
||||
} else { // (31XXX)
|
||||
if (mat % 2 == 0) { // Stained Glass
|
||||
#ifdef CONNECTED_GLASS_EFFECT
|
||||
uint voxelID = uint(200 + (mat - 31000) / 2);
|
||||
bool isPane = false;
|
||||
DoConnectedGlass(colorP, color, noGeneratedNormals, playerPos, worldGeoNormal, voxelID, isPane);
|
||||
#endif
|
||||
#include "/lib/materials/specificMaterials/translucents/stainedGlass.glsl"
|
||||
overlayNoiseAlpha = 1.05;
|
||||
mossNoiseIntensity = 0.8;
|
||||
} else /*if (mat % 2 == 1)*/ { // Stained Glass Pane
|
||||
#ifdef CONNECTED_GLASS_EFFECT
|
||||
uint voxelID = uint(200 + (mat - 31000) / 2);
|
||||
bool isPane = true;
|
||||
DoConnectedGlass(colorP, color, noGeneratedNormals, playerPos, worldGeoNormal, voxelID, isPane);
|
||||
#endif
|
||||
#include "/lib/materials/specificMaterials/translucents/stainedGlass.glsl"
|
||||
noSmoothLighting = true;
|
||||
overlayNoiseAlpha = 1.05;
|
||||
sandNoiseIntensity = 0.8;
|
||||
mossNoiseIntensity = 0.8;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 32004) { // Water
|
||||
#ifdef SHADER_WATER
|
||||
#include "/lib/materials/specificMaterials/translucents/water.glsl"
|
||||
#endif
|
||||
overlayNoiseIntensity = 0.0;
|
||||
overlayNoiseFresnelMult = 0.0;
|
||||
IPBRMult = 0.0;
|
||||
overlayNoiseAlpha = 0.0;
|
||||
} else /*if (mat == 32004)*/ { // Ice
|
||||
smoothnessG = pow2(color.g) * color.g;
|
||||
highlightMult = pow2(min1(pow2(color.g) * 1.5)) * 3.5;
|
||||
|
||||
reflectMult = 0.7;
|
||||
overlayNoiseAlpha = 0.6;
|
||||
sandNoiseIntensity = 0.7;
|
||||
mossNoiseIntensity = 0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 32024) {
|
||||
if (mat < 32016) {
|
||||
if (mat < 32012) { // Glass
|
||||
if (mat == 32008){
|
||||
#ifdef CONNECTED_GLASS_EFFECT
|
||||
uint voxelID = uint(217);
|
||||
bool isPane = false;
|
||||
DoConnectedGlass(colorP, color, noGeneratedNormals, playerPos, worldGeoNormal, voxelID, isPane);
|
||||
#endif
|
||||
}
|
||||
#include "/lib/materials/specificMaterials/translucents/glass.glsl"
|
||||
overlayNoiseAlpha = 0.8;
|
||||
sandNoiseIntensity = 0.8;
|
||||
mossNoiseIntensity = 0.8;
|
||||
} else /*if (mat == 32012)*/ { // Glass Pane
|
||||
if (mat == 32012) {
|
||||
#ifdef CONNECTED_GLASS_EFFECT
|
||||
uint voxelID = uint(218);
|
||||
bool isPane = true;
|
||||
DoConnectedGlass(colorP, color, noGeneratedNormals, playerPos, worldGeoNormal, voxelID, isPane);
|
||||
#endif
|
||||
}
|
||||
if (color.a < 0.001 && abs(NdotU) > 0.95) discard; // Fixing artifacts on CTM/Opti connected glass panes
|
||||
#include "/lib/materials/specificMaterials/translucents/glass.glsl"
|
||||
noSmoothLighting = true;
|
||||
overlayNoiseAlpha = 0.8;
|
||||
sandNoiseIntensity = 0.8;
|
||||
mossNoiseIntensity = 0.8;
|
||||
}
|
||||
} else {
|
||||
if (mat == 32016) { // Beacon
|
||||
lmCoordM.x = 0.88;
|
||||
|
||||
translucentMultCalculated = true;
|
||||
translucentMult = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
if (color.b > 0.5) {
|
||||
if (color.g - color.b < 0.01 && color.g < 0.99) {
|
||||
#include "/lib/materials/specificMaterials/translucents/glass.glsl"
|
||||
} else { // Beacon:Center
|
||||
lmCoordM = vec2(0.0);
|
||||
noDirectionalShading = true;
|
||||
|
||||
float lColor = length(color.rgb);
|
||||
vec3 baseColor = vec3(0.1, 1.0, 0.92);
|
||||
if (lColor > 1.65) color.rgb = baseColor + 0.2;
|
||||
else if (lColor > 1.5) color.rgb = baseColor + 0.15;
|
||||
else if (lColor > 1.3) color.rgb = baseColor + 0.08;
|
||||
else if (lColor > 1.15) color.rgb = baseColor + 0.035;
|
||||
else color.rgb = baseColor;
|
||||
emission = 3.5;
|
||||
}
|
||||
} else { // Beacon:Obsidian
|
||||
float factor = color.r * 1.5;
|
||||
|
||||
smoothnessG = factor;
|
||||
highlightMult = 2.0 + min1(smoothnessG * 2.0) * 1.5;
|
||||
smoothnessG = min1(smoothnessG);
|
||||
}
|
||||
overlayNoiseAlpha = 0.8;
|
||||
sandNoiseIntensity = 0.5;
|
||||
mossNoiseIntensity = 0.5;
|
||||
} else /*if (mat == 32020)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 32032) {
|
||||
if (mat == 32024) { //
|
||||
|
||||
} else /*if (mat == 32028)*/ { //
|
||||
|
||||
}
|
||||
} else {
|
||||
if (mat == 32032) { //
|
||||
|
||||
} else /*if (mat == 32036)*/ { //
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#ifdef VOXY_PATCH
|
||||
#undef CONNECTED_GLASS_EFFECT
|
||||
#undef GENERATED_NORMALS
|
||||
#undef CUSTOM_PBR
|
||||
#ifndef IPBR_COMPAT_MODE
|
||||
#define IPBR_COMPAT_MODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IPBR
|
||||
#include "/lib/materials/materialHandling/translucentIPBR.glsl"
|
||||
|
||||
#ifdef GENERATED_NORMALS
|
||||
if (!noGeneratedNormals) GenerateNormals(normalM, colorP.rgb * colorP.a * 1.5);
|
||||
#endif
|
||||
|
||||
#if IPBR_EMISSIVE_MODE != 1 && !defined VOXY_PATCH
|
||||
emission = GetCustomEmissionForIPBR(color, glColor, emission);
|
||||
#endif
|
||||
#else
|
||||
#ifdef CUSTOM_PBR
|
||||
float smoothnessD, materialMaskPh;
|
||||
GetCustomMaterials(color, normalM, lmCoordM, NdotU, shadowMult, smoothnessG, smoothnessD, highlightMult, emission, materialMaskPh, materialAO, viewPos, lViewPos);
|
||||
reflectMult = smoothnessD;
|
||||
#endif
|
||||
|
||||
if (mat == 32000) { // Water
|
||||
#ifdef SHADER_WATER
|
||||
#include "/lib/materials/specificMaterials/translucents/water.glsl"
|
||||
#endif
|
||||
overlayNoiseIntensity = 0.0;
|
||||
overlayNoiseFresnelMult = 0.0;
|
||||
IPBRMult = 0.0;
|
||||
overlayNoiseAlpha = 0.0;
|
||||
} else if (mat == 30020) { // Nether Portal
|
||||
#ifdef SPECIAL_PORTAL_EFFECTS
|
||||
#include "/lib/materials/specificMaterials/translucents/netherPortal.glsl"
|
||||
#endif
|
||||
overlayNoiseIntensity = 0.0;
|
||||
} else if (mat == 32016) { // Beacon
|
||||
overlayNoiseAlpha = 0.8;
|
||||
mossNoiseIntensity = 0.5;
|
||||
sandNoiseIntensity = 0.5;
|
||||
}
|
||||
|
||||
#endif
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
This file is specifically licensed with Mozilla Public License Version 2.0.
|
||||
You can get a copy from https://www.mozilla.org/MPL/2.0/
|
||||
*/
|
||||
|
||||
float manualDeterminant(mat2 matrix) {
|
||||
return matrix[0].x * matrix[1].y - matrix[0].y * matrix[1].x;
|
||||
}
|
||||
|
||||
mat2 inverseM(mat2 m) {
|
||||
#if MC_VERSION >= 11700
|
||||
return inverse(m);
|
||||
#else
|
||||
mat2 adj;
|
||||
adj[0][0] = m[1][1];
|
||||
adj[0][1] = -m[0][1];
|
||||
adj[1][0] = -m[1][0];
|
||||
adj[1][1] = m[0][0];
|
||||
return adj / manualDeterminant(m);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec4 textureAF(sampler2D texSampler, vec2 uv) {
|
||||
vec2 spriteDimensions = vec2(spriteBounds.z - spriteBounds.x, spriteBounds.w - spriteBounds.y);
|
||||
|
||||
mat2 J = inverseM(mat2(dFdx(uv), dFdy(uv)));
|
||||
J = transpose(J)*J;
|
||||
float d = manualDeterminant(J), t = J[0][0]+J[1][1],
|
||||
D = sqrt(abs(t*t-4.001*d)), // using 4.001 instead of 4.0 fixes a rare texture glitch with square texture atlas
|
||||
V = (t-D)/2.0, v = (t+D)/2.0,
|
||||
M = 1.0/sqrt(V), m = 1./sqrt(v);
|
||||
vec2 A = M * normalize(vec2(-J[0][1], J[0][0]-V));
|
||||
|
||||
float lod = 0.0;
|
||||
#if ANISOTROPIC_FILTER >= 8 && defined GBUFFERS_TERRAIN
|
||||
#if MC_VERSION < 12111
|
||||
// Excluding cutout blocks because cutout mipmaps suck in older mc versions
|
||||
if (texture2DLod(texSampler, uv, 10000.0).a == 1.0)
|
||||
#endif
|
||||
|
||||
// Fix257062 - Checking if absMidCoordPos is fine or else miplevel will be broken. This can be an issue for flowing lava.
|
||||
if (absMidCoordPos.x > 0.0001 && absMidCoordPos.y > 0.0001)
|
||||
lod = miplevel * 0.4;
|
||||
#endif
|
||||
|
||||
float samplesDiv2 = ANISOTROPIC_FILTER / 2.0;
|
||||
vec2 ADivSamples = A / ANISOTROPIC_FILTER;
|
||||
|
||||
vec4 filteredColor = vec4(0.0);
|
||||
float totalModifiedAlpha = 0.0;
|
||||
vec4 spriteBoundsM = mix(spriteBounds, vec4(midCoord, midCoord), 0.0001); // Fixes some mods causing issues with cutout blocks
|
||||
for (float i = -samplesDiv2 + 0.5; i < samplesDiv2; i++) {
|
||||
vec2 sampleUV = uv + ADivSamples * i;
|
||||
sampleUV = clamp(sampleUV, spriteBoundsM.xy, spriteBoundsM.zw);
|
||||
vec4 colorSample = texture2DLod(texSampler, sampleUV, lod);
|
||||
|
||||
colorSample.a = sqrt(colorSample.a); // Tweak to make cutout blocks look fuller in the distance
|
||||
|
||||
#if !defined POM || !defined POM_ALLOW_CUTOUT
|
||||
float modifiedAlpha = colorSample.a;
|
||||
#else
|
||||
// To avoid NaNs because we don't discard low alpha if POM_ALLOW_CUTOUT is enabled (see 6WIR4HT23)
|
||||
float modifiedAlpha = max(colorSample.a, 0.00001);
|
||||
#endif
|
||||
|
||||
totalModifiedAlpha += modifiedAlpha;
|
||||
filteredColor.rgb += colorSample.rgb * modifiedAlpha;
|
||||
filteredColor.a += colorSample.a;
|
||||
}
|
||||
filteredColor.rgb /= totalModifiedAlpha;
|
||||
filteredColor.a /= ANISOTROPIC_FILTER;
|
||||
|
||||
return filteredColor;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#define ENTITY_GN_AND_CT
|
||||
#define COATED_TEXTURE_MULT 100 //[25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200]
|
||||
#define COATED_TEXTURE_RES 64 //[16 32 64 80 96 112 128 144 160 176 192 208 224 240 256 320 384 448 512]
|
||||
const float packSizeNT = COATED_TEXTURE_RES;
|
||||
|
||||
void CoatTextures(inout vec3 color, float noiseFactor, vec3 playerPos, bool doTileRandomisation) {
|
||||
#ifndef ENTITY_GN_AND_CT
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_HAND
|
||||
return;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SAFER_GENERATED_NORMALS
|
||||
vec2 noiseCoord = floor(midCoordPos / 16.0 * packSizeNT * atlasSizeM) / packSizeNT / 3.0;
|
||||
#else
|
||||
vec2 offsetR = max(absMidCoordPos.x, absMidCoordPos.y) * vec2(float(atlasSizeM.y) / float(atlasSizeM.x), 1.0);
|
||||
vec2 noiseCoord = floor(midCoordPos / 2.0 * packSizeNT / offsetR) / packSizeNT / 3.0;
|
||||
#endif
|
||||
|
||||
if (doTileRandomisation) {
|
||||
vec3 floorWorldPos = floor(playerPos + cameraPosition + 0.001);
|
||||
noiseCoord += 0.84 * (floorWorldPos.xz + floorWorldPos.y);
|
||||
}
|
||||
|
||||
float noiseTexture = texture2DLod(noisetex, noiseCoord, 0.0).r;
|
||||
noiseTexture = noiseTexture + 0.6;
|
||||
float colorBrightness = dot(color, color) * 0.3;
|
||||
#define COATED_TEXTURE_MULT_M COATED_TEXTURE_MULT * 0.0027
|
||||
noiseFactor *= COATED_TEXTURE_MULT_M * max0(1.0 - colorBrightness);
|
||||
noiseFactor *= max(1.0 - miplevel * 0.25, 0.0);
|
||||
noiseTexture = pow(noiseTexture, noiseFactor);
|
||||
color *= noiseTexture;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
ivec3[6] glassOffsets = ivec3[](
|
||||
ivec3( 1, 0, 0),
|
||||
ivec3(-1, 0, 0),
|
||||
ivec3( 0, 1, 0),
|
||||
ivec3( 0,-1, 0),
|
||||
ivec3( 0, 0, 1),
|
||||
ivec3( 0, 0,-1)
|
||||
);
|
||||
|
||||
ivec3[12] glassCornerOffsets = ivec3[](
|
||||
ivec3( 1, 1, 0),
|
||||
ivec3( 1,-1, 0),
|
||||
ivec3(-1, 1, 0),
|
||||
ivec3(-1,-1, 0),
|
||||
ivec3( 0, 1, 1),
|
||||
ivec3( 0, 1,-1),
|
||||
ivec3( 0,-1, 1),
|
||||
ivec3( 0,-1,-1),
|
||||
ivec3( 1, 0, 1),
|
||||
ivec3( 1, 0,-1),
|
||||
ivec3(-1, 0, 1),
|
||||
ivec3(-1, 0,-1)
|
||||
);
|
||||
|
||||
vec2 GetModifiedMidCoord() {
|
||||
float epsilon1 = 0.00001;
|
||||
vec2 midCoord = texCoord - signMidCoordPos * absMidCoordPos;
|
||||
return midCoord - epsilon1;
|
||||
}
|
||||
|
||||
void DoSimpleConnectedGlass(inout vec4 color) {
|
||||
color = texture2DLod(tex, GetModifiedMidCoord() - 0.125 * absMidCoordPos, 0);
|
||||
}
|
||||
|
||||
#ifdef GBUFFERS_WATER
|
||||
void DoConnectedGlass(inout vec4 colorP, inout vec4 color, inout bool noGeneratedNormals, vec3 playerPos, vec3 worldGeoNormal, uint voxelID, bool isPane) {
|
||||
vec3 worldGeoNormalM = vec3( // Fixes Iris 1.8 normal precision issues causing the coordinates to be imperfect
|
||||
round(worldGeoNormal.x),
|
||||
round(worldGeoNormal.y),
|
||||
round(worldGeoNormal.z)
|
||||
);
|
||||
vec3 playerPosM = playerPos - worldGeoNormalM * 0.25;
|
||||
vec3 voxelPos = SceneToVoxel(playerPosM);
|
||||
|
||||
if (CheckInsideVoxelVolume(voxelPos)) {
|
||||
#if IRIS_VERSION >= 10800
|
||||
float epsilon2 = 0.0;
|
||||
#else
|
||||
float epsilon2 = 0.001;
|
||||
#endif
|
||||
float pixelOffset = 0.5 / (absMidCoordPos.y * atlasSize.y);
|
||||
float pixelOffsetPlus = pixelOffset + epsilon2;
|
||||
float pixelOffsetMinus = pixelOffset - epsilon2;
|
||||
|
||||
colorP = texture2DLod(tex, texCoord, 0);
|
||||
vec4 colorPvanilla = colorP;
|
||||
|
||||
vec2 midCoordM = GetModifiedMidCoord();
|
||||
vec3 worldPos = playerPosM + cameraPositionBestFract;
|
||||
vec3 floorWorldPos = floor(worldPos);
|
||||
|
||||
// Remove edges
|
||||
for (int i = 0; i < 6; i++) {
|
||||
uint voxel = GetVoxelVolume(ivec3(voxelPos) + glassOffsets[i]);
|
||||
if (voxel == voxelID) {
|
||||
if (floor(worldPos + glassOffsets[i] * pixelOffsetPlus) != floorWorldPos) {
|
||||
colorP = texture2DLod(tex, midCoordM, 0);
|
||||
}
|
||||
#ifdef GENERATED_NORMALS
|
||||
if (floor(worldPos + glassOffsets[i] * pixelOffsetPlus * 1.25) != floorWorldPos) {
|
||||
noGeneratedNormals = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Fixes the connections by restoring the edges that aren't connected
|
||||
for (int i = 0; i < 6; i++) {
|
||||
uint voxel = GetVoxelVolume(ivec3(voxelPos) + glassOffsets[i]);
|
||||
if (voxel != voxelID) {
|
||||
//if (floor(worldPos + glassOffsets[i] * 0.0625) != floorWorldPos) {
|
||||
if (floor(worldPos + glassOffsets[i] * pixelOffsetMinus) != floorWorldPos) {
|
||||
colorP = colorPvanilla;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPane) {
|
||||
// Fixes lines between layers of glass panes
|
||||
if (NdotU > 0.9) {
|
||||
uint voxel = GetVoxelVolume(ivec3(voxelPos) + ivec3(0, 1, 0));
|
||||
if (voxel == voxelID) discard;
|
||||
}
|
||||
if (NdotU < -0.9) {
|
||||
uint voxel = GetVoxelVolume(ivec3(voxelPos) - ivec3(0, 1, 0));
|
||||
if (voxel == voxelID) discard;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONNECTED_GLASS_CORNER_FIX
|
||||
// Restores corners
|
||||
for (int i = 0; i < 12; i++) {
|
||||
uint voxel = GetVoxelVolume(ivec3(voxelPos) + glassCornerOffsets[i]);
|
||||
if ((voxel != voxelID) && (!isPane || voxel > 0u)) {
|
||||
if (floor((worldPos - glassCornerOffsets[i] * (1.0 - pixelOffsetMinus))) == floorWorldPos) {
|
||||
colorP = colorPvanilla;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
color = colorP * vec4(glColor.rgb, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#ifndef INCLUDE_CUSTOM_EMISSION
|
||||
#define INCLUDE_CUSTOM_EMISSION
|
||||
|
||||
float GetCustomEmission(vec4 specularMap, vec2 texCoordM) {
|
||||
#if CUSTOM_EMISSION_INTENSITY > 0
|
||||
#if RP_MODE == 2 || RP_MODE == 1 && IPBR_EMISSIVE_MODE == 2 // seuspbr
|
||||
float emission = specularMap.b;
|
||||
#elif RP_MODE == 3 || RP_MODE == 1 && IPBR_EMISSIVE_MODE == 3 // labPBR
|
||||
float emission = specularMap.a < 1.0 ? specularMap.a : 0.0;
|
||||
|
||||
vec4 specularMapL0 = texture2DLod(specular, texCoordM, 0);
|
||||
float emissionL0 = specularMapL0.a < 1.0 ? specularMapL0.a : 0.0;
|
||||
emission = min(emission, emissionL0); // Fixes issues caused by mipmaps
|
||||
#endif
|
||||
|
||||
return emission * 0.03 * CUSTOM_EMISSION_INTENSITY;
|
||||
#else
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef IPBR
|
||||
float GetCustomEmissionForIPBR(inout vec4 color, vec4 glColor, float emission) {
|
||||
vec4 specularMap = texture2D(specular, texCoord);
|
||||
|
||||
#if IPBR_EMISSIVE_MODE == 2 // seuspbr
|
||||
if (specularMap.b == 0.0) return emission;
|
||||
#elif IPBR_EMISSIVE_MODE == 3 // labPBR
|
||||
if (specularMap.a == 0.0 || specularMap.a == 1.0) return emission;
|
||||
#endif
|
||||
|
||||
color = texture2D(tex, texCoord) * glColor;
|
||||
|
||||
float customEmission = GetCustomEmission(specularMap, texCoord);
|
||||
return customEmission;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //INCLUDE_CUSTOM_EMISSION
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#define ENTITY_GN_AND_CT
|
||||
#define GENERATED_NORMAL_MULT 100 //[25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200 250 300 400]
|
||||
#define GENERATED_NORMAL_ENTITY_MULT 0 //[0 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200 250 300 400]
|
||||
#define GENERATED_NORMAL_RES 128 //[16 32 64 80 96 112 128 144 160 176 192 208 224 240 256 320 384 448 512]
|
||||
|
||||
const float normalThreshold = 0.05;
|
||||
const float normalClamp = 0.2;
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
#if GENERATED_NORMAL_ENTITY_MULT > 0
|
||||
const float normalMult = GENERATED_NORMAL_ENTITY_MULT * 0.025;
|
||||
#else
|
||||
const float normalMult = GENERATED_NORMAL_MULT * 0.025;
|
||||
#endif
|
||||
#elif !defined GBUFFERS_HAND
|
||||
float normalMult = GENERATED_NORMAL_MULT * 0.025;
|
||||
#else
|
||||
float normalMult = GENERATED_NORMAL_MULT * 0.015;
|
||||
#endif
|
||||
|
||||
float GetDif(float lOriginalAlbedo, vec2 offsetCoord) {
|
||||
#ifndef GBUFFERS_WATER
|
||||
float lNearbyAlbedo = length(texture2D(tex, offsetCoord).rgb);
|
||||
#else
|
||||
vec4 textureSample = texture2D(tex, offsetCoord);
|
||||
float lNearbyAlbedo = length(textureSample.rgb * textureSample.a * 1.5);
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
lOriginalAlbedo = abs(lOriginalAlbedo - 1.0);
|
||||
lNearbyAlbedo = abs(lNearbyAlbedo - 1.0);
|
||||
#endif
|
||||
|
||||
float dif = lOriginalAlbedo - lNearbyAlbedo;
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
dif = -dif;
|
||||
#endif
|
||||
|
||||
#ifndef GBUFFERS_WATER
|
||||
if (dif > 0.0) dif = max(dif - normalThreshold, 0.0);
|
||||
else dif = min(dif + normalThreshold, 0.0);
|
||||
#endif
|
||||
|
||||
return clamp(dif, -normalClamp, normalClamp);
|
||||
}
|
||||
|
||||
void GenerateNormals(inout vec3 normalM, vec3 color) {
|
||||
#ifndef ENTITY_GN_AND_CT
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_HAND
|
||||
return;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 absMidCoordPos2 = absMidCoordPos * 2.0;
|
||||
float lOriginalAlbedo = length(color.rgb);
|
||||
|
||||
#ifndef SAFER_GENERATED_NORMALS
|
||||
vec2 offsetR = 16.0 / atlasSizeM;
|
||||
#else
|
||||
vec2 offsetR = max(absMidCoordPos2.x, absMidCoordPos2.y) * vec2(float(atlasSizeM.y) / float(atlasSizeM.x), 1.0);
|
||||
#endif
|
||||
offsetR /= GENERATED_NORMAL_RES;
|
||||
|
||||
vec2 originalOffsetR = offsetR;
|
||||
offsetR = max(originalOffsetR, fwidth(texCoord));
|
||||
|
||||
vec2 midCoord = texCoord - midCoordPos;
|
||||
vec2 maxOffsetCoord = midCoord + absMidCoordPos;
|
||||
vec2 minOffsetCoord = midCoord - absMidCoordPos;
|
||||
|
||||
vec3 normalMap = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
vec2 offsetCoord = texCoord + vec2(0.0, offsetR.y);
|
||||
if (offsetCoord.y < maxOffsetCoord.y)
|
||||
normalMap.y += GetDif(lOriginalAlbedo, offsetCoord);
|
||||
|
||||
offsetCoord = texCoord + vec2(offsetR.x, 0.0);
|
||||
if (offsetCoord.x < maxOffsetCoord.x)
|
||||
normalMap.x += GetDif(lOriginalAlbedo, offsetCoord);
|
||||
|
||||
offsetCoord = texCoord + vec2(0.0, -offsetR.y);
|
||||
if (offsetCoord.y > minOffsetCoord.y)
|
||||
normalMap.y -= GetDif(lOriginalAlbedo, offsetCoord);
|
||||
|
||||
offsetCoord = texCoord + vec2(-offsetR.x, 0.0);
|
||||
if (offsetCoord.x > minOffsetCoord.x)
|
||||
normalMap.x -= GetDif(lOriginalAlbedo, offsetCoord);
|
||||
|
||||
normalMap.xy *= vec2(normalMult * sqrt(GENERATED_NORMAL_RES / 128.0)) * (originalOffsetR / offsetR);
|
||||
normalMap.xy = clamp(normalMap.xy, vec2(-1.0), vec2(1.0));
|
||||
|
||||
if (normalMap.xy != vec2(0.0, 0.0))
|
||||
normalM = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
vec3 safeRcp(vec3 v) {
|
||||
vec3 signV = mix(vec3(1.0), vec3(-1.0), lessThan(v, vec3(0.0)));
|
||||
return signV / max(abs(v), vec3(1e-6));
|
||||
}
|
||||
|
||||
bool intersectsAABB(vec3 ro, vec3 rd, vec3 aabbMin, vec3 aabbMax) {
|
||||
vec3 invRd = safeRcp(rd);
|
||||
vec3 t0 = (aabbMin - ro) * invRd;
|
||||
vec3 t1 = (aabbMax - ro) * invRd;
|
||||
|
||||
vec3 tMin = min(t0, t1);
|
||||
vec3 tMax = max(t0, t1);
|
||||
|
||||
float m0 = max(max(tMin.x, tMin.y), tMin.z);
|
||||
float m1 = min(min(tMax.x, tMax.y), tMax.z);
|
||||
|
||||
return m1 > max0(m0);
|
||||
}
|
||||
|
||||
bool intersectsParallelogram(vec3 ro, vec3 rd, vec3 v0, vec3 v1, vec3 v2, float tMin, out float t, out vec2 uv, inout vec3 normal) {
|
||||
vec3 a = v1 - v0, n = cross(a, v2 - v0);
|
||||
|
||||
float denom = dot(n, rd);
|
||||
if (abs(denom) < 1e-6) return false;
|
||||
|
||||
t = dot(v0 - ro, n) / denom;
|
||||
if (t < 0.0 || t > tMin) return false;
|
||||
|
||||
vec3 b = v2 - v1;
|
||||
vec3 c = ro + rd * t - v0;
|
||||
|
||||
float aa = dot(a, a);
|
||||
float bb = dot(b, b);
|
||||
if (aa < 1e-6 || bb < 1e-6) return false;
|
||||
|
||||
uv = vec2(dot(c, a) / aa, dot(c, b) / bb);
|
||||
if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return false;
|
||||
|
||||
float nn = dot(n, n);
|
||||
if (nn < 1e-6) return false;
|
||||
normal = n * inversesqrt(nn);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckQuadAt(int i, vec3 playerPos, vec3 rayDir, inout vec3 albedo, inout float tMin, inout vec3 normal, inout float emissionOut) {
|
||||
int i0 = 3 * i, i1 = 3 * i + 1, i2 = 3 * i + 2;
|
||||
|
||||
vec3 v0 = playerVerticesSSBO.vertexPositions[i0];
|
||||
vec3 v1 = playerVerticesSSBO.vertexPositions[i1];
|
||||
vec3 v2 = playerVerticesSSBO.vertexPositions[i2];
|
||||
|
||||
float t = 0.0;
|
||||
vec2 uv = vec2(0.0);
|
||||
|
||||
vec3 colorP = vec3(0.0);
|
||||
vec3 color = vec3(0.0);
|
||||
float emission = 0.0;
|
||||
float smoothnessD, smoothnessG;
|
||||
if (intersectsParallelogram(playerPos, rayDir, v0, v1, v2, tMin, t, uv, normal)) {
|
||||
vec2 texCoord0 = playerVerticesSSBO.vertexData[i0];
|
||||
vec2 texCoord1 = playerVerticesSSBO.vertexData[i1];
|
||||
vec2 texCoord2 = playerVerticesSSBO.vertexData[i2];
|
||||
|
||||
vec2 quadTexCoord = mix(texCoord0, texCoord1, uv.x) + uv.y * (texCoord2 - texCoord1);
|
||||
vec4 playerAtlasSample = texelFetch(playerAtlas_sampler, clamp(ivec2(64.0 * quadTexCoord), ivec2(0), ivec2(63)), 0);
|
||||
|
||||
vec3 colorP = playerAtlasSample.rgb;
|
||||
vec3 color = playerAtlasSample.rgb;
|
||||
|
||||
#ifdef SPACEAGLE17
|
||||
#include "/lib/materials/specificMaterials/others/SpacEagle17.glsl"
|
||||
#endif
|
||||
if (playerAtlasSample.a > 0.2) {albedo = color * (emission * 0.2 + 1.0); tMin = t; emissionOut = emission;}
|
||||
}
|
||||
}
|
||||
|
||||
bool rayTracePlayer(vec3 playerPos, vec3 rayDir, float wsrTraceLength, out vec3 albedo, out vec3 normal, out float emission) {
|
||||
float tMin = wsrTraceLength;
|
||||
vec3 aabbPos = playerPos * 1000.0;
|
||||
|
||||
// Head
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.headMin, playerVerticesSSBO.headMax)) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
// Right Hand
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.rightHandMin, playerVerticesSSBO.rightHandMax)) {
|
||||
for (int i = 12; i < 24; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
// Left Leg
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.leftLegMin, playerVerticesSSBO.leftLegMax)) {
|
||||
for (int i = 24; i < 36; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
// Left Hand
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.leftHandMin, playerVerticesSSBO.leftHandMax)) {
|
||||
for (int i = 36; i < 48; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
// Right leg
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.rightLegMin, playerVerticesSSBO.rightLegMax)) {
|
||||
for (int i = 48; i < 60; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
// Torso
|
||||
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.torsoMin, playerVerticesSSBO.torsoMax)) {
|
||||
for (int i = 60; i < 72; i++) {
|
||||
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
|
||||
}
|
||||
}
|
||||
|
||||
return tMin < wsrTraceLength;
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
#include "/lib/util/dither.glsl"
|
||||
|
||||
vec2 vTexCoord = signMidCoordPos * 0.5 + 0.5;
|
||||
|
||||
#include "/lib/util/dFdxdFdy.glsl"
|
||||
|
||||
vec4 ReadNormal(vec2 coord) {
|
||||
coord = fract(coord) * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
return textureGrad(normals, coord, dcdx, dcdy);
|
||||
}
|
||||
|
||||
vec2 GetParallaxCoord(float parallaxFade, float dither, inout vec2 newCoord, inout float texDepth, inout vec3 traceCoordDepth) {
|
||||
float invParallaxQuality = 1.0 / POM_QUALITY;
|
||||
vec4 normalMap = ReadNormal(vTexCoord.st);
|
||||
vec2 normalMapM = normalMap.xy * 2.0 - 1.0;
|
||||
float normalCheck = normalMapM.x + normalMapM.y;
|
||||
float minHeight = 1.0 - invParallaxQuality;
|
||||
|
||||
if (viewVector.z >= 0.0 || normalMap.a >= minHeight || normalCheck <= -1.999) return vTexCoord.st;
|
||||
|
||||
vec2 interval = viewVector.xy * 0.25 * (1.0 - parallaxFade) * POM_DEPTH / (-viewVector.z * POM_QUALITY);
|
||||
|
||||
float i = 0.0;
|
||||
vec2 localCoord;
|
||||
#if defined GBUFFERS_TERRAIN || defined GBUFFERS_BLOCK
|
||||
if (texDepth <= 1.0 - i * invParallaxQuality) {
|
||||
localCoord = vTexCoord.st + i * interval;
|
||||
texDepth = ReadNormal(localCoord).a;
|
||||
i = dither;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (; i < POM_QUALITY && texDepth <= 1.0 - i * invParallaxQuality; i++) {
|
||||
localCoord = vTexCoord.st + i * interval;
|
||||
texDepth = ReadNormal(localCoord).a;
|
||||
}
|
||||
|
||||
float pI = float(max(i - 1, 0));
|
||||
traceCoordDepth.xy -= pI * interval;
|
||||
traceCoordDepth.z -= pI * invParallaxQuality;
|
||||
|
||||
localCoord = fract(vTexCoord.st + pI * interval);
|
||||
newCoord = localCoord * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
return localCoord;
|
||||
}
|
||||
|
||||
float GetParallaxShadow(float parallaxFade, float dither, float height, vec2 coord, vec3 lightVec, mat3 tbn) {
|
||||
float parallaxshadow = 1.0;
|
||||
|
||||
vec3 parallaxdir = tbn * lightVec;
|
||||
parallaxdir.xy *= 1.0 * POM_DEPTH; // Angle
|
||||
|
||||
for (int i = 0; i < 4 && parallaxshadow >= 0.01; i++) {
|
||||
float stepLC = 0.025 * (i + dither);
|
||||
|
||||
float currentHeight = height + parallaxdir.z * stepLC;
|
||||
|
||||
vec2 parallaxCoord = fract(coord + parallaxdir.xy * stepLC) * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
float offsetHeight = textureGrad(normals, parallaxCoord, dcdx, dcdy).a;
|
||||
|
||||
parallaxshadow *= clamp(1.0 - (offsetHeight - currentHeight) * 4.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
return mix(parallaxshadow, 1.0, parallaxFade);
|
||||
}
|
||||
|
||||
// Big thanks to null511 for slope normals
|
||||
vec3 GetParallaxSlopeNormal(vec2 texCoord, float traceDepth, vec3 viewDir) {
|
||||
vec2 atlasPixelSize = 1.0 / atlasSize;
|
||||
float atlasAspect = atlasSize.x / atlasSize.y;
|
||||
vec2 atlasCoord = fract(texCoord) * vTexCoordAM.pq + vTexCoordAM.st;
|
||||
|
||||
vec2 tileSize = atlasSize * vTexCoordAM.pq;
|
||||
vec2 tilePixelSize = 1.0 / tileSize;
|
||||
|
||||
vec2 tex_snapped = floor(atlasCoord * atlasSize) * atlasPixelSize;
|
||||
vec2 tex_offset = atlasCoord - (tex_snapped + 0.5 * atlasPixelSize);
|
||||
|
||||
vec2 stepSign = sign(tex_offset);
|
||||
vec2 viewSign = sign(viewDir.xy);
|
||||
|
||||
bool dir = abs(tex_offset.x * atlasAspect) < abs(tex_offset.y);
|
||||
vec2 tex_x, tex_y;
|
||||
|
||||
if (dir) {
|
||||
tex_x = texCoord - vec2(tilePixelSize.x * viewSign.x, 0.0);
|
||||
tex_y = texCoord + vec2(0.0, stepSign.y * tilePixelSize.y);
|
||||
}
|
||||
else {
|
||||
tex_x = texCoord + vec2(tilePixelSize.x * stepSign.x, 0.0);
|
||||
tex_y = texCoord - vec2(0.0, viewSign.y * tilePixelSize.y);
|
||||
}
|
||||
|
||||
float height_x = ReadNormal(tex_x).a;
|
||||
float height_y = ReadNormal(tex_y).a;
|
||||
|
||||
if (dir) {
|
||||
if (!(traceDepth > height_y && viewSign.y != stepSign.y)) {
|
||||
if (traceDepth > height_x) return vec3(-viewSign.x, 0.0, 0.0);
|
||||
|
||||
if (abs(viewDir.y) > abs(viewDir.x))
|
||||
return vec3(0.0, -viewSign.y, 0.0);
|
||||
else
|
||||
return vec3(-viewSign.x, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return vec3(0.0, -viewSign.y, 0.0);
|
||||
}
|
||||
else {
|
||||
if (!(traceDepth > height_x && viewSign.x != stepSign.x)) {
|
||||
if (traceDepth > height_y) return vec3(0.0, -viewSign.y, 0.0);
|
||||
|
||||
if (abs(viewDir.y) > abs(viewDir.x))
|
||||
return vec3(0.0, -viewSign.y, 0.0);
|
||||
else
|
||||
return vec3(-viewSign.x, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return vec3(-viewSign.x, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
#if defined END && (defined COMPOSITE || defined GBUFFERS_WATER || defined VOXY_TRANSLUCENT)
|
||||
#include "/lib/atmospherics/volumetricLight/enderBeams.glsl"
|
||||
#include "/lib/atmospherics/volumetricLight/volumetricLight.glsl"
|
||||
#include "/lib/atmospherics/enderStars.glsl"
|
||||
#include "/lib/atmospherics/enderNebula.glsl"
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD && ( defined COMPOSITE && defined SKY_EFFECT_REFLECTION_OPAQUE || !defined COMPOSITE && defined SKY_EFFECT_REFLECTION_TRANSLUCENT)
|
||||
void DoSkyEffectReflection(inout vec3 skyReflection, vec3 playerPos, vec3 normalMR, vec3 nViewPosR, float RVdotU, float RVdotS, float dither, vec3 viewPos, vec3 sunVec, vec3 nViewPos) {
|
||||
float cloudLinearDepth = 1.0;
|
||||
float skyFade = 1.0;
|
||||
vec3 auroraBorealis = vec3(0.0);
|
||||
vec3 nightNebula = vec3(0.0);
|
||||
|
||||
#if AURORA_STYLE > 0
|
||||
auroraBorealis = GetAuroraBorealis(nViewPosR, RVdotU, dither);
|
||||
skyReflection += auroraBorealis;
|
||||
#endif
|
||||
#if NIGHT_NEBULAE == 1
|
||||
nightNebula += GetNightNebula(nViewPosR, RVdotU, RVdotS);
|
||||
skyReflection += nightNebula;
|
||||
#endif
|
||||
|
||||
#ifdef PIXELATED_WATER_REFLECTIONS
|
||||
#if WATER_STYLE < 2
|
||||
vec2 starCoord = GetStarCoord(nViewPosR, 0.5);
|
||||
#else
|
||||
vec2 starCoord = GetStarCoord(nViewPos, 0.5);
|
||||
#endif
|
||||
vec3 absPlayerPos = abs(playerPos);
|
||||
float sizeDecider = -clamp01(pow2(min1(length(absPlayerPos) / 10))) + 1.0; // The effect will only be around the player
|
||||
float starSize = mix(1.0, 2.0, step(0.2, sizeDecider));
|
||||
#else
|
||||
vec2 starCoord = GetStarCoord(nViewPosR, 0.5);
|
||||
float starSize = 1.0;
|
||||
#endif
|
||||
#if STAR_BRIGHTNESS != 3
|
||||
vec3 starColor = GetStars(starCoord, RVdotU, RVdotS, 1.0 * starSize, 0.0);
|
||||
|
||||
#define ADD_STAR_LAYER_OW1 (STAR_LAYER_OW == 1 || STAR_LAYER_OW == 3)
|
||||
#define ADD_STAR_LAYER_OW2 (STAR_LAYER_OW == 2 || STAR_LAYER_OW == 3)
|
||||
|
||||
#if ADD_STAR_LAYER_OW1
|
||||
starColor = max(starColor, GetStars(starCoord, RVdotU, RVdotS, 0.66 * starSize, 0.0));
|
||||
#endif
|
||||
|
||||
#if ADD_STAR_LAYER_OW2
|
||||
starColor = max(starColor, GetStars(starCoord, RVdotU, RVdotS, 2.2 * starSize, 0.45));
|
||||
#endif
|
||||
|
||||
skyReflection += starColor;
|
||||
#endif
|
||||
|
||||
#ifdef VL_CLOUDS_ACTIVE
|
||||
vec3 worldNormalMR = normalize(mat3(gbufferModelViewInverse) * normalMR);
|
||||
vec3 cameraPosOffset = 2.0 * worldNormalMR * dot(playerPos, worldNormalMR);
|
||||
vec3 RPlayerPos = normalize(mat3(gbufferModelViewInverse) * nViewPosR);
|
||||
float RlViewPos = 100000.0;
|
||||
|
||||
vec4 clouds = GetClouds(cloudLinearDepth, skyFade, cameraPosOffset, RPlayerPos,
|
||||
viewPos, RlViewPos, RVdotS, RVdotU, dither, auroraBorealis, nightNebula, sunVec);
|
||||
|
||||
skyReflection = mix(skyReflection, clouds.rgb, clouds.a);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void AddBackgroundReflection(inout vec4 reflection, vec3 color, vec3 playerPos, vec3 normalM, vec3 normalMR, vec3 viewPos, vec3 nViewPos, vec3 nViewPosR,
|
||||
vec3 shadowMult, float RVdotU, float RVdotS, float z0, float dither, float skyLightFactor, float smoothness, float highlightMult) {
|
||||
#ifdef OVERWORLD
|
||||
bool isCustomSky;
|
||||
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2
|
||||
vec3 skyReflection = GetSkyReflected(RVdotU, RVdotS, dither, isEyeInWater == 0, true, isCustomSky);
|
||||
#else
|
||||
vec3 skyReflection = GetLowQualitySkyReflected(RVdotU, RVdotS, dither, isEyeInWater == 0, true, isCustomSky);
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
skyReflection *= atmColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
skyReflection *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#ifdef SKY_EFFECT_REFLECTION_OPAQUE
|
||||
DoSkyEffectReflection(skyReflection, playerPos, normalMR, nViewPosR, RVdotU, RVdotS, dither, viewPos, sunVec, nViewPos);
|
||||
#endif
|
||||
|
||||
skyReflection *= skyLightFactor;
|
||||
#else
|
||||
float specularHighlight = GGX(normalM, nViewPos, lightVec, max(dot(normalM, lightVec), 0.0), smoothness, 0.05);
|
||||
skyReflection += specularHighlight * highlightColor * shadowMult * highlightMult * invRainFactor;
|
||||
|
||||
#if WATER_REFLECT_QUALITY >= 1
|
||||
#ifdef SKY_EFFECT_REFLECTION_TRANSLUCENT
|
||||
DoSkyEffectReflection(skyReflection, playerPos, normalMR, nViewPosR, RVdotU, RVdotS, dither, viewPos, sunVec, nViewPos);
|
||||
#endif
|
||||
|
||||
skyReflection = mix(color * 0.5, skyReflection, skyLightFactor);
|
||||
#else
|
||||
skyReflection = mix(color, skyReflection, skyLightFactor * 0.5);
|
||||
#endif
|
||||
#endif
|
||||
#elif defined END
|
||||
#if defined COMPOSITE || defined GBUFFERS_WATER || defined VOXY_TRANSLUCENT
|
||||
#ifdef COMPOSITE
|
||||
float vlFactorM = vlFactor;
|
||||
#elif defined GBUFFERS_WATER
|
||||
float vlFactorM = texelFetch(colortex5, ivec2(viewWidth-1, viewHeight-1), 0).a;
|
||||
#elif defined VOXY_TRANSLUCENT
|
||||
float vlFactorM = texelFetch(gaux2, ivec2(viewWidth-1, viewHeight-1), 0).a;
|
||||
#endif
|
||||
|
||||
vec3 translucentMult = vec3(1.0);
|
||||
float lViewPos = 100000.0;
|
||||
float lViewPos1 = 100000.0;
|
||||
vec4 volumetricEffect = GetVolumetricLight(vlFactorM, translucentMult, lViewPos, lViewPos1, nViewPosR, RVdotS, RVdotU, z0, z0, z0, dither);
|
||||
|
||||
volumetricEffect.rgb = pow(volumetricEffect.rgb, vec3(1.0 / 2.2));
|
||||
|
||||
#ifdef COMPOSITE
|
||||
volumetricEffect.rgb *= 1.25;
|
||||
#endif
|
||||
|
||||
#ifndef END_BEAMS
|
||||
volumetricEffect.rgb = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#if BLACK_HOLE > 0
|
||||
vec3 blackHoleDir = getBlackHoleDir();
|
||||
#endif
|
||||
|
||||
vec3 enderNebula = vec3(0.0);
|
||||
#if END_NEBULA > 0
|
||||
vec3 nebulaViewPos = nViewPosR;
|
||||
#if BLACK_HOLE > 0
|
||||
nebulaViewPos = GetBlackHoleLensedDirection(nViewPosR, blackHoleDir);
|
||||
#endif
|
||||
|
||||
enderNebula += GetEnderNebula(nebulaViewPos, RVdotU);
|
||||
#endif
|
||||
|
||||
vec3 enderStars = vec3(0.0);
|
||||
#ifdef END_STARS
|
||||
vec3 starViewPos = nViewPosR;
|
||||
float starVdotU = RVdotU;
|
||||
#if BLACK_HOLE > 0
|
||||
starViewPos = GetBlackHoleLensedDirection(nViewPosR, blackHoleDir);
|
||||
#endif
|
||||
|
||||
vec3 starColor = GetEnderStars(starViewPos, starVdotU, 1.0, 0.0);
|
||||
|
||||
#define ADD_STAR_LAYER_END1 (STAR_LAYER_END == 1 || STAR_LAYER_END == 3)
|
||||
#define ADD_STAR_LAYER_END2 (STAR_LAYER_END == 2 || STAR_LAYER_END == 3)
|
||||
|
||||
#if ADD_STAR_LAYER_END1
|
||||
starColor = max(starColor, GetEnderStars(starViewPos, starVdotU, 0.66, 0.0));
|
||||
#endif
|
||||
|
||||
#if ADD_STAR_LAYER_END2
|
||||
starColor = max(starColor, GetEnderStars(starViewPos, starVdotU, 2.2, 0.33));
|
||||
#endif
|
||||
|
||||
enderStars += starColor;
|
||||
#endif
|
||||
|
||||
#if BLACK_HOLE > 0
|
||||
vec4 blackHole = GetBlackHole(nViewPosR, blackHoleDir);
|
||||
enderStars = mix(enderStars, vec3(0.0), blackHole.a);
|
||||
enderStars += blackHole.rgb;
|
||||
#endif
|
||||
|
||||
vec3 skyReflection = (endSkyColor + enderNebula + enderStars + volumetricEffect.rgb) * skyLightFactor;
|
||||
#else
|
||||
vec3 skyReflection = endSkyColor * skyLightFactor;
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
skyReflection *= atmColorMult;
|
||||
#endif
|
||||
#else
|
||||
vec3 skyReflection = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && defined COMPOSITE && (BLOCK_REFLECT_QUALITY >= 2 || WATER_REFLECT_QUALITY >= 2)
|
||||
float traceLength = far;
|
||||
vec4 wsrReflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither, traceLength, false);
|
||||
refDist = min(refDist, traceLength);
|
||||
|
||||
reflection = mix(wsrReflection, vec4(reflection.rgb, 1.0), reflection.a);
|
||||
#endif
|
||||
|
||||
reflection.rgb = mix(skyReflection, reflection.rgb, reflection.a);
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
vec4 sampleBlurFilteredReflection(vec4 centerCol, vec3 nViewPos, float dither, float z0) {
|
||||
vec4 texture4 = texture2D(colortex4, texCoord);
|
||||
|
||||
const float spatialFactor = 2.5; // higher = smoother in space
|
||||
const float spatialFactorM = 2.0 * spatialFactor * spatialFactor;
|
||||
|
||||
vec4 sum = vec4(0.0);
|
||||
float weightSum = 0.0;
|
||||
vec2 texelSize = (3.0 + 6.0 * dither) / view; // 1 pixel range doesn't seem to be enough to smooth things out
|
||||
|
||||
#ifdef SMOOTHNESS_AFFECTED_REF_BLUR
|
||||
vec3 texture6 = texelFetch(colortex6, texelCoord, 0).rgb;
|
||||
float smoothnessD = texture6.r;
|
||||
texelSize *= 1.0 - 0.75 * pow2(pow2(pow2(smoothnessD)));
|
||||
#endif
|
||||
|
||||
#ifdef REFLECTION_BLUR_DEPTH_CHECK
|
||||
float linearZ0 = GetLinearDepth(z0);
|
||||
|
||||
vec3 normalM = mat3(gbufferModelView) * texture4.rgb;
|
||||
float fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
|
||||
float blurDepthCheckThreshold = (2.0 + pow2(pow2(fresnel)) * 35.0) / far;
|
||||
#endif
|
||||
|
||||
int k = 2;
|
||||
for (int dy = -k; dy <= k; dy++) {
|
||||
for (int dx = -k; dx <= k; dx++) {
|
||||
vec2 offset = vec2(float(dx), float(dy)) * texelSize;
|
||||
vec2 sampleCoord = texCoord + offset;
|
||||
vec4 sampleCol = texture2D(colortex7, sampleCoord);
|
||||
|
||||
// Skip step if normals are too different
|
||||
vec4 texture1Sample = texture2D(colortex1, sampleCoord);
|
||||
if (length(texture4.rgb - texture1Sample.rgb) > 0.1 + 0.075 * dither) continue;
|
||||
|
||||
// Skip if depth is too different (costs performance for a tiny fix)
|
||||
#ifdef REFLECTION_BLUR_DEPTH_CHECK
|
||||
if (abs(GetLinearDepth(texture2D(depthtex0, sampleCoord).r) - linearZ0) > blurDepthCheckThreshold) continue;
|
||||
#endif
|
||||
|
||||
// Spatial weight (gaussian)
|
||||
float spatialDist2 = float(dx*dx + dy*dy);
|
||||
float weight = exp(-spatialDist2 / spatialFactorM);
|
||||
|
||||
sum += sampleCol * weight;
|
||||
weightSum += weight;
|
||||
}
|
||||
}
|
||||
|
||||
return sum / weightSum;
|
||||
}
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
#include "/lib/misc/reprojection.glsl"
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sky.glsl"
|
||||
#include "/lib/shaderSettings/stars.glsl"
|
||||
#ifdef END_PORTAL_BEAM_INTERNAL
|
||||
#include "/lib/atmospherics/endPortalBeam.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
#include "/lib/shaderSettings/endBeams.glsl"
|
||||
#ifdef COMPOSITE
|
||||
#include "/lib/atmospherics/volumetricLight/enderBeams.glsl"
|
||||
#endif
|
||||
#if END_CRYSTAL_VORTEX_INTERNAL > 0 || DRAGON_DEATH_EFFECT_INTERNAL > 0
|
||||
#include "/lib/atmospherics/endCrystalVortex.glsl"
|
||||
#endif
|
||||
#include "/lib/atmospherics/fog/endCenterFog.glsl"
|
||||
#include "/lib/shaderSettings/blackHole.glsl"
|
||||
|
||||
#if BLACK_HOLE > 0
|
||||
#include "/lib/atmospherics/blackHole.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ATM_COLOR_MULTS
|
||||
#include "/lib/colors/colorMultipliers.glsl"
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_ATMOSPHERE
|
||||
#include "/lib/colors/moonPhaseInfluence.glsl"
|
||||
#endif
|
||||
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && defined COMPOSITE
|
||||
#include "/lib/voxelization/lightVoxelization.glsl"
|
||||
#include "/lib/materials/materialMethods/worldSpaceRef.glsl"
|
||||
#endif
|
||||
|
||||
float GetApproxDistance(float depth) {
|
||||
return near * far / (far - depth * far);
|
||||
}
|
||||
|
||||
vec3 nvec3(vec4 pos) {
|
||||
return pos.xyz/pos.w;
|
||||
}
|
||||
float refDist = far;
|
||||
|
||||
#include "/lib/materials/materialMethods/reflectionBackground.glsl"
|
||||
|
||||
vec4 GetReflection(inout vec3 normalM, vec3 viewPos, vec3 nViewPos, vec3 playerPos, float lViewPos, float z0,
|
||||
sampler2D depthtex, float dither, float skyLightFactor, float fresnel,
|
||||
float smoothness, vec3 geoNormal, vec3 color, vec3 shadowMult, float highlightMult, float enderDragonDead, vec2 texelOffset) {
|
||||
// ============================== Step 1: Prepare ============================== //
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL == -1
|
||||
vec2 rEdge = vec2(0.6, 0.55);
|
||||
#else
|
||||
vec2 rEdge = vec2(0.525, 0.525);
|
||||
#endif
|
||||
vec3 normalMR = normalM;
|
||||
#if defined PIXELATED_WATER_REFLECTIONS && defined GBUFFERS_WATER
|
||||
playerPos = TexelSnap(playerPos, texelOffset);
|
||||
viewPos = TexelSnap(viewPos, texelOffset);
|
||||
nViewPos = TexelSnap(nViewPos, texelOffset);
|
||||
lViewPos = TexelSnap(lViewPos, texelOffset);
|
||||
fresnel = TexelSnap(fresnel, texelOffset);
|
||||
|
||||
// Fixes NaN happening further down the road because of bad nViewPos.
|
||||
nViewPos *= inversesqrt(max(dot(nViewPos, nViewPos), eps));
|
||||
#endif
|
||||
|
||||
#if defined GBUFFERS_WATER && WATER_STYLE == 1 && defined GENERATED_NORMALS
|
||||
normalMR = normalize(mix(geoNormal, normalM, 0.05));
|
||||
#endif
|
||||
|
||||
vec3 nViewPosR = normalize(reflect(nViewPos, normalMR));
|
||||
float RVdotU = dot(nViewPosR, upVec);
|
||||
float RVdotS = dot(nViewPosR, sunVec);
|
||||
vec3 worldRefDir = 0.5 * far * (mat3(gbufferModelViewInverse) * nViewPosR);
|
||||
|
||||
#if defined GBUFFERS_WATER && WATER_STYLE >= 2
|
||||
normalMR = normalize(mix(geoNormal, normalM, 0.8));
|
||||
#endif
|
||||
// ============================== End of Step 1 ============================== //
|
||||
|
||||
// ============================== Step 2: Calculate Terrain Reflection and Alpha ============================== //
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && defined COMPOSITE && WATER_REFLECT_QUALITY >= 1
|
||||
// In COMPOSITE for translucents we just need to return WSR and that's it
|
||||
if (z0 != z1) {
|
||||
vec4 reflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither, refDist, true);
|
||||
return reflection;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 reflection = vec4(0.0);
|
||||
vec3 refPos = vec3(0.0);
|
||||
vec3 reflectionColor = vec3(0.0);
|
||||
#if (defined COMPOSITE || WATER_REFLECT_QUALITY >= 1) && (WORLD_SPACE_REFLECTIONS_INTERNAL == -1 || WORLD_SPACE_REF_MODE == 2)
|
||||
// Method 1: Ray Marched Reflection //
|
||||
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2
|
||||
// Ray Marching
|
||||
vec3 start = viewPos + normalMR * (lViewPos * 0.025 * (1.0 - fresnel) + 0.05);
|
||||
#if defined GBUFFERS_WATER && WATER_STYLE >= 2
|
||||
vec3 vector = normalize(reflect(nViewPos, normalMR)); // Not using nViewPosR because normalMR changed
|
||||
#else
|
||||
vec3 vector = nViewPosR;
|
||||
#endif
|
||||
vector *= 0.5;
|
||||
vec3 vectorBase = vector;
|
||||
vec3 viewPosRT = viewPos + vector;
|
||||
vec3 tvector = vector;
|
||||
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL == -1
|
||||
int sampleCount = 30;
|
||||
int refinementCount = 6;
|
||||
#else
|
||||
int sampleCount = 38;
|
||||
int refinementCount = 10;
|
||||
#endif
|
||||
|
||||
int sr = 0;
|
||||
float dist = 0.0;
|
||||
vec3 rfragpos = vec3(0.0);
|
||||
float err = 9999999.0;
|
||||
float sampleDepth = 1.0;
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
refPos = nvec3(gbufferProjection * vec4(viewPosRT, 1.0)) * 0.5 + 0.5;
|
||||
if (abs(refPos.x - 0.5) > rEdge.x || abs(refPos.y - 0.5) > rEdge.y) break;
|
||||
|
||||
sampleDepth = texture2D(depthtex, refPos.xy).r;
|
||||
rfragpos = nvec3(gbufferProjectionInverse * vec4(vec3(refPos.xy, sampleDepth) * 2.0 - 1.0, 1.0));
|
||||
|
||||
#if defined GBUFFERS_WATER && (defined DISTANT_HORIZONS || defined VOXY)
|
||||
if (sampleDepth >= 1.0) {
|
||||
#ifdef VOXY
|
||||
sampleDepth = texture2D(vxDepthTexOpaque, refPos.xy).r;
|
||||
if (sampleDepth < 1.0) {
|
||||
rfragpos = nvec3(vxProjInv * vec4(vec3(refPos.xy, sampleDepth) * 2.0 - 1.0, 1.0));
|
||||
}
|
||||
#endif
|
||||
#ifdef DISTANT_HORIZONS
|
||||
sampleDepth = texture2D(dhDepthTex1, refPos.xy).r;
|
||||
if (sampleDepth < 1.0) {
|
||||
rfragpos = nvec3(dhProjectionInverse * vec4(vec3(refPos.xy, sampleDepth) * 2.0 - 1.0, 1.0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
dist = length(start - rfragpos);
|
||||
|
||||
err = length(viewPosRT - rfragpos);
|
||||
if (err * 0.33333 < length(vector)) {
|
||||
sr++;
|
||||
if (sr >= refinementCount) break;
|
||||
tvector -= vector;
|
||||
vector *= 0.1;
|
||||
}
|
||||
vector *= 2.0;
|
||||
tvector += vector * (0.95 + 0.1 * dither);
|
||||
viewPosRT = start + tvector;
|
||||
}
|
||||
|
||||
float lViewPosRT = length(rfragpos);
|
||||
refPos.z = sampleDepth;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
bool possibleReflection = true;
|
||||
#else
|
||||
vec3 viewRefPos = ScreenToView(refPos);
|
||||
// #ifdef VOXY
|
||||
// vec3 viewRefPosVx = ScreenToViewVoxy(refPos);
|
||||
// if (length(viewRefPos) < length(viewRefPosVx)) viewRefPos = viewRefPosVx;
|
||||
// #endif
|
||||
bool possibleReflection = dot(normalize(viewRefPos - start), geoNormal) > 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef VOXY_PATCH
|
||||
if (refPos.x > 0.0 && refPos.x < 1.0 && refPos.y > 0.0 && refPos.y < 1.0)
|
||||
{
|
||||
// Previous frame reprojection from Chocapic13
|
||||
// Voxy water needs reflection reprojection due to rendering before deferred
|
||||
vec4 viewPosPrev = vxProjInv * vec4(refPos * 2.0 - 1.0, 1.0);
|
||||
viewPosPrev /= viewPosPrev.w;
|
||||
|
||||
viewPosPrev = vxModelViewInv * viewPosPrev;
|
||||
|
||||
vec4 previousPosition = viewPosPrev + vec4(cameraPosition - previousCameraPosition, 0.0);
|
||||
previousPosition = vxModelViewPrev * previousPosition;
|
||||
previousPosition = vxProjPrev * previousPosition;
|
||||
refPos.xy = previousPosition.xy / previousPosition.w * 0.5 + 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Finalizing Terrain Reflection and Alpha
|
||||
if (
|
||||
refPos.z < 1.0
|
||||
&& possibleReflection
|
||||
&& (err * (1.0 - fresnel) < 1.0 + lViewPosRT * 0.2)
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && COLORED_LIGHTING_INTERNAL >= 256
|
||||
&& (err < 2.0 + pow2(lViewPosRT) * 0.001 || lViewPosRT > 0.25 * COLORED_LIGHTING_INTERNAL)
|
||||
#endif
|
||||
) {
|
||||
vec2 absPos = abs(refPos.xy - 0.5);
|
||||
vec2 cdist = absPos / rEdge;
|
||||
float border = clamp(1.0 - pow(max(cdist.x, cdist.y), 50.0), 0.0, 1.0);
|
||||
reflection.a = border;
|
||||
|
||||
if (reflection.a > 0.001) {
|
||||
vec2 edgeFactor = pow2(pow2(pow2(cdist)));
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL == -1
|
||||
refPos.y += (dither - 0.5) * (0.05 * (edgeFactor.x + edgeFactor.y));
|
||||
#endif
|
||||
|
||||
#if defined GBUFFERS_WATER || defined DH_WATER || defined VOXY_PATCH
|
||||
#ifndef VOXY_PATCH
|
||||
reflection = vec4(texture2D(gaux2, refPos.xy).rgb, 1.0);
|
||||
#else
|
||||
reflection = vec4(texture2D(colortex19, refPos.xy).rgb, 1.0);
|
||||
#endif
|
||||
reflection.rgb = pow2(reflection.rgb * 2.0);
|
||||
#else
|
||||
#ifdef BETTER_LABPBR_REFLECTIONS_INTERNAL
|
||||
float roughnessDM = pow2(1.0 - smoothness); // ImprPBRPow2
|
||||
#else
|
||||
float roughnessDM = 1.0 - pow2(smoothness);
|
||||
#endif
|
||||
float lodFactor = 1.0 - exp(-0.125 * roughnessDM * dist);
|
||||
float lod = log2(viewHeight / 8.0 * roughnessDM * lodFactor) * 0.45;
|
||||
if (z0 <= 0.56) lod *= 2.22; // Using more lod to compensate for less roughness noise on held items
|
||||
lod = max(lod - 1.0, 0.0);
|
||||
|
||||
reflection.rgb = texture2DLod(colortex0, refPos.xy, lod).rgb;
|
||||
reflectionColor = reflection.rgb;
|
||||
|
||||
#endif
|
||||
|
||||
float skyFade = 0.0;
|
||||
|
||||
#if defined GBUFFERS_WATER || defined DH_WATER || defined VOXY_PATCH
|
||||
float reflectionPrevAlpha = reflection.a;
|
||||
DoFog(reflection, skyFade, lViewPosRT, ViewToPlayer(rfragpos.xyz), RVdotU, RVdotS, dither, true, lViewPos);
|
||||
reflection.a = reflectionPrevAlpha;
|
||||
//reflection.a *= 1.0 - skyFade;
|
||||
#endif
|
||||
|
||||
edgeFactor.x = pow2(edgeFactor.x);
|
||||
edgeFactor = 1.0 - edgeFactor;
|
||||
float refFactor = pow(edgeFactor.x * edgeFactor.y, 2.0 + 3.0 * GetLuminance(reflection.rgb));
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && defined GBUFFERS_WATER
|
||||
refFactor = min(refFactor, 0.1) * 10.0;
|
||||
#endif
|
||||
reflection.a *= refFactor;
|
||||
refDist = dist;
|
||||
}
|
||||
|
||||
float posDif = lViewPosRT - lViewPos;
|
||||
reflection.a *= clamp(posDif + 3.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Method 2: Mirorred Image Reflection //
|
||||
#if !defined COMPOSITE && WATER_REFLECT_QUALITY < 2
|
||||
#if WATER_REFLECT_QUALITY < 2 && !defined DISTANT_HORIZONS
|
||||
float verticalStretch = 0.013;
|
||||
#else
|
||||
float verticalStretch = 0.0025;
|
||||
#endif
|
||||
|
||||
vec4 clipPosR = gbufferProjection * vec4(nViewPosR + verticalStretch * viewPos, 1.0);
|
||||
vec3 screenPosR = clipPosR.xyz / clipPosR.w * 0.5 + 0.5;
|
||||
vec2 screenPosRM = abs(screenPosR.xy - 0.5);
|
||||
|
||||
if (screenPosRM.x < rEdge.x && screenPosRM.y < rEdge.y) {
|
||||
vec2 edgeFactor = pow2(pow2(pow2(screenPosRM / rEdge)));
|
||||
screenPosR.y += (dither - 0.5) * (0.03 * (edgeFactor.x + edgeFactor.y) + 0.001);
|
||||
float z1R = texture2D(depthtex1, screenPosR.xy).x;
|
||||
screenPosR.z = z1R;
|
||||
vec3 viewPosR = ScreenToView(screenPosR);
|
||||
float lViewPosR = length(viewPosR);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float z1RDH = texture2D(dhDepthTex, screenPosR.xy).x;
|
||||
vec4 screenPos1DH = vec4(screenPosR.xy, z1RDH, 1.0);
|
||||
vec4 viewPos1DH = dhProjectionInverse * (screenPos1DH * 2.0 - 1.0);
|
||||
viewPos1DH /= viewPos1DH.w;
|
||||
lViewPosR = min(lViewPosR, length(viewPos1DH.xyz));
|
||||
|
||||
z1R = min(z1R, z1RDH);
|
||||
#endif
|
||||
|
||||
if (z1R < 0.9999 && lViewPos <= 2.0 + lViewPosR) {
|
||||
reflection.rgb = texture2D(gaux2, screenPosR.xy).rgb;
|
||||
reflection.rgb = pow2(reflection.rgb * 2.0);
|
||||
|
||||
edgeFactor = 1.0 - edgeFactor;
|
||||
reflection.a = edgeFactor.x * pow2(edgeFactor.y);
|
||||
reflection.a *= clamp01((dot(nViewPos, nViewPosR) - 0.45) * 10.0); // Fixes perpendicular ref bug
|
||||
|
||||
#ifdef BORDER_FOG
|
||||
float fog = lViewPosR / renderDistance;
|
||||
fog = pow2(pow2(fog));
|
||||
#ifndef DISTANT_HORIZONS
|
||||
fog = pow2(pow2(fog));
|
||||
#endif
|
||||
reflection.a *= exp(-3.0 * fog);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// ============================== End of Step 2 ============================== //
|
||||
|
||||
// ============================== Step 3: Add Sky or WSR Reflection ============================== //
|
||||
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 1
|
||||
if (reflection.a < 1.0)
|
||||
#endif
|
||||
{
|
||||
AddBackgroundReflection(reflection, color, playerPos, normalM, normalMR, viewPos, nViewPos, nViewPosR,
|
||||
shadowMult, RVdotU, RVdotS, z0, dither, skyLightFactor, smoothness, highlightMult);
|
||||
}
|
||||
// ============================== End of Step 3 ============================== //
|
||||
|
||||
// Tweak for wsr water ref normals to look correct
|
||||
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0 && WATER_REFLECT_QUALITY >= 1
|
||||
normalM = normalMR;
|
||||
#endif
|
||||
|
||||
#if (defined COMPOSITE || WATER_REFLECT_QUALITY >= 2) && (END_CRYSTAL_VORTEX_INTERNAL > 0 || DRAGON_DEATH_EFFECT_INTERNAL > 0)
|
||||
reflection.rgb += EndCrystalVortices(playerPos, worldRefDir, dither).rgb;
|
||||
#endif
|
||||
#if (defined COMPOSITE || WATER_REFLECT_QUALITY >= 2) && defined END_PORTAL_BEAM_INTERNAL && !defined DH_WATER
|
||||
vec4 refPosPlayer = gbufferModelViewInverse * (gbufferProjectionInverse * vec4(refPos * 2.0 - 1.0, 1.0));
|
||||
refPosPlayer /= refPosPlayer.w;
|
||||
reflection.rgb += sqrt(GetEndPortalBeam(playerPos, refPosPlayer.xyz * reflection.a - playerPos).rgb);
|
||||
#endif
|
||||
|
||||
#if (defined COMPOSITE || WATER_REFLECT_QUALITY >= 2) && (WORLD_SPACE_REFLECTIONS_INTERNAL == -1 || WORLD_SPACE_REF_MODE == 2) && defined END && END_CENTER_LIGHTING > 0 && MC_VERSION >= 10900 && !defined DH_WATER
|
||||
if (reflection.a < 1.0) {
|
||||
float attentuation = doEndCenterFog(playerPos + cameraPositionBest, worldRefDir.xyz, length(viewPosRT - start), 0.07);
|
||||
vec3 pointLightFog = vec3(END_CENTER_LIGHTING_R, END_CENTER_LIGHTING_G + 0.05, END_CENTER_LIGHTING_B) * 0.355 * END_CENTER_LIGHTING * attentuation * enderDragonDead;
|
||||
reflection.rgb += sqrt(clamp01(pointLightFog - reflectionColor));
|
||||
}
|
||||
#endif
|
||||
|
||||
return reflection;
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
float GetApproxDistance(float depth) {
|
||||
return near * far / (far - depth * far);
|
||||
}
|
||||
|
||||
vec2 DoRefraction(inout vec3 color, inout float z0, inout float z1, vec3 viewPos, float lViewPos) {
|
||||
// Prep
|
||||
if (int(texelFetch(colortex6, texelCoord, 0).g * 255.1) != 241) return texCoord.xy;
|
||||
|
||||
float fovScale = gbufferProjection[1][1];
|
||||
|
||||
vec3 playerPos = ViewToPlayer(viewPos.xyz);
|
||||
vec3 worldPos = playerPos.xyz + cameraPosition.xyz;
|
||||
vec2 worldPosRM = worldPos.xz * 0.02 + worldPos.y * 0.01 + 0.01 * frameTimeCounter;
|
||||
|
||||
vec2 refractNoise = texture2DLod(noisetex, worldPosRM, 0.0).rb - vec2(0.5);
|
||||
refractNoise *= WATER_REFRACTION_INTENSITY * fovScale / (3.0 + lViewPos);
|
||||
|
||||
#if WATER_STYLE < 3
|
||||
refractNoise *= 0.015;
|
||||
#else
|
||||
refractNoise *= 0.02;
|
||||
#endif
|
||||
|
||||
// Check
|
||||
float approxDif = GetApproxDistance(z1) - GetApproxDistance(z0);
|
||||
refractNoise *= clamp(approxDif, 0.0, 1.0);
|
||||
|
||||
vec2 refractCoord = texCoord.xy + refractNoise;
|
||||
|
||||
if (int(texture2D(colortex6, refractCoord).g * 255.1) != 241) return texCoord.xy;
|
||||
|
||||
float z0check = texture2D(depthtex0, refractCoord).r;
|
||||
float z1check = texture2D(depthtex1, refractCoord).r;
|
||||
float approxDifCheck = GetApproxDistance(z1check) - GetApproxDistance(z0check);
|
||||
refractNoise *= clamp(approxDifCheck, 0.0, 1.0);
|
||||
|
||||
// Sample
|
||||
refractCoord = texCoord.xy + refractNoise;
|
||||
color = texture2D(colortex0, refractCoord).rgb;
|
||||
z0 = texture2D(depthtex0, refractCoord).r;
|
||||
z1 = texture2D(depthtex1, refractCoord).r;
|
||||
return refractCoord;
|
||||
}
|
||||
|
||||
#ifdef BETTER_LABPBR_REFRACTIONS_INTERNAL
|
||||
vec3 GetViewPosAt(ivec2 coord) {
|
||||
vec4 screenPos = vec4((vec2(coord) + 0.5) / vec2(viewWidth, viewHeight), texelFetch(depthtex0, coord, 0).r, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
return viewPos.xyz / viewPos.w;
|
||||
}
|
||||
|
||||
vec3 GetFlatNormalFromDepth(vec3 viewPos, ivec2 coord, out bool isEdge) {
|
||||
// Needs to be this complex to avoid artifacts at the edge of translucent blocks T-T
|
||||
vec3 ddxL = viewPos - GetViewPosAt(coord - ivec2(1, 0));
|
||||
vec3 ddxR = GetViewPosAt(coord + ivec2(1, 0)) - viewPos;
|
||||
vec3 ddyD = viewPos - GetViewPosAt(coord - ivec2(0, 1));
|
||||
vec3 ddyU = GetViewPosAt(coord + ivec2(0, 1)) - viewPos;
|
||||
|
||||
vec3 ddx = dot(ddxL, ddxL) < dot(ddxR, ddxR) ? ddxL : ddxR;
|
||||
vec3 ddy = dot(ddyD, ddyD) < dot(ddyU, ddyU) ? ddyD : ddyU;
|
||||
|
||||
isEdge = max(dot(ddx, ddx), dot(ddy, ddy)) > pow2(length(viewPos) * 0.01);
|
||||
vec3 flatNormal = normalize(cross(ddx, ddy));
|
||||
return dot(flatNormal, viewPos) > 0.0 ? -flatNormal : flatNormal;
|
||||
}
|
||||
|
||||
vec2 DoLabPBRRefraction(inout vec3 color, inout float z0, inout float z1, vec3 viewPos, vec2 texCoordM) {
|
||||
if (z0 == z1) return texCoordM; // No translucent surface in front of anything here
|
||||
|
||||
bool isHand = z0 <= 0.56;
|
||||
|
||||
// Rely on the fact that gbuffers_water is the only gbuffer that sets colortex.r to 1.0
|
||||
// That way we filter out entities/particles. Hand we can still include via depth check.
|
||||
if (texelFetch(colortex6, texelCoord, 0).r < 0.999 && !isHand) return texCoordM;
|
||||
|
||||
int materialMaskInt = int(texelFetch(colortex6, texelCoord, 0).g * 255.1);
|
||||
if (materialMaskInt == 241) return texCoordM; // Water already has its own dedicated refraction above
|
||||
|
||||
// Only refract the translucent pixels. Solid ones shuld return the original coord, solid ones have color of 1.0
|
||||
if (texelFetch(colortex3, texelCoord, 0).rgb == vec3(1.0)) return texCoordM;
|
||||
|
||||
// normalM is stored in world space, need in view space
|
||||
vec3 normalM = mat3(gbufferModelView) * texelFetch(colortex4, texelCoord, 0).xyz;
|
||||
|
||||
vec3 flatNormal;
|
||||
float refDistance;
|
||||
if (isHand) {
|
||||
// Blur the hand normals as I can't think of a better way to get a flat normal for the hand.
|
||||
vec3 nSum = texelFetch(colortex4, texelCoord + ivec2( 3, 0), 0).xyz
|
||||
+ texelFetch(colortex4, texelCoord + ivec2(-3, 0), 0).xyz
|
||||
+ texelFetch(colortex4, texelCoord + ivec2( 0, 3), 0).xyz
|
||||
+ texelFetch(colortex4, texelCoord + ivec2( 0, -3), 0).xyz;
|
||||
flatNormal = mat3(gbufferModelView) * normalize(nSum);
|
||||
refDistance = 3.0; // random number that looks good yay
|
||||
} else {
|
||||
bool isEdge;
|
||||
flatNormal = GetFlatNormalFromDepth(viewPos, texelCoord, isEdge);
|
||||
if (isEdge) return texCoordM; // Depth discontinuity check
|
||||
refDistance = max(length(viewPos), 8.0);
|
||||
}
|
||||
|
||||
vec2 delta = normalM.xy - flatNormal.xy;
|
||||
if (dot(delta, delta) < 0.00001) return texCoordM;
|
||||
|
||||
float fovScale = gbufferProjection[1][1] / 1.37373871;
|
||||
vec2 distort = delta * vec2(1.0 / aspectRatio, 1.0) * fovScale / refDistance;
|
||||
vec2 newCoord = texCoordM + distort * BETTER_LABPBR_REFRACTIONS * 0.01;
|
||||
|
||||
// New coord so when we do depth stuff later in composite1 we have the correct refracted depth
|
||||
float z0check = texture2D(depthtex0, newCoord).r;
|
||||
float z1check = texture2D(depthtex1, newCoord).r;
|
||||
if (z0check == z1check) return texCoordM;
|
||||
if ((z0check <= 0.56) != isHand) return texCoordM; // Don't let the sample cross the hand/world boundary
|
||||
|
||||
color = texture2D(colortex0, newCoord).rgb;
|
||||
z0 = z0check;
|
||||
z1 = z1check;
|
||||
return newCoord;
|
||||
}
|
||||
#endif
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
const float packSizeSW = 16.0;
|
||||
|
||||
void DoSnowyWorld(inout vec4 color, inout float smoothnessG, inout float highlightMult, inout float smoothnessD, inout float emission,
|
||||
vec3 playerPos, vec2 lmCoord, float snowFactor, float snowMinNdotU, float NdotU, int subsurfaceMode) {
|
||||
float snowFactorM = snowFactor * 1000.0 * max(NdotU - 0.9, snowMinNdotU) * max0(lmCoord.y - 0.9) * (0.9 - clamp(lmCoord.x, 0.8, 0.9));
|
||||
if (snowFactorM <= 0.0001) return;
|
||||
|
||||
vec3 worldPos = playerPos + cameraPosition;
|
||||
vec2 noiseCoord = floor(packSizeSW * worldPos.xz + 0.001) / packSizeSW;
|
||||
noiseCoord += floor(packSizeSW * worldPos.y + 0.001) / packSizeSW;
|
||||
float noiseTexture = dot(vec2(0.25, 0.75), texture2DLod(noisetex, noiseCoord * 0.45, 0.0).rg);
|
||||
vec3 snowColor = mix(vec3(0.65, 0.8, 0.85), vec3(1.0, 1.0, 1.0), noiseTexture * 0.75 + 0.125);
|
||||
|
||||
color.rgb = mix(color.rgb, snowColor + color.rgb * emission * 0.2, snowFactorM);
|
||||
smoothnessG = mix(smoothnessG, 0.25 + 0.25 * noiseTexture, snowFactorM);
|
||||
highlightMult = mix(highlightMult, 2.0 - subsurfaceMode * 0.666, snowFactorM);
|
||||
smoothnessD = mix(smoothnessD, 0.0, snowFactorM);
|
||||
emission *= 1.0 - snowFactorM * 0.85;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
void DoTranslucentTweaks(inout vec4 color, inout float fresnelM, inout float reflectMult, float lViewPos) {
|
||||
#ifdef MORE_REFLECTIVE_DISTANT_GLASS
|
||||
float tweakDistance = 192.0;
|
||||
|
||||
float factor = smoothstep(0.0, tweakDistance, lViewPos);
|
||||
|
||||
color.a = mix(color.a, 1.0, factor * 0.75);
|
||||
fresnelM = mix(fresnelM, 1.0, factor * 0.25);
|
||||
reflectMult = mix(reflectMult, reflectMult / color.a, factor);
|
||||
#endif
|
||||
|
||||
// Reduce glass reflectivity when the camera is really close
|
||||
float factor2 = smoothstep(1.8, 0.3, lViewPos);
|
||||
reflectMult = mix(reflectMult, 0.0, factor2);
|
||||
|
||||
// Slightly reduce glass opacity when the camera is close
|
||||
float factor3 = smoothstep(4.0, 0.5, lViewPos);
|
||||
color.a = mix(color.a, pow2(color.a), factor3 * 0.5);
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
float random (in float x) { return fract(sin(x)*1e4);}
|
||||
float random (in vec2 st) {return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);}
|
||||
vec2 random2( vec2 p ) {
|
||||
return fract(sin(vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))))*43758.5453);
|
||||
}
|
||||
|
||||
vec4 hash4( vec2 p ) { return fract(sin(vec4( 1.0+dot(p,vec2(37.0,17.0)),
|
||||
2.0+dot(p,vec2(11.0,47.0)),
|
||||
3.0+dot(p,vec2(41.0,29.0)),
|
||||
4.0+dot(p,vec2(23.0,31.0))))*103.0); }
|
||||
|
||||
vec4 textureNoTile( sampler2D samp, in vec2 uv )
|
||||
{
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
|
||||
// #ifdef USEHASH
|
||||
// // generate per-tile transform (needs GL_NEAREST_MIPMAP_LINEARto work right)
|
||||
// vec4 ofa = texture( samp, (iuv + vec2(0.5,0.5))/256.0 );
|
||||
// vec4 ofb = texture( samp, (iuv + vec2(1.5,0.5))/256.0 );
|
||||
// vec4 ofc = texture( samp, (iuv + vec2(0.5,1.5))/256.0 );
|
||||
// vec4 ofd = texture( samp, (iuv + vec2(1.5,1.5))/256.0 );
|
||||
// #else
|
||||
// generate per-tile transform
|
||||
vec4 ofa = hash4( iuv + vec2(0.0,0.0) );
|
||||
vec4 ofb = hash4( iuv + vec2(1.0,0.0) );
|
||||
vec4 ofc = hash4( iuv + vec2(0.0,1.0) );
|
||||
vec4 ofd = hash4( iuv + vec2(1.0,1.0) );
|
||||
//#endif
|
||||
|
||||
vec2 ddx = dFdx( uv );
|
||||
vec2 ddy = dFdy( uv );
|
||||
|
||||
// transform per-tile uvs
|
||||
ofa.zw = sign(ofa.zw-0.5);
|
||||
ofb.zw = sign(ofb.zw-0.5);
|
||||
ofc.zw = sign(ofc.zw-0.5);
|
||||
ofd.zw = sign(ofd.zw-0.5);
|
||||
|
||||
// uv's, and derivarives (for correct mipmapping)
|
||||
vec2 uva = uv*ofa.zw + ofa.xy; vec2 ddxa = ddx*ofa.zw; vec2 ddya = ddy*ofa.zw;
|
||||
vec2 uvb = uv*ofb.zw + ofb.xy; vec2 ddxb = ddx*ofb.zw; vec2 ddyb = ddy*ofb.zw;
|
||||
vec2 uvc = uv*ofc.zw + ofc.xy; vec2 ddxc = ddx*ofc.zw; vec2 ddyc = ddy*ofc.zw;
|
||||
vec2 uvd = uv*ofd.zw + ofd.xy; vec2 ddxd = ddx*ofd.zw; vec2 ddyd = ddy*ofd.zw;
|
||||
|
||||
// fetch and blend
|
||||
vec2 b = smoothstep(0.25,0.75,fuv);
|
||||
|
||||
return mix( mix( textureGrad( samp, uva, ddxa, ddya ),
|
||||
textureGrad( samp, uvb, ddxb, ddyb ), b.x ),
|
||||
mix( textureGrad( samp, uvc, ddxc, ddyc ),
|
||||
textureGrad( samp, uvd, ddxd, ddyd ), b.x), b.y );
|
||||
}
|
||||
|
||||
vec3 voronoi( in vec2 x, float rnd ) {
|
||||
vec2 n = floor(x);
|
||||
vec2 f = fract(x);
|
||||
|
||||
// first pass: regular voronoi
|
||||
vec2 mg, mr;
|
||||
float md = 8.0;
|
||||
for (int j=-1; j<=1; j++ ) {
|
||||
for (int i=-1; i<=1; i++ ) {
|
||||
vec2 g = vec2(float(i),float(j));
|
||||
vec2 o = random2( n + g )*rnd;
|
||||
o = 0.5 + 0.5*sin( frameTimeCounter + 6.2831*o );
|
||||
vec2 r = g + o - f;
|
||||
float d = dot(r,r);
|
||||
|
||||
if( d<md ) {
|
||||
md = d;
|
||||
mr = r;
|
||||
mg = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// second pass: distance to borders
|
||||
md = 8.0;
|
||||
for (int j=-2; j<=2; j++ ) {
|
||||
for (int i=-2; i<=2; i++ ) {
|
||||
vec2 g = mg + vec2(float(i),float(j));
|
||||
vec2 o = random2(n + g)*rnd;
|
||||
o = 0.5 + 0.5*sin( frameTimeCounter + 6.2831*o );
|
||||
vec2 r = g + o - f;
|
||||
|
||||
if( dot(mr-r,mr-r)>0.00001 )
|
||||
md = min( md, dot( 0.5*(mr+r), normalize(r-mr) ) );
|
||||
}
|
||||
}
|
||||
return vec3( md, mr );
|
||||
}
|
||||
|
||||
vec3 waterMaskFunc(vec3 worldPos, const float water_scroll_speed, vec3 waterColor, int mat, vec3 normal) {
|
||||
const float foam_speed = 0.05;
|
||||
const float water_warp = 0.005;
|
||||
vec3 water_color = vec3(0.0);
|
||||
if (mat == 10049) { // Water Cauldron
|
||||
water_color = saturateColors(waterColor, 0.3) * 0.7;
|
||||
} else {
|
||||
water_color = mix(waterColor * 0.4, vec3(0.22, 0.22, 0.22), 0.5);
|
||||
}
|
||||
|
||||
//pixelated coord to created pixelated visual
|
||||
vec3 uv = worldPos;
|
||||
uv = (uv-.5)*.25+.5;
|
||||
float pixelWaterSize = 16;
|
||||
uv = floor(uv * (pixelWaterSize * 4)) / (pixelWaterSize * 4);
|
||||
|
||||
float d = dot(uv.xz-0.5,uv.xz-0.5);
|
||||
vec3 c = voronoi(5.0*uv.xz, pow(d,.6) );
|
||||
|
||||
vec2 water_pos = vec2(frameTimeCounter) * water_scroll_speed;
|
||||
vec3 foamNoise = textureNoTile(noisetex, uv.xz + vec2(frameTimeCounter) * foam_speed).xyz;
|
||||
|
||||
vec3 result = vec3(0.0);
|
||||
// borders
|
||||
vec3 waterMask = mix(vec3(1.00), vec3(0.0), smoothstep( 0.04, 0.06, c.x ));
|
||||
vec3 foam = waterMask * vec3(foamNoise.y - 0.55);
|
||||
foam = clamp(foam, vec3(0.02), vec3(1.0));
|
||||
foam *= 1.3;
|
||||
|
||||
//not regular structure water
|
||||
float water_sample = floor(texture2DLod(noisetex, uv.xz * 0.25 + foamNoise.xz * water_warp + water_pos, 0.0).r * 16) / 16;
|
||||
vec3 water = mix(water_color, vec3(0.001), water_sample * float(foam));
|
||||
|
||||
// small particles in water
|
||||
// Grid
|
||||
vec2 st = uv.xz;
|
||||
st *= vec2(100.0,100.);
|
||||
vec2 ipos = floor(st); // integer
|
||||
vec2 vel = vec2(frameTimeCounter); // time
|
||||
vel *= vec2(-1.,0.); // direction
|
||||
vel *= (step(1.0, mod(ipos.y,5.024))-0.5)*2.; // Oposite directions
|
||||
vel *= vec2(-1.,0.); // direction
|
||||
vel *= random(ipos.y); // random speed
|
||||
|
||||
//Creating particles
|
||||
vec3 pixelParticle = vec3(1.0);
|
||||
pixelParticle *= random(floor(vec2(st.x*0.32, st.y)+vel));
|
||||
float mixFactor = clamp((sin(frameTimeCounter*0.1) + 1.0)*0.5, 0.005, 0.15);
|
||||
pixelParticle = smoothstep(0.0,mixFactor,pixelParticle);
|
||||
pixelParticle = (1.0 - pixelParticle) * (foamNoise.y - 0.55);
|
||||
pixelParticle = clamp(pixelParticle, vec3(0.02), vec3(1.0));
|
||||
|
||||
result = foam * 2.0 + pixelParticle * 2.0 + water;
|
||||
//result = vec3(foamNoise.y - 0.55);
|
||||
return result;
|
||||
}
|
||||
+392
@@ -0,0 +1,392 @@
|
||||
#include "/lib/shaderSettings/wavingBlocks.glsl"
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
#include "/lib/voxelization/lightVoxelization.glsl"
|
||||
#endif
|
||||
|
||||
// Material ID groups shared between the MCWind override below and DoWave's
|
||||
// built-in waving fallback further down, so the two lists can't drift apart.
|
||||
#define MAT_GROUNDED_FOLIAGE (mat == 10003 || mat == 10005 || mat == 10029 || mat == 10025) // Grounded Foliage
|
||||
#define MAT_UPPER_LAYER_FOLIAGE (mat == 10021 || mat == 10023 || mat == 10027) // Upper Layer Foliage
|
||||
#define MAT_LEAVES (mat == 10007 || mat == 10009 || mat == 10011) // Leaves
|
||||
#define MAT_VINE_WALL (mat == 11009 || mat == 10544) // Vine, Glow Lichen
|
||||
#define MAT_VINE_CEILING (mat == 10923 || mat == 10629 || mat == 10632) // Pale Hanging Moss, Cave Vines
|
||||
#define MAT_WEEPING_VINES (mat == 10884 || mat == 10885) // Weeping Vines - hangs from the block above, like MAT_VINE_CEILING
|
||||
#define MAT_TWISTING_VINES (mat == 10887) // Twisting Vines - bottom-anchored, grows upward
|
||||
#define MAT_VINE (mat == 11009 || mat == 10923) // Vine, Pale Hanging Moss (just those 2 from default Comp) - used by DoWave's own fallback below
|
||||
#define MAT_FIRE (mat == 10072 || mat == 10076) // Fire, Soul Fire
|
||||
#define MAT_CAMPFIRE_LIT (mat == 10652 || mat == 10656) // Campfire:Lit, Soul Campfire:Lit
|
||||
#define MAT_STALK (mat == 10039 || mat == 10753) // Sugar Cane, Bamboo
|
||||
#define MAT_LILY_PAD (mat == 10489) // Lily Pad
|
||||
#define MAT_PENDANT (mat == 10562 || mat == 10743 || mat == 10564 || mat == 10988 || mat == 10291) // All types of Lanterns, Chains
|
||||
#if defined DO_MORE_FOLIAGE_WAVING || defined MCWIND_INTERNAL
|
||||
#define MAT_GROUNDED_FOLIAGE_EXTRA (mat == 10769 || mat == 10976) // Torchflower, Open Eye Blossom
|
||||
#endif
|
||||
|
||||
#if defined MCWIND_INTERNAL && (defined GBUFFERS_TERRAIN || defined SHADOW)
|
||||
|
||||
#define MCW_CAVE_CALM 0.75 // How calm the wind is in caves
|
||||
|
||||
// arm is the length of the chain/lantern, 1 is just a single lantern. The longer the chain, the more it swings
|
||||
// Caps at 9 and then it has 0.42 as the max radius of movement. 0.018 is the minimum radius of movement for a single lantern.
|
||||
#define MCW_PENDANT_RADIUS (mix(0.018, 0.42, smoothstep(1.0, 9.0, float(arm)))) // Amount of movement in lanterns
|
||||
#define MCW_PENDULUM // Makes the lanterns swing like a pendulum instead
|
||||
|
||||
#include "/mcwind/mcwind.glsl"
|
||||
|
||||
bool DoWave_MCWIND(inout vec3 playerPos, vec3 worldPos, int mat) {
|
||||
vec3 blockCenter = worldPos + clamp(at_midBlock.xyz / 64.0, -2.0, 2.0);
|
||||
|
||||
#ifdef MCWIND_FOLIAGE
|
||||
if (MAT_GROUNDED_FOLIAGE
|
||||
#if defined DO_MORE_FOLIAGE_WAVING || defined MCWIND_INTERNAL
|
||||
|| MAT_GROUNDED_FOLIAGE_EXTRA
|
||||
|| mat == 10972 // Firefly Bush
|
||||
#endif
|
||||
) {
|
||||
float h = mcw_grassHeight(worldPos, blockCenter, 0.0);
|
||||
playerPos.xz += mcw_grassPush(blockCenter, h);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MAT_UPPER_LAYER_FOLIAGE) {
|
||||
float h = mcw_grassHeight(worldPos, blockCenter, 1.0);
|
||||
playerPos.xz += mcw_grassPush(blockCenter, h);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_LEAVES
|
||||
if (MAT_LEAVES) {
|
||||
float weld = mcw_leafWeld(worldPos, blockCenter);
|
||||
playerPos += mcw_leafSway(worldPos, blockCenter, weld);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_VINES
|
||||
if ((MAT_VINE_CEILING || MAT_WEEPING_VINES) && mcw_hasOccupancy()) {
|
||||
float weld = mcw_leafWeld(worldPos, blockCenter);
|
||||
vec3 delta = mcw_leafSway(worldPos, blockCenter, weld);
|
||||
delta.xz += mcw_vineSwing(worldPos, blockCenter, weld);
|
||||
playerPos += mcw_vineDrop(delta, worldPos, blockCenter);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MAT_VINE_WALL && mcw_hasOccupancy()) {
|
||||
float weld = mcw_leafWeld(worldPos, blockCenter);
|
||||
vec3 delta = mcw_leafSway(worldPos, blockCenter, weld);
|
||||
delta.xz += mcw_vineSwing(worldPos, blockCenter, weld);
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
vec3 worldFaceNormal = normalize(mat3(gbufferModelViewInverse) * gl_NormalMatrix * gl_Normal);
|
||||
#else
|
||||
vec3 worldFaceNormal = normalize(mat3(shadowModelViewInverse) * gl_NormalMatrix * gl_Normal);
|
||||
#endif
|
||||
|
||||
playerPos += mcw_vineMotion(delta, worldPos, blockCenter, worldFaceNormal);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MAT_TWISTING_VINES && mcw_hasOccupancy()) {
|
||||
float weld = mcw_leafWeld(worldPos, blockCenter);
|
||||
vec3 delta = mcw_leafSway(worldPos, blockCenter, weld);
|
||||
delta.xz += mcw_vineSwing(worldPos, blockCenter, weld);
|
||||
playerPos += mcw_vineRise(delta, worldPos, blockCenter);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_PENDANTS
|
||||
if (MAT_PENDANT && mcw_hasOccupancy()) {
|
||||
playerPos += mcw_pendantSwing(worldPos, blockCenter);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_FIRE
|
||||
if (MAT_FIRE || MAT_CAMPFIRE_LIT) {
|
||||
// Wooden base should not sway lol
|
||||
bool base = MAT_CAMPFIRE_LIT ? abs(clamp(at_midBlock.y / 64.0, -2.0, 2.0)) > 0.5 : fract(worldPos.y + 0.21) > 0.26;
|
||||
float topWeight = base ? 1.0 : 0.0;
|
||||
playerPos += mcw_fireLean(blockCenter, topWeight);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_STALKS
|
||||
if (MAT_STALK) {
|
||||
float groundY = mcw_groundHeight(blockCenter, cameraPosition);
|
||||
playerPos.xz += mcw_stalkSway(worldPos, blockCenter, groundY);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCWIND_LILY_PAD
|
||||
if (MAT_LILY_PAD) {
|
||||
float phase = mcw_hash(floor(blockCenter.xz)) * 6.28318531;
|
||||
playerPos.y += sin(mcw_windPhase * 1.6 + phase) * 0.02 * (0.4 + 0.6 * mcw_windMag(blockCenter));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 GetRawWave(in vec3 pos, float wind) {
|
||||
float magnitude = sin(wind * 0.0027 + pos.x + pos.y) * 0.04 + 0.04;
|
||||
float d0 = sin(wind * 0.0127);
|
||||
float d1 = sin(wind * 0.0089);
|
||||
float d2 = sin(wind * 0.0114);
|
||||
vec3 wave;
|
||||
wave.x = magnitude * sin(wind*0.0224 + d1 + d2 + pos.x - pos.z + pos.y);
|
||||
wave.y = magnitude * sin(wind*0.0015 + d2 + d0 + pos.x);
|
||||
wave.z = magnitude * sin(wind*0.0063 + d0 + d1 - pos.x + pos.z + pos.y);
|
||||
|
||||
return wave;
|
||||
}
|
||||
|
||||
vec3 GetWave(in vec3 pos, float waveSpeed) {
|
||||
float wind = frameTimeCounter * waveSpeed * WAVING_SPEED;
|
||||
vec3 wave = GetRawWave(pos, wind);
|
||||
|
||||
#define WAVING_I_RAIN_MULT_M WAVING_I_RAIN_MULT * 0.01
|
||||
|
||||
#if WAVING_I_RAIN_MULT > 100
|
||||
float windRain = frameTimeCounter * waveSpeed * WAVING_I_RAIN_MULT_M * WAVING_SPEED;
|
||||
vec3 waveRain = GetRawWave(pos, windRain);
|
||||
wave = mix(wave, waveRain, rainFactor);
|
||||
#endif
|
||||
|
||||
float wavingIntensity = WAVING_I * mix(1.0, WAVING_I_RAIN_MULT_M, rainFactor);
|
||||
|
||||
return wave * wavingIntensity;
|
||||
}
|
||||
|
||||
void DoWave_Foliage(inout vec3 playerPos, vec3 worldPos, float waveMult) {
|
||||
worldPos.y *= 0.5;
|
||||
|
||||
vec3 wave = GetWave(worldPos, 170.0);
|
||||
wave.x = wave.x * 3.0;
|
||||
wave.y = 0.0;
|
||||
wave.z = wave.z * 8.0 + wave.y * 4.0;
|
||||
|
||||
#ifdef NO_WAVING_INDOORS
|
||||
#ifndef WAVE_EVERYTHING
|
||||
wave *= clamp(lmCoord.y - 0.87, 0.0, 0.1);
|
||||
#else
|
||||
wave *= 0.1;
|
||||
#endif
|
||||
#else
|
||||
wave *= 0.1;
|
||||
#endif
|
||||
|
||||
playerPos.xyz += wave * waveMult;
|
||||
}
|
||||
|
||||
void DoWave_Leaves(inout vec3 playerPos, vec3 worldPos, float waveMult) {
|
||||
worldPos *= vec3(0.75, 0.375, 0.75);
|
||||
|
||||
vec3 wave = GetWave(worldPos, 170.0);
|
||||
wave *= vec3(4.0, 3.0, 8.0);
|
||||
|
||||
wave *= 1.0 - inSnowy; // Leaves with snow on top look wrong
|
||||
|
||||
#if defined NO_WAVING_INDOORS && !defined WAVE_EVERYTHING
|
||||
wave *= clamp(lmCoord.y - 0.87, 0.0, 0.1);
|
||||
#else
|
||||
wave *= 0.1;
|
||||
#endif
|
||||
|
||||
playerPos.xyz += wave * waveMult;
|
||||
}
|
||||
|
||||
void DoWave_Water(inout vec3 playerPos, vec3 worldPos) {
|
||||
float waterWaveTime = frameTimeCounter * 6.0 * WAVING_SPEED;
|
||||
worldPos.xz *= 14.0;
|
||||
|
||||
float wave = sin(waterWaveTime * 0.7 - worldPos.z * 0.14 + worldPos.x * 0.07);
|
||||
wave += sin(waterWaveTime * 0.5 - worldPos.z * 0.10 + worldPos.x * 0.05);
|
||||
|
||||
#if defined NO_WAVING_INDOORS && !defined WAVE_EVERYTHING
|
||||
wave *= clamp(lmCoord.y - 0.87, 0.0, 0.1);
|
||||
#else
|
||||
wave *= 0.1;
|
||||
#endif
|
||||
|
||||
wave = wave * 0.125 - 0.05;
|
||||
|
||||
#ifdef VOXY
|
||||
// Fixes water alignment between normal water and voxy water
|
||||
float renderDisEdge = min1(max0(length(playerPos) * 2.0 - far) / far);
|
||||
wave *= 1.0 - renderDisEdge;
|
||||
wave += 0.02 * renderDisEdge;
|
||||
#endif
|
||||
|
||||
playerPos.y += wave;
|
||||
|
||||
#if defined GBUFFERS_WATER && WATER_STYLE == 1
|
||||
normal = mix(normal, tangent, wave * 0.01);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoWave_Lava(inout vec3 playerPos, vec3 worldPos) {
|
||||
if (fract(worldPos.y + 0.005) > 0.06) {
|
||||
float lavaWaveTime = frameTimeCounter * 3.0 * WAVING_SPEED;
|
||||
worldPos.xz *= 14.0;
|
||||
|
||||
float wave = sin(lavaWaveTime * 0.7 - worldPos.z * 0.14 + worldPos.x * 0.07);
|
||||
wave += sin(lavaWaveTime * 0.5 - worldPos.z * 0.05 + worldPos.x * 0.10);
|
||||
|
||||
#if defined NETHER && defined WAVIER_LAVA
|
||||
if (worldPos.y > 30 && worldPos.y < 32) wave *= 4.5;
|
||||
else wave *= 2.0;
|
||||
#endif
|
||||
|
||||
#ifdef VOXY
|
||||
// Fixes lava alignment between normal lava and voxy lava
|
||||
float renderDisEdge = min1(max0(length(playerPos) * 2.0 - far) / far);
|
||||
wave *= 1.0 - renderDisEdge;
|
||||
wave += 0.02 * renderDisEdge;
|
||||
#endif
|
||||
|
||||
playerPos.y += wave * 0.0125;
|
||||
}
|
||||
}
|
||||
|
||||
void DoWave(inout vec3 playerPos, int mat) {
|
||||
vec3 worldPos = playerPos.xyz + cameraPosition.xyz;
|
||||
|
||||
#if defined MCWIND_INTERNAL && (defined GBUFFERS_TERRAIN || defined SHADOW)
|
||||
if (DoWave_MCWIND(playerPos.xyz, worldPos, mat)) return;
|
||||
#endif
|
||||
|
||||
#if defined GBUFFERS_TERRAIN || defined SHADOW
|
||||
#ifdef WAVING_FOLIAGE
|
||||
if (MAT_GROUNDED_FOLIAGE
|
||||
#ifdef DO_MORE_FOLIAGE_WAVING
|
||||
|| MAT_GROUNDED_FOLIAGE_EXTRA
|
||||
#endif
|
||||
) {
|
||||
if (gl_MultiTexCoord0.t < mc_midTexCoord.t || fract(worldPos.y + 0.21) > 0.26)
|
||||
DoWave_Foliage(playerPos.xyz, worldPos, 1.0);
|
||||
}
|
||||
|
||||
else if (MAT_UPPER_LAYER_FOLIAGE) {
|
||||
DoWave_Foliage(playerPos.xyz, worldPos, 1.0);
|
||||
}
|
||||
|
||||
#ifdef DO_MORE_FOLIAGE_WAVING
|
||||
else if (mat == 10972) { // Firefly Bush
|
||||
if (gl_MultiTexCoord0.t < mc_midTexCoord.t || fract(worldPos.y + 0.21) > 0.26) {
|
||||
vec3 wave = GetWave(worldPos, 170.0);
|
||||
wave.x = wave.x * 8.0 + wave.y * 4.0;
|
||||
wave.y = 0.0;
|
||||
wave.z = wave.z * 3.0;
|
||||
|
||||
playerPos.xyz += wave * 0.1 * eyeBrightnessM; // lmCoord.y is unreliable for firefly bushes
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined WAVING_LEAVES_ENABLED || defined WAVING_LAVA || defined WAVING_LILY_PAD
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WAVING_LEAVES_ENABLED
|
||||
if (MAT_LEAVES) {
|
||||
DoWave_Leaves(playerPos.xyz, worldPos, 1.0);
|
||||
} else if (MAT_VINE) {
|
||||
// Reduced waving on vines to prevent clipping through blocks
|
||||
DoWave_Leaves(playerPos.xyz, worldPos, 0.75);
|
||||
}
|
||||
#if defined NETHER || defined DO_NETHER_VINE_WAVING_OUTSIDE_NETHER
|
||||
else if (MAT_WEEPING_VINES || MAT_TWISTING_VINES) {
|
||||
float waveMult = 1.0;
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
vec3 playerPosP = playerPos + vec3(0.0, 0.1, 0.0);
|
||||
vec3 voxelPosP = SceneToVoxel(playerPosP);
|
||||
vec3 playerPosN = playerPos - vec3(0.0, 0.1, 0.0);
|
||||
vec3 voxelPosN = SceneToVoxel(playerPosN);
|
||||
|
||||
if (CheckInsideVoxelVolume(voxelPosP)) {
|
||||
int voxelP = int(GetVoxelVolume(ivec3(voxelPosP)));
|
||||
int voxelN = int(GetVoxelVolume(ivec3(voxelPosN)));
|
||||
if (voxelP != 0 && voxelP != 65 || voxelN != 0 && voxelN != 65) // not air, not weeping vines
|
||||
waveMult = 0.0;
|
||||
}
|
||||
#endif
|
||||
DoWave_Foliage(playerPos.xyz, worldPos, waveMult);
|
||||
}
|
||||
#endif
|
||||
#ifdef WAVING_SUGAR_CANE
|
||||
if (mat == 10039) { // Sugar Cane
|
||||
float waveMult = 0.75;
|
||||
#if COLORED_LIGHTING_INTERNAL > 0
|
||||
vec3 voxelPosP = SceneToVoxel(playerPos - vec3(0.0, 0.1, 0.0));
|
||||
|
||||
if (CheckInsideVoxelVolume(voxelPosP)) {
|
||||
int voxelP = int(texelFetch(voxel_sampler, ivec3(voxelPosP), 0).r);
|
||||
if (voxelP != 0) // not air
|
||||
waveMult = 0.0;
|
||||
}
|
||||
#endif
|
||||
DoWave_Foliage(playerPos.xyz, worldPos, waveMult);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined WAVING_LAVA || defined WAVING_LILY_PAD
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WAVING_LAVA
|
||||
if (mat == 10068 || mat == 10070) { // Lava
|
||||
DoWave_Lava(playerPos.xyz, worldPos);
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
// G8FL735 Fixes Optifine-Iris parity. Optifine has 0.9 gl_Color.rgb on a lot of versions
|
||||
glColorRaw.rgb = min(glColorRaw.rgb, vec3(0.9));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WAVING_LILY_PAD
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WAVING_LILY_PAD
|
||||
if (MAT_LILY_PAD) {
|
||||
DoWave_Water(playerPos.xyz, worldPos);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined GBUFFERS_WATER || defined SHADOW || defined GBUFFERS_TERRAIN
|
||||
#ifdef WAVING_WATER_VERTEX
|
||||
#if defined WAVING_ANYTHING_TERRAIN && defined SHADOW
|
||||
else
|
||||
#endif
|
||||
|
||||
if (mat == 32000) { // Water
|
||||
if (fract(worldPos.y + 0.005) > 0.06)
|
||||
DoWave_Water(playerPos.xyz, worldPos);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
void DoInteractiveWave(inout vec3 playerPos, int mat) {
|
||||
float strength = 2.0;
|
||||
if (mat == 10003 || mat == 10023 || mat == 10015) { // Flowers & Seagrass
|
||||
strength = 1.0;
|
||||
}
|
||||
if (length(playerPos) < 2.0) playerPos.xz += playerPos.xz * max(5.0 / max(length(playerPos * vec3(8.0, 2.0, 8.0) - vec3(0.0, 2.0, 0.0)), 2.0) -0.625, 0.0) * clamp(2.0 / length(playerPos) - 1.0, 0.0, 1.0) * strength; // Emin's code from v4 + smooth transition by me
|
||||
}
|
||||
|
||||
void DoWaveEverything(inout vec3 playerPos) {
|
||||
vec3 worldPos = playerPos.xyz + cameraPosition.xyz;
|
||||
DoWave_Leaves(playerPos.xyz, worldPos, 1.0);
|
||||
DoWave_Foliage(playerPos.xyz, worldPos, 1.0);
|
||||
}
|
||||
+370
@@ -0,0 +1,370 @@
|
||||
#extension GL_ARB_shader_image_load_store : enable
|
||||
|
||||
#include "/lib/voxelization/reflectionVoxelization.glsl"
|
||||
#include "/lib/lighting/minimumLighting.glsl"
|
||||
#include "/lib/shaderSettings/mainLighting.glsl"
|
||||
#include "/lib/shaderSettings/cloudsAndLighting.glsl"
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
#include "/lib/materials/materialMethods/playerRayTracer.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
#include "/lib/atmospherics/auroraBorealis.glsl"
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD || defined END
|
||||
#ifndef GBUFFERS_WATER
|
||||
#include "/lib/lighting/shadowSampling.glsl"
|
||||
#if defined DO_PIXELATION_EFFECTS && defined PIXELATED_SHADOWS
|
||||
#include "/lib/misc/pixelation.glsl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SHADOW_SMOOTHING == 4 || SHADOW_QUALITY == 0
|
||||
const float offset = 0.00098;
|
||||
#elif SHADOW_SMOOTHING == 3
|
||||
const float offset = 0.00075;
|
||||
#elif SHADOW_SMOOTHING == 2
|
||||
const float offset = 0.0005;
|
||||
#elif SHADOW_SMOOTHING == 1
|
||||
const float offset = 0.0003;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
#include "/lib/lighting/heldLighting.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef CLOUD_SHADOWS
|
||||
#include "/lib/lighting/cloudShadows.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
#include "/lib/colors/colorMultipliers.glsl"
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_LIGHT
|
||||
#include "/lib/colors/moonPhaseInfluence.glsl"
|
||||
#endif
|
||||
|
||||
vec2 getLocalTexCoord(vec3 local, vec3 normal) {
|
||||
vec3 absNormal = abs(normal);
|
||||
return 1.0 - local.zy * absNormal.x - local.xz * absNormal.y - local.xy * absNormal.z;
|
||||
}
|
||||
|
||||
float getVoxelSpaceAO(ivec3 voxelPos, ivec3 normal, vec2 localTexCoord) {
|
||||
ivec3 absNormal = abs(normal);
|
||||
ivec3 hrz = ivec3(0, 0, 1) * absNormal.x + ivec3(1, 0, 0) * absNormal.y + ivec3(1, 0, 0) * absNormal.z;
|
||||
ivec3 vrt = ivec3(0, 1, 0) * absNormal.x + ivec3(0, 0, 1) * absNormal.y + ivec3(0, 1, 0) * absNormal.z;
|
||||
|
||||
vec2 dir = 1.0 - 2.0 * localTexCoord;
|
||||
|
||||
ivec2 signDir = ivec2(sign(dir));
|
||||
ivec3 voxelHrz = voxelPos + normal + signDir.x * hrz;
|
||||
ivec3 voxelVrt = voxelPos + normal + signDir.y * vrt;
|
||||
|
||||
vec2 factor = pow2(dir);
|
||||
float occHrz = mix(1.0, float(texelFetch(wsr_sampler, voxelHrz, 0).r == 0u), factor.x);
|
||||
float occVrt = mix(1.0, float(texelFetch(wsr_sampler, voxelVrt, 0).r == 0u), factor.y);
|
||||
|
||||
return 0.3 * (occHrz + occVrt) + 0.4;
|
||||
}
|
||||
|
||||
vec4 getShadedReflection(ivec3 voxelPos, vec3 oldPlayerPos, vec3 playerPos, vec3 rayDir, vec3 normal, uint mat, float dither) {
|
||||
faceData faceData = getFaceData(voxelPos, normal);
|
||||
if (faceData.textureBounds.z < 1e-6) return vec4(-1.0);
|
||||
|
||||
vec2 localTexCoord = getLocalTexCoord(fract(playerPos + cameraPositionBestFract), normal);
|
||||
|
||||
vec2 textureSizeAtlas = textureSize(textureAtlas, 0);
|
||||
vec2 textureRadVec2 = faceData.textureBounds.z * vec2(1.0, textureSizeAtlas.x / textureSizeAtlas.y);
|
||||
vec2 textureCoord = faceData.textureBounds.xy + 2.0 * textureRadVec2 * localTexCoord;
|
||||
|
||||
float virtualDist = length(playerPos - oldPlayerPos) + length(oldPlayerPos);
|
||||
float textureFactor = length(textureRadVec2 * textureSizeAtlas) * 3.0;
|
||||
float lod = 0.5 * log2(virtualDist * textureFactor / gbufferProjection[0][0] / abs(dot(normal, rayDir)) / viewHeight / REFLECTION_RES);
|
||||
|
||||
vec4 color = texture2DLod(textureAtlas, textureCoord, lod) * vec4(faceData.glColor, 1.0);
|
||||
|
||||
#if MC_VERSION >= 12111 && IRIS_VERSION < 11005
|
||||
// stupid fake lods because custom texture lods broke with Iris in newer mc versions
|
||||
vec2 lodCoordSpan = localTexCoord / pow(2.0, int(1.5 + pow2(max0(lod)) + 0.0 * dither));
|
||||
|
||||
vec2 lodCoord1 = faceData.textureBounds.xy + 2.0 * textureRadVec2 * (0.5 + lodCoordSpan);
|
||||
vec2 lodCoord2 = faceData.textureBounds.xy + 2.0 * textureRadVec2 * (0.25 + lodCoordSpan);
|
||||
vec2 lodCoord3 = faceData.textureBounds.xy + 2.0 * textureRadVec2 * lodCoordSpan;
|
||||
vec4 lodColor1 = texture2DLod(textureAtlas, lodCoord1, lod) * vec4(faceData.glColor, 1.0);
|
||||
vec4 lodColor2 = texture2DLod(textureAtlas, lodCoord2, lod) * vec4(faceData.glColor, 1.0);
|
||||
vec4 lodColor3 = texture2DLod(textureAtlas, lodCoord3, lod) * vec4(faceData.glColor, 1.0);
|
||||
|
||||
float lodMix = clamp01(lod - 0.75 + 0.25 * dither);
|
||||
color = mix(color, 0.333333 * (lodColor1 + lodColor2 + lodColor3), lodMix);
|
||||
if (dot(color.rgb, vec3(0.333333)) - 0.5 < 0.49) color.a = mix(color.a, 1.0, lodMix);
|
||||
//
|
||||
#endif
|
||||
|
||||
if (color.a < 0.0041) return vec4(-1.0); // Note that the cutout parts of leaves have a color.a of about 0.004
|
||||
|
||||
bool noSmoothLighting = false, noDirectionalShading = false, isFoliage = false;;
|
||||
int subsurfaceMode = 0;
|
||||
float emission = 0.0, NdotU = normal.y, NdotE = normal.x, snowMinNdotU = 0.0;
|
||||
vec2 lmCoordM = vec2(1.0);
|
||||
vec3 shadowMult = vec3(1.0), maRecolor = vec3(0.0);
|
||||
float skyLightCheck = 0.0;
|
||||
float overlayNoiseIntensity = 1.0, snowNoiseIntensity = 1.0, sandNoiseIntensity = 1.0, mossNoiseIntensity = 1.0, overlayNoiseTransparentOverwrite = 0.0, overlayNoiseEmission = 1.0, lavaNoiseIntensity = LAVA_NOISE_INTENSITY;
|
||||
vec3 normalM = normal, geoNormal = normal;
|
||||
#ifdef IPBR
|
||||
float lViewPos = length(playerPos);
|
||||
vec4 glColor = vec4(faceData.glColor, 1.0);
|
||||
vec2 absMidCoordPos = vec2(textureRadVec2);
|
||||
vec2 midCoord = faceData.textureBounds.xy + 2.0 * textureRadVec2 * vec2(0.5);
|
||||
vec2 signMidCoordPos = localTexCoord * 2.0 - 1.0;
|
||||
bool noVanillaAO = false, centerShadowBias = false, noGeneratedNormals = false, doTileRandomisation = true;
|
||||
float smoothnessD = 0.0, materialMask = 0.0;
|
||||
float smoothnessG = 0.0, highlightMult = 1.0, noiseFactor = 1.0, snowFactor = 1.0, noPuddles = 0.0;
|
||||
vec2 lmCoord = faceData.lightmap;
|
||||
float IPBRMult = 1.0;
|
||||
|
||||
#define DURING_WORLDSPACE_REF
|
||||
#ifndef IPBR_COMPAT_MODE
|
||||
#define IPBR_COMPAT_MODE
|
||||
#endif
|
||||
#undef DISTANT_LIGHT_BOKEH
|
||||
#include "/lib/materials/materialHandling/terrainIPBR.glsl"
|
||||
#undef DURING_WORLDSPACE_REF
|
||||
#else
|
||||
if (mat == 10007 || mat == 10009 || mat == 10011) { // Leaves
|
||||
#include "/lib/materials/specificMaterials/terrain/leaves.glsl"
|
||||
}
|
||||
#endif
|
||||
|
||||
float NdotL = dot(normal, mat3(gbufferModelViewInverse) * lightVec);
|
||||
#ifdef SIDE_SHADOWING
|
||||
float lightingNdotL = max0(NdotL + 0.4) * 0.714;
|
||||
|
||||
#ifdef END
|
||||
lightingNdotL = sqrt3(lightingNdotL);
|
||||
#endif
|
||||
#else
|
||||
float lightingNdotL = max0(NdotL);
|
||||
#endif
|
||||
|
||||
#ifndef NETHER
|
||||
vec3 shadow = shadowMult;
|
||||
if (lightingNdotL > 0.0001) {
|
||||
float shadowLength = shadowDistance * 0.9166667 - length(playerPos); //consistent08JJ622
|
||||
if (shadowLength > 0.000001) {
|
||||
float distanceBias = 0.12 + 0.0008 * pow(dot(playerPos, playerPos), 0.75);
|
||||
vec3 bias = normal * distanceBias * (2.0 - 0.95 * max0(NdotL));
|
||||
int shadowSamples = 2;
|
||||
|
||||
shadow = GetShadow(GetShadowPos(playerPos + bias), faceData.lightmap.y, offset, shadowSamples, false, playerPos);
|
||||
}
|
||||
}
|
||||
shadow *= dot(shadow, vec3(0.33333));
|
||||
|
||||
#ifdef END_FLASH_SHADOW_INTERNAL
|
||||
vec3 endFlashShadowColor = END_FLASH_SHADOW * 0.12 * 0.82 + endOrangeCol * 0.18;
|
||||
shadow = mix(vec3(1.0), endFlashShadowColor * shadow + 1.0, endFlashIntensityM);
|
||||
#endif
|
||||
#else
|
||||
vec3 shadow = vec3(1.0);
|
||||
#endif
|
||||
|
||||
#ifdef CLOUD_SHADOWS
|
||||
shadow *= GetCloudShadow(playerPos);
|
||||
#endif
|
||||
|
||||
faceData.lightmap = pow2(pow2(faceData.lightmap));
|
||||
float AO = getVoxelSpaceAO(voxelPos, ivec3(normal), localTexCoord);
|
||||
float directionalShading = noDirectionalShading ? 1.0 : (NdotU + 1.0) * 0.25 + 0.5;
|
||||
|
||||
vec3 centerPlayerPos = floor(playerPos + cameraPosition + normal * 0.01) - cameraPosition + 0.5;
|
||||
vec3 playerPosM = mix(centerPlayerPos, playerPos, (AO - 0.8) / 0.2);
|
||||
vec3 voxelPosM = SceneToVoxel(playerPosM);
|
||||
voxelPosM = clamp01(voxelPosM / vec3(voxelVolumeSize));
|
||||
vec4 lightVolume = GetLightVolume(voxelPosM);
|
||||
lightVolume = max(lightVolume, vec4(0.000001));
|
||||
vec3 specialLighting = 0.8 * pow(GetLuminance(lightVolume.rgb), 0.25) * DoLuminanceCorrection(pow(lightVolume.rgb, vec3(0.3)));
|
||||
if (noSmoothLighting == true) specialLighting *= 0.6;
|
||||
|
||||
vec3 minLighting = 0.8 * sqrt(GetMinimumLighting(faceData.lightmap.y, playerPos));
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
vec3 heldLighting = GetHeldLighting(playerPos, color.rgb, emission, geoNormal, normalM, vec3(0.0));
|
||||
specialLighting = sqrt(pow2(specialLighting) + sqrt(heldLighting));
|
||||
#endif
|
||||
|
||||
#ifdef AURORA_INFLUENCE
|
||||
ambientColor = getAuroraAmbientColor(ambientColor, rayDir, 0.035, AURORA_TERRAIN_INFLUENCE_INTENSITY, 0.9);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float ambientMult = 0.9 * faceData.lightmap.y;
|
||||
float lightMult = (1.1 + 0.25 * subsurfaceMode) * lightingNdotL * shadowTime;
|
||||
lightMult *= 1.0 + abs(NdotE) * 0.25;
|
||||
specialLighting *= 1.0 - faceData.lightmap.y * sunFactor;
|
||||
#else
|
||||
float ambientMult = 1.0;
|
||||
float lightMult = 1.0 * lightingNdotL * shadowTime;
|
||||
#endif
|
||||
|
||||
vec3 sceneLighting = ambientMult * ambientColor + lightMult * lightColor * shadow;
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
lightColorMult = GetLightColorMult();
|
||||
sceneLighting *= lightColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_LIGHT
|
||||
sceneLighting *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
vec3 lighting = sceneLighting + specialLighting * XLIGHT_I + minLighting;
|
||||
lighting = lighting * AO * directionalShading + emission * 0.8;
|
||||
|
||||
vec3 fadeout = smoothstep(0.0, 32.0, 0.5 * sceneVoxelVolumeSize - abs(playerPos));
|
||||
float alphaFade = sqrt3(minOf(fadeout)) * 0.9 + 0.1;
|
||||
|
||||
return vec4(color.rgb * lighting + maRecolor, alphaFade);
|
||||
}
|
||||
|
||||
vec4 voxelRayTrace(vec3 playerPos, vec3 voxelPos, vec3 rayDir, float RVdotU, float RVdotS, float dither, out float traceLength) {
|
||||
vec3 stepAxis = vec3(0.0);
|
||||
vec3 stepDir = sign(rayDir);
|
||||
vec3 stepSizes = 1.0 / abs(rayDir);
|
||||
|
||||
float dist1 = 0.0;
|
||||
vec3 voxelPosRT1 = voxelPos * 0.25;
|
||||
vec3 nextDist1 = (stepDir * 0.5 + 0.5 - fract(voxelPosRT1)) / rayDir;
|
||||
|
||||
while (CheckInsideLodVoxelVolume(voxelPosRT1)) {
|
||||
if (texelFetch(wsr_lod_sampler, ivec3(voxelPosRT1), 0).r > 0u) {
|
||||
float dist0 = 0.0;
|
||||
vec3 voxelPosRT0 = playerToSceneVoxel(playerPos + (4.0 * dist1 - 0.001) * rayDir); // consistency59SMG32: 0.001 offset to fix rare wsr glitches
|
||||
vec3 nextDist0 = (stepDir * 0.5 + 0.5 - fract(voxelPosRT0)) / rayDir;
|
||||
|
||||
vec3 lodVoxelMin = floor(voxelPosRT1) * 4.0;
|
||||
vec3 lodVoxelMax = lodVoxelMin + 4.0;
|
||||
|
||||
float maxDist0 = minOf((mix(lodVoxelMin, lodVoxelMax, stepDir * 0.5 + 0.5) - voxelPosRT0) / rayDir);
|
||||
|
||||
while (dist0 < maxDist0 && CheckInsideSceneVoxelVolume(voxelPosRT0)) {
|
||||
uint mat = texelFetch(wsr_sampler, ivec3(voxelPosRT0), 0).r;
|
||||
if (mat > 0u) {
|
||||
traceLength = 4.0 * dist1 + dist0;
|
||||
|
||||
vec3 normal = -stepAxis * stepDir;
|
||||
vec3 intersection = playerPos + (traceLength - 0.001) * rayDir; // consistency59SMG32: 0.001 offset to fix rare wsr glitches
|
||||
|
||||
vec4 reflection = getShadedReflection(ivec3(voxelPosRT0), playerPos, intersection, rayDir, normal, mat, dither);
|
||||
if (reflection.a > -0.5) {
|
||||
vec3 fadeout = smoothstep(0.0, 32.0, 0.5 * sceneVoxelVolumeSize - abs(playerPos));
|
||||
reflection *= sqrt3(minOf(fadeout)) * 0.9 + 0.1;
|
||||
|
||||
float skyFade = 0.0;
|
||||
float reflectionPrevAlpha = reflection.a;
|
||||
|
||||
DoFog(reflection, skyFade, length(intersection), intersection, RVdotU, RVdotS, dither, true, length(playerPos));
|
||||
|
||||
reflection.a = reflectionPrevAlpha * (1.0 - skyFade);
|
||||
|
||||
return reflection;
|
||||
}
|
||||
}
|
||||
|
||||
dist0 = minOf(nextDist0);
|
||||
stepAxis = vec3(equal(nextDist0, vec3(dist0)));
|
||||
|
||||
nextDist0 += stepAxis * stepSizes;
|
||||
voxelPosRT0 += stepAxis * stepDir;
|
||||
}
|
||||
}
|
||||
|
||||
dist1 = minOf(nextDist1);
|
||||
stepAxis = vec3(equal(nextDist1, vec3(dist1)));
|
||||
|
||||
nextDist1 += stepAxis * stepSizes;
|
||||
voxelPosRT1 += stepAxis * stepDir;
|
||||
}
|
||||
|
||||
traceLength = 999999.0;
|
||||
return vec4(0.0);
|
||||
}
|
||||
|
||||
vec4 getWSR(vec3 playerPos, vec3 normalMR, vec3 nViewPosR, float RVdotU, float RVdotS, float z0, float dither, out float wsrTraceLength, bool isTranslucent) {
|
||||
vec3 worldNormal = normalize(mat3(gbufferModelViewInverse) * normalMR);
|
||||
float normalOffsetDist = 0.04; // Fixes artifacts. 0.03 is enough but use slightly higher to make sure
|
||||
|
||||
if (!isTranslucent && z0 > 0.56) {
|
||||
// Fix self-reflection and also align non-full blocks' trace start position to the grid
|
||||
vec3 absWorldNormal = abs(worldNormal);
|
||||
vec3 worldNormalM = vec3(equal(absWorldNormal, vec3(maxOf(abs(worldNormal))))) * sign(worldNormal);
|
||||
|
||||
float normalOffsetDist = 1.0 - fract(dot(playerPos + cameraPositionBestFract - worldNormal * 0.1, worldNormalM));
|
||||
}
|
||||
|
||||
playerPos += normalOffsetDist * worldNormal;
|
||||
|
||||
vec3 rayDir = mat3(gbufferModelViewInverse) * nViewPosR;
|
||||
vec3 voxelPos = playerToSceneVoxel(playerPos);
|
||||
|
||||
if (CheckInsideSceneVoxelVolume(voxelPos)) {
|
||||
vec4 wsrResult = voxelRayTrace(playerPos, voxelPos, rayDir, RVdotU, RVdotS, dither, wsrTraceLength);
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
if (!bool(is_invisible) && z0 > 0.56) {
|
||||
vec3 albedo = vec3(0.0);
|
||||
vec3 normal = vec3(0.0);
|
||||
float emission = 0.0;
|
||||
|
||||
#ifdef SPACEAGLE17
|
||||
if (isSneaking < 0.5 || !(heldItemId == 45014 || heldItemId2 == 45014))
|
||||
#endif
|
||||
if (rayTracePlayer(playerPos - 0.01 * rayDir, rayDir, wsrTraceLength, albedo, normal, emission)) {
|
||||
vec2 lmCoord = eyeBrightness / 240.0;
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float ambientMult = 1.5 * lmCoord.y;
|
||||
float lightMult = 0.2 * pow2(pow2(lmCoord.y));
|
||||
#else
|
||||
float ambientMult = 1.5;
|
||||
float lightMult = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 voxelPosM = SceneToVoxel(vec3(0.0));
|
||||
voxelPosM = clamp01(voxelPosM / vec3(voxelVolumeSize));
|
||||
vec4 lightVolume = GetLightVolume(voxelPosM);
|
||||
lightVolume = max(lightVolume, vec4(0.000001));
|
||||
vec3 specialLighting = pow(GetLuminance(lightVolume.rgb), 0.25) * DoLuminanceCorrection(pow(lightVolume.rgb, vec3(0.25)));
|
||||
|
||||
#if HELD_LIGHTING_MODE >= 1
|
||||
float tempEmission = 0.0;
|
||||
vec3 heldLighting = GetHeldLighting(playerPos, vec3(999999.0), tempEmission, vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
specialLighting = sqrt(pow2(specialLighting) + sqrt(heldLighting));
|
||||
#endif
|
||||
|
||||
vec3 minLighting = 0.8 * sqrt(GetMinimumLighting(lmCoord.y, playerPos));
|
||||
|
||||
vec3 sceneLighting = ambientMult * ambientColor + lightMult * lightColor;
|
||||
#ifdef LIGHT_COLOR_MULTS
|
||||
lightColorMult = GetLightColorMult();
|
||||
sceneLighting *= lightColorMult;
|
||||
#endif
|
||||
#ifdef MOON_PHASE_INF_LIGHT
|
||||
sceneLighting *= moonPhaseInfluence;
|
||||
#endif
|
||||
|
||||
vec3 lighting = sceneLighting + specialLighting * (1.0 - lmCoord.y * sunFactor) * XLIGHT_I + minLighting + emission;
|
||||
|
||||
vec3 fadeout = smoothstep(0.0, 32.0, 0.5 * sceneVoxelVolumeSize - abs(playerPos));
|
||||
float alphaFade = sqrt3(minOf(fadeout)) * 0.9 + 0.1;
|
||||
|
||||
return vec4(albedo * lighting, alphaFade);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return wsrResult;
|
||||
}
|
||||
|
||||
return vec4(0.0);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
vec2 getOverlayNoise(float sideIntensity, bool noLightCheck, bool decreaseWithDepth, float meltingRadius, int pixelSize, vec3 worldPos, float noiseTransparency, float removeIntensity) {
|
||||
float overlayNoiseVariable;
|
||||
float topCheck = abs(clamp01(dot(normal, upVec))); // normal check for top surfaces
|
||||
if (topCheck > 0.5) {
|
||||
overlayNoiseVariable = 0.0;
|
||||
overlayNoiseVariable += topCheck;
|
||||
} else {
|
||||
overlayNoiseVariable = sideIntensity;
|
||||
}
|
||||
|
||||
//noise
|
||||
int noiseSize = 0;
|
||||
noiseSize = pixelSize;
|
||||
float noise = float(hash33(floor(mod(worldPos, vec3(100.0)) * noiseSize + 0.03) * noiseSize)) * 0.25; // pixel-locked procedural noise
|
||||
|
||||
//make patches of terrain that don't have noise
|
||||
float removeNoise1 = 1.0 - Noise3D(worldPos * 0.0005) * removeIntensity * 1.2;
|
||||
float removeNoise2 = 1.0 - Noise3D(worldPos * 0.005) * removeIntensity;
|
||||
float removeNoise3 = Noise3D(worldPos * 0.02) * removeIntensity;
|
||||
float removeNoise = clamp01(2.0 * removeNoise1 + 0.70 * removeNoise2 + 0.2 * removeNoise3);
|
||||
overlayNoiseVariable *= removeNoise;
|
||||
|
||||
// light check so noise is not in caves (near light sources)
|
||||
overlayNoiseVariable = clamp01(overlayNoiseVariable); // to prevent stuff breaking, like the fucking bamboo sapling!!!!
|
||||
if (!noLightCheck) {
|
||||
overlayNoiseVariable *= (1.0 - pow(lmCoord.x, 1.0 / meltingRadius * 2.5) * 4.3) * pow(lmCoord.y, 14.0); // first part to turn off at light sources, second part to turn off if under blocks
|
||||
}
|
||||
float depthTransparency = 1.0;
|
||||
if (decreaseWithDepth) {
|
||||
depthTransparency = 10.0 / abs(min(worldPos.y, 0.001)) - 0.3 + clamp(removeNoise * 1.3, 0.0, 0.1); // increase transparency beginning at y=0 at increasing with decreasing y level
|
||||
}
|
||||
overlayNoiseVariable = clamp(overlayNoiseVariable, 0.0, depthTransparency); // to prevent artifacts near light sources
|
||||
|
||||
vec2 result = vec2(overlayNoiseVariable, noise);
|
||||
return result;
|
||||
}
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
#define MOSS_NOISE_INTENSITY 1.0 //[0.5 0.75 1.0 1.25 1.5 2.0]
|
||||
#define MOSS_NOISE_REMOVE_INTENSITY 1.00 //[0.00 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.60 1.70 1.80 1.90 2.00 2.25 2.50 2.75 3.00]
|
||||
#define MOSS_TRANSPARENCY 0.85 // [0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 1.00]
|
||||
#define MOSS_IN_CAVES 0 //[0 1 2] //lush caves, true, false
|
||||
#define MOSS_SIDE_INTENSITY 10 //[0 1 2 3 4 5 6 7 8 9 10]
|
||||
#define MOSS_NOISE_DISTANCE 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0]
|
||||
#define MOSS_SIZE 16 //[8 16 32 64 128]
|
||||
|
||||
#define SAND_CONDITION 0 //[0 1 2] 0 = dynamic 1 = only in hot biomes, 2 = everywhere
|
||||
#define SAND_SIZE 16 //[8 16 32 64 128]
|
||||
#define SAND_NOISE_INTENSITY 1.0 //[0.5 0.75 1.0 1.25 1.5 2.0]
|
||||
#define SAND_NOISE_REMOVE_INTENSITY 1.00 //[0.00 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.60 1.70 1.80 1.90 2.00 2.25 2.50 2.75 3.00]
|
||||
#define SAND_TRANSPARENCY 0.85 // [0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 1.00]
|
||||
#define SAND_IN_CAVES true //[true false]
|
||||
#define SAND_SIDE_INTENSITY 7 //[0 1 2 3 4 5 6 7 8 9 10]
|
||||
#define SAND_NOISE_DISTANCE 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0]
|
||||
|
||||
vec3 absPlayerPos = abs(playerPos);
|
||||
float maxPlayerPosXZ = max(absPlayerPos.x, absPlayerPos.z);
|
||||
#ifdef MOSS_NOISE_INTERNAL
|
||||
#if MOSS_IN_CAVES == 0
|
||||
float mossDecider = -clamp01(pow2(min1(maxPlayerPosXZ / (200 * MOSS_NOISE_DISTANCE)) * 2.0)) + 1.0; // The effect will only be around the player
|
||||
#else
|
||||
float mossDecider = 1.0;
|
||||
#endif
|
||||
if (mossDecider > 0.001){
|
||||
vec3 mossColor = mix(vec3(0.2745, 0.3412, 0.1412), vec3(0.451, 0.5804, 0.1255), float(hash33(floor(mod(worldPos, vec3(100.0)) * MOSS_SIZE + 0.03) * MOSS_SIZE)) * 0.15);
|
||||
#if MOSS_IN_CAVES < 2
|
||||
bool disableLight = true;
|
||||
#else
|
||||
bool disableLight = false;
|
||||
#endif
|
||||
|
||||
#if MOSS_SIDE_INTENSITY == 0
|
||||
float mossSide = 0.0;
|
||||
#else
|
||||
float mossSide = MOSS_SIDE_INTENSITY * 0.1;
|
||||
#endif
|
||||
|
||||
vec2 mossVec = getOverlayNoise(mossSide, disableLight, false, 0.1, MOSS_SIZE, worldPos, MOSS_TRANSPARENCY, MOSS_NOISE_REMOVE_INTENSITY * 1.5);
|
||||
|
||||
float mossNoise = mossVec.y;
|
||||
float mossVariable = mossVec.x;
|
||||
|
||||
#if MOSS_IN_CAVES == 0
|
||||
mossVariable *= inLushCave;
|
||||
#endif
|
||||
|
||||
mossColor *= 1.1;
|
||||
mossColor += 0.13 * mossNoise * MOSS_NOISE_INTENSITY; // make the noise less noticeable & configurable with option
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
#if MOSS_IN_CAVES == 0
|
||||
emission *= mix(1.0, overlayNoiseEmission, inLushCave * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, 0.0, mossVariable * inLushCave * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, smoothnessG, mossVariable * inLushCave * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#endif
|
||||
#else
|
||||
emission *= mix(1.0, overlayNoiseEmission, overlayNoiseIntensity * mossNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, 0.0, mossVariable * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, smoothnessG, mossVariable * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MOSS_IN_CAVES == 0
|
||||
smoothnessG = mix(smoothnessG, max(smoothnessG, 0.3 * color.g * float(color.g > color.b * 1.5)), mossVariable * inLushCave * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#else
|
||||
smoothnessG = mix(smoothnessG, max(smoothnessG, 0.3 * color.g * float(color.g > color.b * 1.5)), mossVariable * overlayNoiseIntensity * mossNoiseIntensity);
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_WATER
|
||||
#if MOSS_IN_CAVES == 0
|
||||
overlayNoiseTransparentOverwrite = mix(overlayNoiseTransparentOverwrite, overlayNoiseAlpha, inLushCave);
|
||||
fresnel = mix(fresnel, 0.01, mossVariable * overlayNoiseFresnelMult * inLushCave);
|
||||
#else
|
||||
overlayNoiseTransparentOverwrite = overlayNoiseAlpha;
|
||||
fresnel = mix(fresnel, 0.01, mossVariable * overlayNoiseFresnelMult);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mossVariable *= mossDecider;
|
||||
|
||||
color.rgb = mix(color.rgb, mossColor, mossVariable * overlayNoiseIntensity * mossNoiseIntensity * MOSS_TRANSPARENCY);
|
||||
color.a = mix(color.a, 1.0, clamp(overlayNoiseTransparentOverwrite * mossVariable * mossNoiseIntensity, 0.0, 1.0 * MOSS_TRANSPARENCY));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAND_NOISE_INTERNAL
|
||||
#if SAND_CONDITION < 2
|
||||
float sandDecider = -clamp01(pow2(min1(maxPlayerPosXZ / (200 * SAND_NOISE_DISTANCE)) * 2.0)) + 1.0; // The effect will only be around the player
|
||||
#else
|
||||
float sandDecider = 1.0;
|
||||
#endif
|
||||
if (sandDecider > 0.001){
|
||||
#if SAND_CONDITION == 0
|
||||
float desertSandColorMixer = inSand + inRedSand;
|
||||
vec3 sandColor = mix(
|
||||
vec3(0.9216, 0.8353, 0.6196), (inSand * vec3(0.9216, 0.8353, 0.6196) + inRedSand * vec3(0.5843, 0.3412, 0.1569)), desertSandColorMixer);
|
||||
#else
|
||||
vec3 sandColor = vec3(0.9216, 0.8353, 0.6196);
|
||||
#endif
|
||||
|
||||
#if SAND_SIDE_INTENSITY == 0
|
||||
float sandSide = 0.0;
|
||||
#else
|
||||
float sandSide = SAND_SIDE_INTENSITY * 0.1;
|
||||
#endif
|
||||
|
||||
vec2 sandVec = getOverlayNoise(sandSide, SAND_IN_CAVES, true, 0.1, SAND_SIZE, worldPos, SAND_TRANSPARENCY, SAND_NOISE_REMOVE_INTENSITY * 2.0);
|
||||
|
||||
float sandNoise = sandVec.y;
|
||||
float sandVariable = sandVec.x;
|
||||
|
||||
#if SAND_CONDITION == 0
|
||||
sandVariable *= desertSandColorMixer;
|
||||
#elif SAND_CONDITION == 1
|
||||
sandVariable *= inDry;
|
||||
#endif
|
||||
|
||||
sandColor *= 1.1;
|
||||
sandColor += 0.13 * sandNoise * SAND_NOISE_INTENSITY; // make the noise less noticeable & configurable with option
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
#if SAND_CONDITION == 0
|
||||
emission *= mix(1.0, overlayNoiseEmission, desertSandColorMixer * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, pow(color.g, 16.0) * 2.0, sandVariable * desertSandColorMixer * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, min1(smoothnessG), sandVariable * desertSandColorMixer * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, smoothnessG * 0.7, sandVariable * desertSandColorMixer * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#endif
|
||||
highlightMult = mix(highlightMult, 2.0, sandVariable * desertSandColorMixer * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#elif SAND_CONDITION == 1
|
||||
emission *= mix(1.0, overlayNoiseEmission, inDry * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, pow(color.g, 16.0) * 2.0, sandVariable * inDry * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, min1(smoothnessG), sandVariable * inDry * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, smoothnessG * 0.7, sandVariable * inDry * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#endif
|
||||
highlightMult = mix(highlightMult, 2.0, sandVariable * inDry * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#else
|
||||
emission *= overlayNoiseEmission;
|
||||
smoothnessG = mix(smoothnessG, pow(color.g, 16.0) * 2.0, sandVariable * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, min1(smoothnessG), sandVariable * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, smoothnessG * 0.7, sandVariable * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#endif
|
||||
highlightMult = mix(highlightMult, 2.0, sandVariable * overlayNoiseIntensity * sandNoiseIntensity);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_WATER
|
||||
#if SAND_CONDITION == 0
|
||||
overlayNoiseTransparentOverwrite = mix(0.0, overlayNoiseAlpha, desertSandColorMixer);
|
||||
fresnel = mix(fresnel, 0.01, sandVariable * overlayNoiseFresnelMult * desertSandColorMixer);
|
||||
#elif SAND_CONDITION == 1
|
||||
overlayNoiseTransparentOverwrite = mix(0.0, overlayNoiseAlpha, inDry);
|
||||
fresnel = mix(fresnel, 0.01, sandVariable * overlayNoiseFresnelMult * inDry);
|
||||
#else
|
||||
overlayNoiseTransparentOverwrite = overlayNoiseAlpha;
|
||||
fresnel = mix(fresnel, 0.01, sandVariable * overlayNoiseFresnelMult);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
sandVariable *= sandDecider;
|
||||
|
||||
color.rgb = mix(color.rgb, sandColor, sandVariable * overlayNoiseIntensity * sandNoiseIntensity * SAND_TRANSPARENCY);
|
||||
color.a = mix(color.a, 1.0, clamp(overlayNoiseTransparentOverwrite * sandVariable * overlayNoiseIntensity * sandNoiseIntensity * SAND_TRANSPARENCY, 0.0, 1.0));
|
||||
}
|
||||
#endif
|
||||
+510
@@ -0,0 +1,510 @@
|
||||
// Yes I hate myself for having done all of this in a big file and with functions. Thanks you me from a year ago
|
||||
|
||||
#include "/lib/shaderSettings/interactiveFoliage.glsl"
|
||||
#include "/lib/shaderSettings/emissiveFlowers.glsl"
|
||||
#include "/lib/shaderSettings/wavingBlocks.glsl"
|
||||
#define SNOW_NOISE_INTENSITY 1.0 //[0.5 0.75 1.0 1.25 1.5 2.0]
|
||||
#define SNOW_TRANSPARENCY 0.90 //[0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 1.00]
|
||||
#define MELTING_RADIUS 0.4 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define SNOW_SIZE 16 //[8 16 32 64 128]
|
||||
//#define SSS_SEASON_SNOW
|
||||
#define SNOW_NOISE_REMOVE_INTENSITY 1.00 //[0.00 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.60 1.70 1.80 1.90 2.00 2.25 2.50 2.75 3.00]
|
||||
#define WINTER_GREEN_AMOUNT 0.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
|
||||
#define SUMMER_STRENGTH 1.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5]
|
||||
|
||||
#define LESS_LEAVES 3 //[0 1 2 3 4 5]
|
||||
#define AUTUMN_NOISE_SIZE 1.0 //[0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define AUTUMN_STRENGTH 0.5 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
//#define EXTRA_FLOOR_LEAVES_IN_FORESTS
|
||||
|
||||
#define FLOWER_DENSITY 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define FLOWER_SIZE 16 //[8 16 32 64 128]
|
||||
#define FLOWER_AMOUNT 2 //[0 1 2 3 4 5 6 7 8 9 10]
|
||||
#define SPRING_GREEN_INTENSITY 1.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
//#define EMISSIVE_SPRING_FLOWERS
|
||||
#define DISABLE_SPRING_IN_DRY_BIOMES
|
||||
#ifdef EMISSIVE_SPRING_FLOWERS
|
||||
#endif
|
||||
|
||||
#ifndef GBUFFERS_HAND
|
||||
vec3 oldColor = color.rgb; // Needed for entities
|
||||
|
||||
float paleGardenDetector = 1.0;
|
||||
#if MC_VERSION >= 12104
|
||||
paleGardenDetector -= inPaleGarden;
|
||||
#endif
|
||||
|
||||
#if SEASONS != 2 && SEASONS != 5
|
||||
// Color Desaturation
|
||||
vec3 desaturatedColor = color.rgb;
|
||||
if (SEASON_COLOR_DESATURATION > 0.0) {
|
||||
float desaturation = SEASON_COLOR_DESATURATION;
|
||||
|
||||
#if SEASONS == 1 || SEASONS == 4
|
||||
if (winterTime > 0) {
|
||||
// snow conditions
|
||||
#if SNOW_CONDITION != 2
|
||||
desaturation *= inSnowy; // make only appear in cold biomes
|
||||
#elif SNOW_CONDITION == 0
|
||||
desaturation *= rainFactor; // make only appear in rain
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
desaturatedColor = mix(color.rgb, vec3(GetLuminance(color.rgb)), clamp01(desaturation - lmCoord.x));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool dhLeaves = true;
|
||||
#ifdef DH_TERRAIN
|
||||
if (BLOCK_LEAVES_SEASONS_DEFINE && (dhColor.r < 0.17 || dhColor.r > 0.7)) {
|
||||
dhLeaves = false;
|
||||
isFoliage = false;
|
||||
}
|
||||
#endif
|
||||
#if defined GBUFFERS_TERRAIN || defined DH_TERRAIN
|
||||
dhLeaves = dhLeaves && BLOCK_LEAVES_SEASONS_DEFINE && isFoliage;
|
||||
#endif
|
||||
|
||||
#if SEASONS == 1 || SEASONS == 2
|
||||
vec3 summerColor = color.rgb;
|
||||
if (summerTime > 0) {
|
||||
#if defined GBUFFERS_TERRAIN || defined DH_TERRAIN || defined VOXY_PATCH
|
||||
if (dhLeaves || (mat == 10132 || mat == 10133) && glColor.b < 0.999) { // Normal Grass Block
|
||||
summerColor = mix(summerColor, GetLuminance(summerColor) * vec3(1.0, 0.8941, 0.3725), 0.15 * SUMMER_STRENGTH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float autumnOnlyForests = 1.0;
|
||||
#ifdef AUTUMN_CONDITION
|
||||
autumnOnlyForests = inForest;
|
||||
#endif
|
||||
|
||||
#if SEASONS == 1 || SEASONS == 3
|
||||
vec3 autumnColor = vec3(0.0);
|
||||
|
||||
if (autumnTime > 0) {
|
||||
autumnColor = mix(color.rgb, desaturatedColor, 0.65 * autumnOnlyForests);
|
||||
|
||||
#if defined GBUFFERS_TERRAIN || defined GBUFFERS_BLOCK || defined DH_TERRAIN || defined VOXY_PATCH
|
||||
const vec3 autumnLeafColor0 = vec3(0.9922, 0.5707, 0.098);
|
||||
const vec3 autumnLeafColor1 = vec3(0.9922, 0.4786, 0.098);
|
||||
const vec3 autumnLeafColor2 = vec3(0.9804, 0.4033, 0.1569);
|
||||
const vec3 autumnLeafColor3 = vec3(0.9765, 0.3333, 0.149);
|
||||
const vec3 autumnLeafColor4 = vec3(0.5608, 0.2275, 0.1686);
|
||||
|
||||
float noiseLeavesColor1 = smoothstep(0.4, 0.7, Noise3D(worldPos * 0.0001 * AUTUMN_NOISE_SIZE));
|
||||
float noiseLeavesColor2 = smoothstep(0.3, 0.7, Noise3D(worldPos * 0.0003 * AUTUMN_NOISE_SIZE + 300.0));
|
||||
float noiseLeavesColor3 = smoothstep(0.65, 0.7, Noise3D(worldPos * 0.0005 * AUTUMN_NOISE_SIZE + 700.0));
|
||||
float noiseLeavesColor4 = smoothstep(0.7, 0.8, Noise3D(worldPos * 0.0003 * AUTUMN_NOISE_SIZE + 1000.0));
|
||||
|
||||
vec3 leafMainColor = mix(mix(mix(mix(autumnLeafColor0, autumnLeafColor1, noiseLeavesColor1), autumnLeafColor2, noiseLeavesColor2), autumnLeafColor3, noiseLeavesColor3), autumnLeafColor4, noiseLeavesColor4) * 1.5; // giant mix :p
|
||||
|
||||
bool isVine = mat == 10013 && inJungle < 0.5;
|
||||
|
||||
if (isFoliage) {
|
||||
if (mat == 10009 || mat == 10011 || dhLeaves || isVine) { // Except some leaves
|
||||
autumnColor *= mix(vec3(1.0), leafMainColor, autumnOnlyForests);
|
||||
} else {
|
||||
autumnColor *= mix(vec3(1.0), vec3(0.9882, 0.7725, 0.5725), autumnOnlyForests * 0.5);
|
||||
}
|
||||
} else { // leaves on the ground
|
||||
if (((mat == 10132 || mat == 10133)
|
||||
#ifdef DH_TERRAIN
|
||||
|| mat == DH_BLOCK_GRASS
|
||||
#endif
|
||||
) && glColor.b < 0.999) { // Normal Grass Block, grass part
|
||||
autumnColor *= mix(vec3(1.0), vec3(0.9882, 0.7725, 0.5725), autumnOnlyForests * 0.4);
|
||||
}
|
||||
#ifdef LEAVES_ON_GROUND
|
||||
vec3 absPlayerPos = abs(playerPos);
|
||||
float maxPlayerPosXZ = max(absPlayerPos.x, absPlayerPos.z);
|
||||
float leafDecider = -clamp01(pow2(min1(maxPlayerPosXZ / 100) * 2.0)) + 1.0; // The effect will only be around the player
|
||||
if (leafDecider > 0.001){
|
||||
float noiseLeavesFloorColor = float(hash33(floor(mod(worldPos, vec3(100.0)) * 16 + 0.03) * 16)) * 0.25;
|
||||
|
||||
vec3 leafFloorColorRandomMess = mix(mix(mix(mix(autumnLeafColor0, autumnLeafColor1, noiseLeavesFloorColor), autumnLeafColor2, noiseLeavesFloorColor), autumnLeafColor3, noiseLeavesFloorColor), autumnLeafColor4, noiseLeavesFloorColor) * 2.0;
|
||||
|
||||
vec3 leafFloorColor = mix(leafFloorColorRandomMess, leafMainColor, 0.66); // this mixes between the random colors and the colors of the leaves at the world pos
|
||||
|
||||
float topCheck = abs(clamp01(dot(normal, upVec)));
|
||||
float leafSide = 0.0;
|
||||
if (((mat == 10132 || mat == 10133) && glColor.b < 0.999) || (mat == 10126 && color.b + color.g < color.r * 2.0 && color.b > 0.3 && color.g < 0.45) || (mat == 10493 && color.r > 0.52 && color.b < 0.30 && color.g > 0.41 && color.g + color.b * 0.95 > color.r * 1.2)) { // Normal Grass Block and Dirt Path
|
||||
leafSide = 1.0;
|
||||
topCheck = 1.0;
|
||||
}
|
||||
vec2 leafVec = getOverlayNoise(1, true, false, 0.1, 16, worldPos, 1.0, 0.0);
|
||||
|
||||
float leafFloorNoise = leafVec.y;
|
||||
float leafVariable = leafVec.x;
|
||||
|
||||
leafFloorColor += 0.7 * leafFloorNoise; // make noisier
|
||||
float skylightCheck = (1.0 - pow(lmCoord.y + 0.01, 30.0)) * pow(lmCoord.y + 0.01, 2.0);
|
||||
|
||||
#ifdef ACT_GROUND_LEAVES_FIX
|
||||
if (skylightCheck > 0.001) {
|
||||
uint underneathLeaves = 0u;
|
||||
#define LEAVES_VOXEL_RANGE 20 // 20 blocks, increasing this to a large number would have a severe performance impact
|
||||
|
||||
float dither1 = 0.0, dither2 = 0.0, scatterAmount = 0.0;
|
||||
#ifdef TAA
|
||||
dither1 = fract(Bayer64(gl_FragCoord.xy) + goldenRatio * mod(float(frameCounter), 3600.0)) * 2.0 - 1.0;
|
||||
dither2 = fract(Bayer64(0.5 * gl_FragCoord.xy + 23) - goldenRatio * mod(float(frameCounter), 3600.0)) * 2.0 - 1.0;
|
||||
scatterAmount = 2.0;
|
||||
#endif
|
||||
|
||||
vec3 voxelPos = SceneToLeavesVoxel(playerPos + scatterAmount * vec3(dither1, -0.1, dither2)); // -0.1 fixes flickering inside water
|
||||
|
||||
for (int i = 0; i < LEAVES_VOXEL_RANGE; i++) {
|
||||
voxelPos.y += 1;
|
||||
|
||||
if (!CheckInsideLeavesVoxelVolume(voxelPos)) {
|
||||
underneathLeaves = 1u; // We don't touch the detection outside of the voxel volume
|
||||
break;
|
||||
}
|
||||
|
||||
vec3 voxelSamplePos = clamp01(voxelPos / vec3(leaves_voxelVolumeSize));
|
||||
uint voxelData = texture(leaves_sampler, voxelSamplePos).r;
|
||||
if (voxelData != 0u) {
|
||||
underneathLeaves = voxelData - 1u;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
leafVariable *= underneathLeaves;
|
||||
leafFloorColor += 1.25 * leafFloorNoise * underneathLeaves;
|
||||
}
|
||||
#endif
|
||||
|
||||
leafVariable = sqrt4(leafVariable); // make the noise less noticeable
|
||||
|
||||
leafVariable *= skylightCheck;
|
||||
|
||||
#ifdef EXTRA_FLOOR_LEAVES_IN_FORESTS
|
||||
float leafAddNoise1 = 1.0 - texture2DLod(noisetex, 0.0005 * (worldPos.xz + worldPos.y), 0.0).r * 1.3;
|
||||
float leafAddNoise2 = 1.0 - texture2DLod(noisetex, 0.005 * (worldPos.xz + worldPos.y), 0.0).r * 1.3;
|
||||
float leafAddNoise3 = texture2DLod(noisetex, 0.02 * (worldPos.xz + worldPos.y), 0.0).r * 1.3;
|
||||
leafVariable += mix(0.0, lmCoord.y * 1.0 - clamp(2.0 * leafAddNoise1 + 0.70 * leafAddNoise2 + 0.2 * leafAddNoise1, 0.0, 1.0), inForest);
|
||||
#endif
|
||||
|
||||
|
||||
leafVariable = clamp01(leafVariable);
|
||||
leafVariable *= topCheck; // make only appear on top of blocks
|
||||
|
||||
leafVariable *= leafDecider;
|
||||
|
||||
autumnColor *= mix(vec3(1.0), leafFloorColor, leafVariable * overlayNoiseIntensity * autumnOnlyForests * paleGardenDetector);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef GBUFFERS_ENTITIES
|
||||
autumnColor *= mix(vec3(1.0), vec3(1.0, 0.7, 0.5), autumnTime * 0.7 * autumnOnlyForests * AUTUMN_STRENGTH * paleGardenDetector);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SEASONS == 1 || SEASONS == 3 || SEASONS == 4) && (defined GBUFFERS_TERRAIN || defined DH_TERRAIN || defined VOXY_PATCH) && LESS_LEAVES > 0
|
||||
if (mat == 10009 || mat == 10011) { // Except some leaves
|
||||
float autumnWinterTime = autumnTime + winterTime;
|
||||
#if SNOW_CONDITION != 2
|
||||
autumnWinterTime *= mix(inSnowy + autumnOnlyForests, inSnowy, winterTime); // make only appear in cold biomes during winter
|
||||
#endif
|
||||
#if SNOW_CONDITION == 0
|
||||
autumnWinterTime *= mix(rainFactor + autumnOnlyForests, rainFactor, winterTime); // make only appear in rain during winter
|
||||
#endif
|
||||
float noiseLeaveAlpha = step(autumnWinterTime * LESS_LEAVES * 0.15, hash13(floor(mod(playerPos.xyz - 0.001 * (mat3(gbufferModelViewInverse) * normal) + cameraPosition.xyz, vec3(100.0)) * 4) * 4)); // remove some leaves with noise
|
||||
noiseLeaveAlpha += step(autumnWinterTime * LESS_LEAVES * 0.13, hash13(floor(mod(playerPos.xyz - 0.001 * (mat3(gbufferModelViewInverse) * normal) + cameraPosition.xyz, vec3(100.0)) * 16) * 16));
|
||||
color.a *= clamp01(noiseLeaveAlpha);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SEASONS == 1 || SEASONS == 4
|
||||
vec3 winterColor = vec3(0.0);
|
||||
|
||||
if (winterTime > 0) {
|
||||
float snowSide = 0.0;
|
||||
#if !defined GBUFFERS_ENTITIES && defined GBUFFERS_TERRAIN
|
||||
if (isFoliage) snowSide = mix(1.0, 0.0, 1.0 / (color.g * color.g) * 0.05); // make all foliage white
|
||||
#if !(defined DH_TERRAIN || defined VOXY_PATCH)
|
||||
if (((mat == 10132 || mat == 10133) && glColor.b < 0.999) || (mat == 10126 && color.b + color.g < color.r * 2.0 && color.b > 0.3 && color.g < 0.45) || (mat == 10493 && color.r > 0.52 && color.b < 0.30 && color.g > 0.41 && color.g + color.b * 0.95 > color.r * 1.2)) { // Normal Grass Block and Dirt Path
|
||||
snowSide = mix(0.0, 1.0, pow(blockUV.y, 3.0));
|
||||
#if defined SSS_SEASON_SNOW && (SEASONS == 1 || SEASONS == 4)
|
||||
#if SNOW_CONDITION == 0
|
||||
if (rainFactor > 0 && inSnowy > 0) subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true; // SSS
|
||||
#elif SNOW_CONDITION == 1
|
||||
if (inSnowy > 0) subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
|
||||
#else
|
||||
subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
|
||||
#endif
|
||||
#endif
|
||||
} // add to the side of grass, mycelium, path blocks; in that order. Use blockUV to increase transparency the the further down the block it goes
|
||||
#endif
|
||||
if ((mat == 10132 || mat == 10133) && glColor.b < 0.999) snowSide += abs(color.g - color.g * 0.5); // Normal Grass Block, mute the grass colors a bit
|
||||
|
||||
if (((mat == 10132 || mat == 10133)
|
||||
#ifdef DH_TERRAIN
|
||||
|| mat == DH_BLOCK_GRASS
|
||||
#endif
|
||||
) && glColor.b < 0.999 || isFoliage || dhLeaves && mat != 10007) { // Foliage except some leaves
|
||||
desaturatedColor = mix(desaturatedColor, mix(saturateColors(desaturatedColor, 0.4), desaturatedColor * vec3(0.9098, 0.6118, 0.4118), 0.5), winterTime * (1.0 - WINTER_GREEN_AMOUNT));
|
||||
}
|
||||
#endif
|
||||
|
||||
winterColor = desaturatedColor;
|
||||
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_COLORWHEEL
|
||||
oldColor = mix(color.rgb, winterColor, winterTime);
|
||||
#else
|
||||
float winterAlpha = color.a;
|
||||
|
||||
vec3 snowColor = vec3(0.9713, 0.9691, 0.9891);
|
||||
|
||||
vec2 snowVec = getOverlayNoise(snowSide, false, false, MELTING_RADIUS, SNOW_SIZE, worldPos, SNOW_TRANSPARENCY, SNOW_NOISE_REMOVE_INTENSITY * 1.2);
|
||||
|
||||
float snowNoise = snowVec.y;
|
||||
float snowVariable = snowVec.x;
|
||||
|
||||
snowColor *= 1.1;
|
||||
snowColor += 0.23 * snowNoise * SNOW_NOISE_INTENSITY; // make the noise less noticeable & configurable with option
|
||||
|
||||
snowVariable *= (1.0 - inDry) * SNOW_TRANSPARENCY;
|
||||
|
||||
// snow conditions
|
||||
#if SNOW_CONDITION != 2
|
||||
snowVariable *= inSnowy; // make only appear in cold biomes
|
||||
#endif
|
||||
#if SNOW_CONDITION == 0
|
||||
snowVariable *= rainFactor; // make only appear in rain
|
||||
#endif
|
||||
|
||||
#if SNOW_CONDITION == 0
|
||||
highlightMult = mix(highlightMult, 2.3 - subsurfaceMode * 0.1, snowVariable * IPBRMult * winterTime * rainFactor * inSnowy * overlayNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, 0.45 + 0.1 * snowNoise, snowVariable * IPBRMult * winterTime * rainFactor * inSnowy * overlayNoiseIntensity);
|
||||
#elif SNOW_CONDITION == 1
|
||||
highlightMult = mix(highlightMult, 2.3 - subsurfaceMode * 0.1, snowVariable * IPBRMult * winterTime * inSnowy * overlayNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, 0.45 + 0.1 * snowNoise, snowVariable * IPBRMult * winterTime * inSnowy * overlayNoiseIntensity);
|
||||
#else
|
||||
highlightMult = mix(highlightMult, 2.3 - subsurfaceMode * 0.1, snowVariable * IPBRMult * winterTime * overlayNoiseIntensity);
|
||||
smoothnessG = mix(smoothnessG, 0.45 + 0.1 * snowNoise, snowVariable * IPBRMult * winterTime * overlayNoiseIntensity);
|
||||
#endif
|
||||
|
||||
#ifdef SSS_SEASON_SNOW
|
||||
if (dot(normal, upVec) > 0.99) {
|
||||
#if SNOW_CONDITION == 0
|
||||
if (rainFactor > 0 && inSnowy > 0) subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
|
||||
#elif SNOW_CONDITION == 1
|
||||
if (inSnowy > 0) subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
|
||||
#else
|
||||
subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (dot(normal, upVec) > 0.99) {
|
||||
#if SNOW_CONDITION == 0
|
||||
emission = mix(emission, emission * overlayNoiseEmission, rainFactor * inSnowy * winterTime * overlayNoiseIntensity); // make only appear in rain
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, 0.0, snowVariable * rainFactor * inSnowy * winterTime * overlayNoiseIntensity);
|
||||
#endif
|
||||
#elif SNOW_CONDITION == 1
|
||||
emission = mix(emission, emission * overlayNoiseEmission, inSnowy * winterTime * overlayNoiseIntensity); // make only appear in cold biomes
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, 0.0, snowVariable * inSnowy * winterTime * overlayNoiseIntensity);
|
||||
#endif
|
||||
#else
|
||||
emission = mix(emission, emission * overlayNoiseEmission, winterTime * overlayNoiseIntensity);
|
||||
#ifndef DH_TERRAIN
|
||||
smoothnessD = mix(smoothnessD, 0.0, snowVariable * winterTime * overlayNoiseIntensity);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_WATER
|
||||
if (dot(normal, upVec) > 0.99) {
|
||||
#if SNOW_CONDITION == 0
|
||||
overlayNoiseTransparentOverwrite = mix(overlayNoiseTransparentOverwrite, overlayNoiseAlpha, rainFactor * inSnowy * winterTime);
|
||||
fresnel = mix(fresnel, 0.01, snowVariable * overlayNoiseFresnelMult * winterTime * rainFactor * inSnowy);
|
||||
#elif SNOW_CONDITION == 1
|
||||
overlayNoiseTransparentOverwrite = mix(overlayNoiseTransparentOverwrite, overlayNoiseAlpha, inSnowy * winterTime);
|
||||
fresnel = mix(fresnel, 0.01, snowVariable * overlayNoiseFresnelMult * winterTime * inSnowy);
|
||||
#else
|
||||
overlayNoiseTransparentOverwrite = mix(1.0, overlayNoiseAlpha, winterTime);
|
||||
fresnel = mix(fresnel, 0.01, snowVariable * overlayNoiseFresnelMult * winterTime);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// final mix
|
||||
winterColor = mix(winterColor, snowColor, snowVariable * overlayNoiseIntensity);
|
||||
winterAlpha = mix(color.a, 1.0, clamp(overlayNoiseTransparentOverwrite * snowVariable, 0.0, 1.0));
|
||||
color.a = mix(color.a, winterAlpha, winterTime * overlayNoiseIntensity);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SEASONS == 1 || SEASONS == 5
|
||||
vec3 springColor = color.rgb;
|
||||
if (springTime > 0) {
|
||||
#ifdef GBUFFERS_TERRAIN
|
||||
if (isFoliage || dhLeaves || (mat == 10132 || mat == 10133) && glColor.b < 0.999
|
||||
#ifdef DH_TERRAIN
|
||||
|| mat == DH_BLOCK_GRASS
|
||||
#endif
|
||||
) { // Foliage except some leaves, Normal Grass Block
|
||||
if (glColor.b < 0.99) springColor = mix(springColor, GetLuminance(springColor) * vec3(0.3725, 1.0, 0.4235), 0.5 * SPRING_GREEN_INTENSITY);
|
||||
}
|
||||
#if FLOWER_AMOUNT > 0 && !(defined DH_TERRAIN || defined VOXY_PATCH)
|
||||
if ((mat == 10132 || mat == 10133)) { // Normal Grass Block
|
||||
float flowerNoiseAdd = step(texture2DLod(noisetex, 0.0005 * (worldPos.xz + atMidBlock.xz / 64), 0.0).r, 0.25) * 3.5 + 1.0; // Noise to add more flowers
|
||||
float flowerNoiseRemove = clamp01(step(texture2DLod(noisetex, 0.003 * (worldPos.xz + atMidBlock.xz / 64), 0.0).g, 0.69) + 0.15); // Noise to reduce the amount of flowers
|
||||
|
||||
ivec2 flowerUV = ivec2(blockUV.xz * FLOWER_SIZE);
|
||||
|
||||
float flower1Variable = 0.0;
|
||||
float flower2Variable = 0.0;
|
||||
float flower3Variable = 0.0;
|
||||
float flower4Variable = 0.0;
|
||||
float flower5Variable = 0.0;
|
||||
|
||||
float flower4Emission = 0.0; // this exists to only make the purple part of the flower bud be emissive
|
||||
float flowerEmissionMask = 0.0;
|
||||
|
||||
const ivec2 flower1Size = ivec2(3, 3);
|
||||
const ivec2 flower2Size = ivec2(3, 3);
|
||||
const ivec2 flower3Size = ivec2(1, 1);
|
||||
const ivec2 flower4Size = ivec2(2, 2);
|
||||
const ivec2 flower5Size = ivec2(5, 5);
|
||||
|
||||
vec4 flower1Pixels[flower1Size.x * flower1Size.y] = vec4[flower1Size.x * flower1Size.y](
|
||||
vec4(0.0), vec4(1.0) , vec4(0.0),
|
||||
vec4(1.0), vec4(1.0, 0.8784, 0.2706, 1.0), vec4(1.0),
|
||||
vec4(0.0), vec4(1.0) , vec4(0.0)
|
||||
);
|
||||
vec4 flower2Pixels[flower2Size.x * flower2Size.y] = vec4[flower2Size.x * flower2Size.y](
|
||||
vec4(0.0), vec4(0.9922, 0.7686, 0.4078, 1.0) , vec4(0.0),
|
||||
vec4(0.9922, 0.7686, 0.4078, 1.0), vec4(0.8471, 0.5216, 0.0627, 1.0), vec4(0.9922, 0.7686, 0.4078, 1.0),
|
||||
vec4(0.0), vec4(0.9922, 0.7686, 0.4078, 1.0) , vec4(0.0)
|
||||
);
|
||||
vec4 flower3Pixels[flower3Size.x] = vec4[flower3Size.x](vec4(1.0, 0.8784, 0.2706, 1.0));
|
||||
vec4 flower4Pixels[flower4Size.x * flower4Size.y] = vec4[flower4Size.x * flower4Size.y](
|
||||
vec4(0.1137, 0.3882, 0.1137, 1.0), vec4(0.5294, 0.2902, 0.5647, 1.0),
|
||||
vec4(0.1059, 0.3333, 0.0863, 1.0), vec4(0.1137, 0.3882, 0.1137, 1.0)
|
||||
);
|
||||
vec4 flower5Pixels[flower5Size.x * flower5Size.y] = vec4[flower5Size.x * flower5Size.y](
|
||||
vec4(0.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.0), vec4(0.0),
|
||||
vec4(0.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.9137, 0.5882, 0.9647, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0),
|
||||
vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.9137, 0.5882, 0.9647, 1.0), vec4(0.8667, 0.2627, 0.9569, 1.0), vec4(0.9137, 0.5882, 0.9647, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0),
|
||||
vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.9137, 0.5882, 0.9647, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.0),
|
||||
vec4(0.0), vec4(0.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.6627, 0.4118, 0.7373, 1.0), vec4(0.0)
|
||||
);
|
||||
|
||||
for (int i = 1; i <= FLOWER_AMOUNT; i++) {
|
||||
if (NdotU > 0.99) {
|
||||
ivec2 randomFlower1UV = ivec2((hash33(mod(floor(worldPos + atMidBlock / 64), vec3(200)) + i) * 0.5 + 0.5) * (FLOWER_SIZE + 1 - flower1Size.x)); // here the bigger component of flower1Size should be used, currently all flowers are symmetric
|
||||
ivec2 randomFlower2UV = ivec2((hash33(mod(floor(worldPos + atMidBlock / 64), vec3(300)) + i) * 0.5 + 0.5) * (FLOWER_SIZE + 1 - flower2Size.x));
|
||||
ivec2 randomFlower3UV = ivec2((hash33(mod(floor(worldPos + atMidBlock / 64), vec3(400)) + i) * 0.5 + 0.5) * (FLOWER_SIZE + 1 - flower3Size.x));
|
||||
ivec2 randomFlower4UV = ivec2((hash33(mod(floor(worldPos + atMidBlock / 64), vec3(501))) * 0.5 + 0.5) * (FLOWER_SIZE + 1 - flower4Size.x)); // Only 1 flower should max generate on a block for flower4/5
|
||||
ivec2 randomFlower5UV = ivec2((hash33(mod(floor(worldPos + atMidBlock / 64), vec3(500))) * 0.5 + 0.5) * (FLOWER_SIZE + 1 - flower5Size.x));
|
||||
|
||||
float randomFlower1Block = step(hash13(mod(floor(worldPos + atMidBlock / 64), vec3(300)) + i), 0.15 * flowerNoiseRemove * flowerNoiseAdd * FLOWER_DENSITY);
|
||||
float randomFlower2Block = step(hash13(mod(floor(worldPos + atMidBlock / 64), vec3(200)) + i), 0.15 * flowerNoiseRemove * flowerNoiseAdd * FLOWER_DENSITY);
|
||||
float randomFlower3Block = step(hash13(mod(floor(worldPos + atMidBlock / 64), vec3(500)) + i), 0.40 * flowerNoiseRemove * flowerNoiseAdd * FLOWER_DENSITY);
|
||||
float randomFlower45Block = step(hash13(mod(floor(worldPos + atMidBlock / 64), vec3(400))) , 0.001 * flowerNoiseRemove * flowerNoiseAdd * FLOWER_DENSITY); // both purple flowers should appear only on the same block
|
||||
float inverseRandomFlower45Block = randomFlower45Block * -1.0 + 1.0; // to remove other flower types on the block where the purple flower is on
|
||||
|
||||
ivec2 flower1RelCoord = flowerUV - randomFlower1UV;
|
||||
ivec2 flower2RelCoord = flowerUV - randomFlower2UV;
|
||||
ivec2 flower3RelCoord = flowerUV - randomFlower3UV;
|
||||
ivec2 flower4RelCoord = flowerUV - randomFlower4UV;
|
||||
ivec2 flower5RelCoord = flowerUV - randomFlower5UV;
|
||||
|
||||
if (all(greaterThanEqual(flower1RelCoord, ivec2(0))) && all(lessThan(flower1RelCoord, flower1Size))) { // if the position is inside the flower, do the flower
|
||||
vec4 flower1Col = flower1Pixels[flower1RelCoord.x + flower1Size.x * flower1RelCoord.y]; // this flower pixel's colour
|
||||
flower1Variable = flower1Col.a * randomFlower1Block * inverseRandomFlower45Block;
|
||||
springColor = mix(springColor, flower1Col.rgb, flower1Variable); // apply the flower colour
|
||||
}
|
||||
if (all(greaterThanEqual(flower2RelCoord, ivec2(0))) && all(lessThan(flower2RelCoord, flower2Size))) {
|
||||
vec4 flower2Col = flower2Pixels[flower2RelCoord.x + flower2Size.x * flower2RelCoord.y];
|
||||
flower2Variable = flower2Col.a * randomFlower2Block * inverseRandomFlower45Block;
|
||||
springColor = mix(springColor, flower2Col.rgb, flower2Variable);
|
||||
}
|
||||
if (all(greaterThanEqual(flower3RelCoord, ivec2(0))) && all(lessThan(flower3RelCoord, flower3Size))) {
|
||||
vec4 flower3Col = flower3Pixels[flower3RelCoord.x + flower3RelCoord.y];
|
||||
flower3Variable = flower3Col.a * randomFlower3Block * inverseRandomFlower45Block;
|
||||
springColor = mix(springColor, flower3Col.rgb, flower3Variable);
|
||||
}
|
||||
if (all(greaterThanEqual(flower4RelCoord, ivec2(0))) && all(lessThan(flower4RelCoord, flower4Size))) {
|
||||
vec4 flower4Col = flower4Pixels[flower4RelCoord.x + flower4Size.x * flower4RelCoord.y];
|
||||
flower4Variable = flower4Col.a * randomFlower45Block;
|
||||
flower4Emission = flower4Variable * (1.0 - step(flower4Col.r , 0.5));
|
||||
springColor = mix(springColor, flower4Col.rgb, flower4Variable);
|
||||
}
|
||||
if (all(greaterThanEqual(flower5RelCoord, ivec2(0))) && all(lessThan(flower5RelCoord, flower5Size))) {
|
||||
vec4 flower5Col = flower5Pixels[flower5RelCoord.x + flower5Size.x * flower5RelCoord.y];
|
||||
flower5Variable = flower5Col.a * randomFlower45Block;
|
||||
springColor = mix(springColor, flower5Col.rgb, flower5Variable);
|
||||
}
|
||||
|
||||
#if EMISSIVE_FLOWERS > 0
|
||||
flowerEmissionMask = max(emission, (flower1Variable + flower2Variable + flower3Variable + flower4Emission + flower5Variable)); // Emission Mask
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if EMISSIVE_FLOWERS > 0 && defined EMISSIVE_SPRING_FLOWERS
|
||||
#if EMISSIVE_FLOWERS_TYPE == 1
|
||||
if (color.b < max(color.r, color.g * 1.1) * 0.95) emission = 0.0;
|
||||
#elif EMISSIVE_FLOWERS_TYPE == 2
|
||||
if (color.r < max(color.b * 1.15, color.g * 1.1) * 0.95) emission = 0.0;
|
||||
#endif
|
||||
emission = 2.0 * skyLightCheck * flowerEmissionMask * pow3(springTime);
|
||||
#if EMISSIVE_FLOWERS == 2
|
||||
emission = max(emission, mix(0.0, rainFactor + 1.0 * rainFactor, flowerEmissionMask));
|
||||
#endif
|
||||
emission *= EMISSIVE_FLOWERS_STRENGTH;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
float dryBiome = 1;
|
||||
#ifdef DISABLE_SPRING_IN_DRY_BIOMES
|
||||
dryBiome = 1.0 - inDry;
|
||||
#endif
|
||||
springColor = mix(color.rgb, springColor, springTime * dryBiome * paleGardenDetector);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SEASONS == 1
|
||||
vec3 summerToAutumn = mix(summerColor, autumnColor, summer);
|
||||
vec3 autumnToWinter = mix(summerToAutumn, winterColor, autumn);
|
||||
vec3 winterToSpring = mix(autumnToWinter, springColor, winter);
|
||||
vec3 springToSummer = mix(winterToSpring, summerColor, spring);
|
||||
|
||||
#ifndef GBUFFERS_ENTITIES
|
||||
color.rgb = springToSummer;
|
||||
#endif
|
||||
|
||||
#elif SEASONS == 2
|
||||
color.rgb = summerColor;
|
||||
|
||||
#elif SEASONS == 3
|
||||
color.rgb = autumnColor;
|
||||
|
||||
#elif SEASONS == 4
|
||||
color.rgb = winterColor;
|
||||
|
||||
#elif SEASONS == 5
|
||||
color.rgb = springColor;
|
||||
#endif
|
||||
|
||||
#ifdef GBUFFERS_ENTITIES
|
||||
color.rgb = oldColor;
|
||||
#endif
|
||||
#endif
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#if SEASONS == 1
|
||||
#ifdef EUPHORIA_PATCHES_IS_SEASONS_MOD_INSTALLED
|
||||
int seasonLength = euphoriaPatchesSeasonDuration;
|
||||
float YearLoop = mod(float(euphoriaPatchesCurrentSeasonTick - seasonLength), float(euphoriaPatchesTotalSeasonDuration));
|
||||
#else
|
||||
#if SEASON_LENGTH >= 24000
|
||||
int seasonLength = SEASON_LENGTH;
|
||||
#else
|
||||
int seasonLength = SEASON_LENGTH * 24000;
|
||||
#endif
|
||||
float YearLoop = int(worldDay * 24000 + worldTimeSmooth + SEASON_START * seasonLength) % (seasonLength * 4);
|
||||
#endif
|
||||
|
||||
float spring = max(0.0, (1.0 + SEASON_TRANSITION_START) * (clamp(YearLoop - seasonLength * 3, 0, seasonLength) / seasonLength) - SEASON_TRANSITION_START);
|
||||
float summer = max(0.0, (1.0 + SEASON_TRANSITION_START) * (clamp(YearLoop - seasonLength * 0, 0, seasonLength) / seasonLength) - SEASON_TRANSITION_START);
|
||||
float autumn = max(0.0, (1.0 + SEASON_TRANSITION_START * 2.5) * (clamp(YearLoop - seasonLength * 1, 0, seasonLength) / seasonLength) - SEASON_TRANSITION_START * 2.5); // 2.5 to make snow appear sooner
|
||||
float winter = max(0.0, (1.0 + SEASON_TRANSITION_START) * (clamp(YearLoop - seasonLength * 2, 0, seasonLength) / seasonLength) - SEASON_TRANSITION_START);
|
||||
|
||||
float summerTime = spring - summer + 1.0;
|
||||
float autumnTime = summer - autumn;
|
||||
float winterTime = autumn - winter;
|
||||
float springTime = winter - spring;
|
||||
|
||||
#elif SEASONS == 2
|
||||
float summerTime = 1.0;
|
||||
float autumnTime = 0.0;
|
||||
float winterTime = 0.0;
|
||||
float springTime = 0.0;
|
||||
#elif SEASONS == 3
|
||||
float summerTime = 0.0;
|
||||
float autumnTime = 1.0;
|
||||
float winterTime = 0.0;
|
||||
float springTime = 0.0;
|
||||
#elif SEASONS == 4
|
||||
float summerTime = 0.0;
|
||||
float autumnTime = 0.0;
|
||||
float winterTime = 1.0;
|
||||
float springTime = 0.0;
|
||||
#elif SEASONS == 5
|
||||
float summerTime = 0.0;
|
||||
float autumnTime = 0.0;
|
||||
float winterTime = 0.0;
|
||||
float springTime = 1.0;
|
||||
#endif
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "/lib/materials/specificMaterials/entities/itemFrame.glsl"
|
||||
+1
@@ -0,0 +1 @@
|
||||
noSmoothLighting = true;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// SpacEagle17's custom skin indicator
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_BLOCK
|
||||
#define TEXCOORD_FOR_SPACEAGLE17 texCoord
|
||||
if (CheckForColor(texelFetch(tex, ivec2(0, 0), 0).rgb, vec3(233, 41, 209))) {
|
||||
#else
|
||||
#define TEXCOORD_FOR_SPACEAGLE17 quadTexCoord
|
||||
#endif
|
||||
vec3 hsv = rgb2hsv(colorP.rgb);
|
||||
float luminance = GetLuminance(colorP.rgb);
|
||||
if (TEXCOORD_FOR_SPACEAGLE17.y < 0.25) { // Head
|
||||
float blinkPhase = mod(frameTimeCounter, 7.0);
|
||||
float blink = 1.0 - smoothstep(0.08, 0.0, abs(blinkPhase - 0.04));
|
||||
if (hsv.g > 0.06) { // Eyes
|
||||
emission = 7 * luminance * blink;
|
||||
color.rgb = mix(vec3(luminance), color.rgb, 0.85) * blink;
|
||||
}
|
||||
}
|
||||
#ifndef GBUFFERS_BLOCK
|
||||
else {
|
||||
if (TEXCOORD_FOR_SPACEAGLE17.x < 0.6 && hsv.g > 0.05) { // Legs
|
||||
if (hsv.r < 0.6) { // Portal
|
||||
float powVal = 1.0 + 3.0 * (cos(frameTimeCounter * 1.5) * 0.5 + 0.5);
|
||||
emission = 0.25 + pow4(luminance) * 4.0 * float(colorP.b > 0.8) + 3.0 * max(pow(hsv.g, powVal), 0.15);
|
||||
} else { // Lightning
|
||||
emission = 1.15 + (1.0 - hsv.g) * 1.2 * sin(frameTimeCounter * 2.5 + TEXCOORD_FOR_SPACEAGLE17.y * 6.2831);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
float emissionMask = 1.0 - step(0.001, emission);
|
||||
smoothnessD = (1.0 - pow2(colorP.g)) * 0.07 * emissionMask;
|
||||
smoothnessG = smoothnessD;
|
||||
#if defined GBUFFERS_ENTITIES || defined GBUFFERS_BLOCK
|
||||
}
|
||||
#endif
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
#define END_PORTAL_VARIATION 0 // [0 1 3] 2 is removed on purpose
|
||||
// End Portal fix by fayer3#2332 (Modified)
|
||||
float dither = Bayer64(gl_FragCoord.xy);
|
||||
#ifdef TAA
|
||||
dither = fract(dither + goldenRatio * mod(float(frameCounter), 3600.0));
|
||||
int repeat = 4;
|
||||
#else
|
||||
int repeat = 8;
|
||||
#endif
|
||||
|
||||
#if END_PORTAL_VARIATION == 0 || END_PORTAL_VARIATION == 1
|
||||
#if END_PORTAL_VARIATION == 0
|
||||
vec3[8] colors = vec3[](
|
||||
vec3(0.3472479, 0.6559956, 0.7387838) * 1.5,
|
||||
vec3(0.6010780, 0.7153565, 1.060625 ),
|
||||
vec3(0.4221090, 0.8135094, 0.9026056),
|
||||
vec3(0.3492291, 1.0241201, 1.8612821),
|
||||
vec3(0.7543085, 0.8238697, 0.6803233),
|
||||
vec3(0.4144472, 0.5648165, 0.8037 ),
|
||||
vec3(0.508905 , 0.6719649, 0.9982805),
|
||||
vec3(0.5361914, 0.4476583, 0.8008522));
|
||||
color.rgb = vec3(0.421, 0.7, 1.6) * 0.14;
|
||||
#else
|
||||
vec3[3] colors = vec3[](
|
||||
vec3(1.0, 0.0, 0.0),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
vec3(0.0, 0.0, 1.0));
|
||||
color.rgb = vec3(0.4214321, 0.4722309, 1.9922364) * 0.08;
|
||||
#endif
|
||||
|
||||
float dismult = 0.5;
|
||||
for (int j = 0; j < repeat; j++) {
|
||||
float add = float(j + dither) * 0.0625 / float(repeat);
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
vec2 offset = vec2(0.0, 1.0/(3600.0/24.0)) * pow(16.0 - i, 2.0) * 0.004;
|
||||
vec2 wind = fract((frameTimeCounter + 984.0) * (i + 8) * 0.125 * offset);
|
||||
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * (i * dismult + 1), 1.0)).xyz);
|
||||
if (abs(NdotU) > 0.9) {
|
||||
wpos.xz /= wpos.y;
|
||||
wpos.xz *= 0.06 * sign(- playerPos.y);
|
||||
wpos.xz *= abs(playerPos.y) + i * dismult + add;
|
||||
wpos.xz -= cameraPosition.xz * 0.05;
|
||||
} else {
|
||||
vec3 absPos = abs(playerPos);
|
||||
if (abs(dot(normal, eastVec)) > 0.9) {
|
||||
wpos.xz = wpos.yz / wpos.x;
|
||||
wpos.xz *= 0.06 * sign(- playerPos.x);
|
||||
wpos.xz *= abs(playerPos.x) + i * dismult + add;
|
||||
wpos.xz -= cameraPosition.yz * 0.05;
|
||||
} else {
|
||||
wpos.xz = wpos.yx / wpos.z;
|
||||
wpos.xz *= 0.06 * sign(- playerPos.z);
|
||||
wpos.xz *= abs(playerPos.z) + i * dismult + add;
|
||||
wpos.xz -= cameraPosition.yx * 0.05;
|
||||
}
|
||||
}
|
||||
vec2 pos = wpos.xz;
|
||||
|
||||
#if END_PORTAL_VARIATION == 0
|
||||
float colormult = 0.9/(30.0+i);
|
||||
float rotation = (i - 0.1 * i + 0.71 * i - 11 * i + 21) * 0.01 + i * 0.01;
|
||||
float Cos = cos(radians(rotation));
|
||||
float Sin = sin(radians(rotation));
|
||||
|
||||
vec2 coord = mat2(Cos, Sin, -Sin, Cos) * pos + wind;
|
||||
if (mod(float(i), 4) < 1.5) coord = coord.yx + vec2(-1.0, 1.0) * wind.y;
|
||||
|
||||
vec3 psample = pow(texture2D(tex, coord).rgb, vec3(0.85)) * colors[i-1] * colormult;
|
||||
color.rgb += psample * length(psample.rgb) * (3000.0 / repeat);
|
||||
#else
|
||||
float noisePortal = texture2DLod(noisetex, pos * 0.5, 0.0).g;
|
||||
color.rgb += texture2DLod(noisetex, vec2(noisePortal, noisePortal) + wind * 2.0, 0.0).g * colors[i % 3] * 0.1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
color.rgb *= vec3(0.09, 0.086, 0.06) * 0.9;
|
||||
emission = 10.0;
|
||||
#elif END_PORTAL_VARIATION == 3 // Thanks to WoMspace
|
||||
float portalEffectSpeed = 3.0;
|
||||
vec3 roundedCoords = floor((playerPos - vec3(0.001) + cameraPosition) * 16.0); // not perfect yet, portal shifts when moving up or down
|
||||
float pixelPortalEffect = 0.0;
|
||||
for (int i = 0; i < 5; i++){
|
||||
float currentTime = floor(frameTimeCounter * portalEffectSpeed + float(i));
|
||||
float nextTime = floor(frameTimeCounter * portalEffectSpeed + 1.0 + float(i));
|
||||
// float currentFrame = hash14(vec4(roundedCoords, floor(worldPos.y * 16.0), currentTime));
|
||||
float currentFrame = hash13(vec3(roundedCoords + currentTime));
|
||||
// float nextFrame = hash14(vec4(roundedCoords, floor(worldPos.y * 16.0), nextTime));
|
||||
float nextFrame = hash13(vec3(roundedCoords + nextTime));
|
||||
pixelPortalEffect += mix(currentFrame, nextFrame, fract(frameTimeCounter * portalEffectSpeed));
|
||||
}
|
||||
pixelPortalEffect /= 5.0;
|
||||
|
||||
color.rgb = vec3(0.37, 0.5, 0.8) * pow(pixelPortalEffect, 5.0) * 10.0;
|
||||
emission = pow(pixelPortalEffect, 5.0) * 2.0;
|
||||
lmCoordM.x = 0.0;
|
||||
#endif
|
||||
noDirectionalShading = true;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef PORTAL_EDGE_EFFECT
|
||||
//vec3 voxelPos = SceneToVoxel(mix(playerPos, vec3(0.0), -0.02)); // Fixes weird parallax offset
|
||||
vec3 voxelPos = SceneToVoxel(playerPos);
|
||||
|
||||
if (CheckInsideVoxelVolume(voxelPos)) {
|
||||
float portalOffset = 0.08333 * dither;
|
||||
vec3[4] portalOffsets = vec3[](
|
||||
vec3( portalOffset, 0, portalOffset),
|
||||
vec3( portalOffset, 0,-portalOffset),
|
||||
vec3(-portalOffset, 0, portalOffset),
|
||||
vec3(-portalOffset, 0,-portalOffset)
|
||||
);
|
||||
|
||||
float edge = 0.0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int voxel = int(GetVoxelVolume(ivec3(voxelPos + portalOffsets[i])));
|
||||
if (voxel == 58 || voxel == 255) { // End Portal Frame or Bedrock
|
||||
edge = 1.0; break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef END
|
||||
// No edge effect in the middle of the return fountain
|
||||
vec2 var1 = abs(playerPos.xz + cameraPosition.xz - 0.5);
|
||||
float var2 = max(var1.x, var1.y);
|
||||
if (var2 > 1.0)
|
||||
#endif
|
||||
{
|
||||
vec4 edgeColor = vec4(vec3(0.18, 0.5, 0.45), 1.0);
|
||||
#if END_PORTAL_VARIATION == 3
|
||||
edgeColor = vec4(vec3(0.2431, 0.2588, 0.7294), 1.0);
|
||||
#endif
|
||||
color = mix(color, edgeColor, edge);
|
||||
emission = mix(emission, 5.0, edge);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
color = vec4(0.5, 0.55, 0.7, 1.0);
|
||||
|
||||
#ifndef GBUFFERS_LIGHTNING
|
||||
color.rgb *= 2.0;
|
||||
lmCoordM = vec2(0.0);
|
||||
shadowMult = vec3(0.0);
|
||||
|
||||
emission = 0.5;
|
||||
#endif
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
normalM = upVec;
|
||||
|
||||
highlightMult = 0.0;
|
||||
shadowMult = vec3(0.0);
|
||||
|
||||
#if MC_VERSION >= 11700
|
||||
if (lmCoord.x > 0.99) { // Glowing Sign Text
|
||||
lmCoordM = vec2(0.0);
|
||||
|
||||
emission = 1.0;
|
||||
|
||||
color.rgb *= length(color.rgb) + 0.5;
|
||||
} else // Normal Sign Text
|
||||
#endif
|
||||
color.rgb *= 5.0;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
smoothnessG = color.g;
|
||||
smoothnessD = color.g;
|
||||
|
||||
emission = min(max0(dot(color.rgb, color.rgb) - 1.0) * 6.0, 1.0);
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(pow2(color.r)) * 0.45;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.5;
|
||||
#endif
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
smoothnessG = color.r * 0.3;
|
||||
smoothnessD = color.r * 0.25;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(pow2(color.g)) * 0.55;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(pow2(color.g)) * 0.5;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(color.r) * 0.5;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.77;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = dot(color.rgb, vec3(0.2));
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
smoothnessG = pow2(pow2(pow2(color.g))) * 12.0;
|
||||
smoothnessG = min1(smoothnessG);
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
smoothnessG = pow2(color.r) * 0.5;
|
||||
smoothnessG = min1(smoothnessG);
|
||||
smoothnessD = smoothnessG;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(dot(color.rgb, color.rgb)) * 0.105;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.77;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(color.g) * 0.22;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(dot(color.rgb, vec3(0.3)));
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.66;
|
||||
#endif
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
smoothnessG = pow2(color.g) * 0.5;
|
||||
smoothnessD = smoothnessG;
|
||||
|
||||
#ifdef COATED_TEXTURES
|
||||
noiseFactor = 0.77;
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user