This commit is contained in:
lucasdpt
2026-06-14 02:07:47 +02:00
parent 398e1e6ddf
commit 0129d81bd4
2475 changed files with 553889 additions and 553884 deletions
@@ -1,123 +1,123 @@
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+, Banner+, 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) { //
} 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;
}
}
}
}
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+, Banner+, 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) { //
} 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;
}
}
}
}
@@ -1,146 +1,146 @@
#ifdef POM
#include "/lib/materials/materialMethods/pomEffects.glsl"
#endif
#include "/lib/materials/materialMethods/customEmission.glsl"
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, 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
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);
float smoothnessM = pow2(specularMap.r);
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
#endif
}
#ifdef POM
#include "/lib/materials/materialMethods/pomEffects.glsl"
#endif
#include "/lib/materials/materialMethods/customEmission.glsl"
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, 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
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);
float smoothnessM = pow2(specularMap.r);
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
#endif
}
@@ -1,71 +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
}
}
}
}
}
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
}
}
}
}
}
@@ -1,23 +1,23 @@
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);
intenseFresnel = materialMaskInt / 240.0;
#endif
reflectColor = mix(vec3(1.0), color.rgb / (max(color.r, max(color.g, color.b)) + 0.00001), metalness);
#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;
}
}
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);
intenseFresnel = materialMaskInt / 240.0;
#endif
reflectColor = mix(vec3(1.0), color.rgb / (max(color.r, max(color.g, color.b)) + 0.00001), metalness);
#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;
}
}
@@ -1,498 +1,498 @@
#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) { // Item Frame, Glow Item Frame
noSmoothLighting = true;
} else if (entityId == 50012) { // Iron Golem
#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)) ||
CheckForColor(color.rgb, vec3( 49, 173, 183)) ||
CheckForColor(color.rgb, vec3(101, 224, 221))) 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) { // 50128 to 50132
// 50128
// 50129
// 50130
// 50131
} else { // 50132 to 50136
// 50132
// 50133
// 50134
// 50135
}
} 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
}
}
}
}
}
}
#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) { // Item Frame, Glow Item Frame
noSmoothLighting = true;
} else if (entityId == 50012) { // Iron Golem
#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)) ||
CheckForColor(color.rgb, vec3( 49, 173, 183)) ||
CheckForColor(color.rgb, vec3(101, 224, 221))) 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) { // 50128 to 50132
// 50128
// 50129
// 50130
// 50131
} else { // 50132 to 50136
// 50132
// 50133
// 50134
// 50135
}
} 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
}
}
}
}
}
}
@@ -1,265 +1,265 @@
#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 < 45064) {
if (currentRenderedItemId < 45032) {
if (currentRenderedItemId < 45016) {
if (currentRenderedItemId < 45008) {
if (currentRenderedItemId == 45000) { // Armor Trims
smoothnessG = 0.5;
highlightMult = 2.0;
smoothnessD = 0.5;
#ifdef GLOWING_ARMOR_TRIM
emission = 1.0;
#endif
#ifdef SITUATIONAL_GLOWING_TRIMS
emission *= skyLightCheck;
#endif
} else if (currentRenderedItemId == 45004) { // Wooden Tools, Bow, Fishing Rod
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
smoothnessG = min(smoothnessG, 0.4);
smoothnessD = smoothnessG;
}
} else {
if (currentRenderedItemId == 45008) { // Stone Tools
if (CheckForStick(color.rgb)) {
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
} else {
#include "/lib/materials/specificMaterials/terrain/stone.glsl"
}
} else /*if (currentRenderedItemId == 45012)*/ { // 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"
}
}
}
} else {
if (currentRenderedItemId < 45024) {
if (currentRenderedItemId == 45016) { // 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"
}
} else /*if (currentRenderedItemId == 45020)*/ { // 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"
}
}
} else {
if (currentRenderedItemId == 45024) { // 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
} else /*if (currentRenderedItemId == 45028)*/ { // Trident Item
#include "/lib/materials/specificMaterials/others/trident.glsl"
}
}
}
} else {
if (currentRenderedItemId < 45048) {
if (currentRenderedItemId < 45040) {
if (currentRenderedItemId == 45032) { // 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 /*if (currentRenderedItemId == 45036)*/ { // 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 == 45040) { // 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 /*if (currentRenderedItemId == 45044)*/ { // Bottle o' Enchanting, Glow Inc Sac
emission = color.b * 2.0;
}
}
} else {
if (currentRenderedItemId < 45056) {
if (currentRenderedItemId == 45048) { // 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 /*if (currentRenderedItemId == 45052)*/ { // Chorus Fruit
emission = max0(color.b * 2.0 - color.r) * 1.5;
}
} else {
if (currentRenderedItemId == 45056) { // Amethyst Shard
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(color.r);
smoothnessG = 0.8 - factor * 0.3;
highlightMult = factor * 3.0;
smoothnessD = factor;
} else /*if (currentRenderedItemId == 45060)*/ { // 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 == 45064) { // Turtle Shell
float factor = color.g * 0.7;
smoothnessG = factor;
highlightMult = factor * 3.0;
smoothnessD = factor;
} else /*if (currentRenderedItemId == 45068)*/ { // Ender Pearl
smoothnessG = 1.0;
highlightMult = 2.0;
smoothnessD = 1.0;
}
} else {
if (currentRenderedItemId == 45072) { // 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 /*if (currentRenderedItemId == 45076)*/ { // 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 == 45080) { // Compass
if (color.r - 0.1 > color.b + color.g) {
emission = color.r * 1.5;
}
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
} else /*if (currentRenderedItemId == 45084)*/ { // 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 == 45088) { // Nether Star
emission = pow2(color.r + color.g) * 0.5;
} else /*if (currentRenderedItemId == 45092)*/ { // 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 == 45096) { // Glow Berries
// iris needs to add support
} else /*if (currentRenderedItemId == 45100)*/ { // Glowstone Dust
emission = dot(color.rgb, color.rgb) * 0.5 + 1.0;
}
} else {
if (currentRenderedItemId == 45104) { // Prismarine Crystals
emission = pow1_5(color.r) * 2.5 + 0.2;
} else /*if (currentRenderedItemId == 45108)*/ { // Totem of Undying
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
}
}
} else {
if (currentRenderedItemId < 45120) {
if (currentRenderedItemId == 45112) { // 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 /*if (currentRenderedItemId == 45116)*/ { // Copper Tools, Copper Armor, Copper Ingot, Copper Horse Armor
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
smoothnessD *= 0.5;
}
} 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)*/ { //
}
}
}
}
}
#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 < 45064) {
if (currentRenderedItemId < 45032) {
if (currentRenderedItemId < 45016) {
if (currentRenderedItemId < 45008) {
if (currentRenderedItemId == 45000) { // Armor Trims
smoothnessG = 0.5;
highlightMult = 2.0;
smoothnessD = 0.5;
#ifdef GLOWING_ARMOR_TRIM
emission = 1.0;
#endif
#ifdef SITUATIONAL_GLOWING_TRIMS
emission *= skyLightCheck;
#endif
} else if (currentRenderedItemId == 45004) { // Wooden Tools, Bow, Fishing Rod
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
smoothnessG = min(smoothnessG, 0.4);
smoothnessD = smoothnessG;
}
} else {
if (currentRenderedItemId == 45008) { // Stone Tools
if (CheckForStick(color.rgb)) {
#include "/lib/materials/specificMaterials/planks/sprucePlanks.glsl"
} else {
#include "/lib/materials/specificMaterials/terrain/stone.glsl"
}
} else /*if (currentRenderedItemId == 45012)*/ { // 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"
}
}
}
} else {
if (currentRenderedItemId < 45024) {
if (currentRenderedItemId == 45016) { // 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"
}
} else /*if (currentRenderedItemId == 45020)*/ { // 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"
}
}
} else {
if (currentRenderedItemId == 45024) { // 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
} else /*if (currentRenderedItemId == 45028)*/ { // Trident Item
#include "/lib/materials/specificMaterials/others/trident.glsl"
}
}
}
} else {
if (currentRenderedItemId < 45048) {
if (currentRenderedItemId < 45040) {
if (currentRenderedItemId == 45032) { // 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 /*if (currentRenderedItemId == 45036)*/ { // 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 == 45040) { // 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 /*if (currentRenderedItemId == 45044)*/ { // Bottle o' Enchanting, Glow Inc Sac
emission = color.b * 2.0;
}
}
} else {
if (currentRenderedItemId < 45056) {
if (currentRenderedItemId == 45048) { // 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 /*if (currentRenderedItemId == 45052)*/ { // Chorus Fruit
emission = max0(color.b * 2.0 - color.r) * 1.5;
}
} else {
if (currentRenderedItemId == 45056) { // Amethyst Shard
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(color.r);
smoothnessG = 0.8 - factor * 0.3;
highlightMult = factor * 3.0;
smoothnessD = factor;
} else /*if (currentRenderedItemId == 45060)*/ { // 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 == 45064) { // Turtle Shell
float factor = color.g * 0.7;
smoothnessG = factor;
highlightMult = factor * 3.0;
smoothnessD = factor;
} else /*if (currentRenderedItemId == 45068)*/ { // Ender Pearl
smoothnessG = 1.0;
highlightMult = 2.0;
smoothnessD = 1.0;
}
} else {
if (currentRenderedItemId == 45072) { // 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 /*if (currentRenderedItemId == 45076)*/ { // 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 == 45080) { // Compass
if (color.r - 0.1 > color.b + color.g) {
emission = color.r * 1.5;
}
#include "/lib/materials/specificMaterials/terrain/ironBlock.glsl"
} else /*if (currentRenderedItemId == 45084)*/ { // 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 == 45088) { // Nether Star
emission = pow2(color.r + color.g) * 0.5;
} else /*if (currentRenderedItemId == 45092)*/ { // 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 == 45096) { // Glow Berries
// iris needs to add support
} else /*if (currentRenderedItemId == 45100)*/ { // Glowstone Dust
emission = dot(color.rgb, color.rgb) * 0.5 + 1.0;
}
} else {
if (currentRenderedItemId == 45104) { // Prismarine Crystals
emission = pow1_5(color.r) * 2.5 + 0.2;
} else /*if (currentRenderedItemId == 45108)*/ { // Totem of Undying
#include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
}
}
} else {
if (currentRenderedItemId < 45120) {
if (currentRenderedItemId == 45112) { // 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 /*if (currentRenderedItemId == 45116)*/ { // Copper Tools, Copper Armor, Copper Ingot, Copper Horse Armor
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
smoothnessD *= 0.5;
}
} 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)*/ { //
}
}
}
}
}
@@ -1,9 +1,9 @@
#if !(defined DH_TERRAIN || defined DH_WATER)
#define BLOCK_LAVA_DEFINE mat == 10068 || mat == 10070
#define BLOCK_LAVA_STILL_DEFINE mat == 10068
#define BLOCK_LEAVES_SEASONS_DEFINE mat == 10009 || mat == 10011
#else
#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
#endif
#if !(defined DH_TERRAIN || defined DH_WATER)
#define BLOCK_LAVA_DEFINE mat == 10068 || mat == 10070
#define BLOCK_LAVA_STILL_DEFINE mat == 10068
#define BLOCK_LEAVES_SEASONS_DEFINE mat == 10009 || mat == 10011
#else
#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
#endif
@@ -1,190 +1,190 @@
#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;
#ifndef MIRROR_TINTED_GLASS
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
#else
color.a = color.a * 0.3 + 0.7;
fresnelM = fresnelM * 0.5 + 0.5;
reflectMult /= color.a;
noGeneratedNormals = true;
#ifdef MIRROR_TINTED_GLASS_OPAQUE
color.a = 1.0;
#endif
#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 == 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 == 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)*/ { //
}
}
}
}
#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;
#ifndef MIRROR_TINTED_GLASS
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
#else
color.a = color.a * 0.3 + 0.7;
fresnelM = fresnelM * 0.5 + 0.5;
reflectMult /= color.a;
noGeneratedNormals = true;
#ifdef MIRROR_TINTED_GLASS_OPAQUE
color.a = 1.0;
#endif
#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 == 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 == 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)*/ { //
}
}
}
}
@@ -1,74 +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;
}
/*
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;
}
@@ -1,33 +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;
}
#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;
}
@@ -1,115 +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
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
@@ -1,35 +1,35 @@
#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, float emission) {
vec4 specularMapCheck = texture2DLod(specular, texCoord, 1000.0);
if (specularMapCheck.a == 0.0) return emission;
color = texture2D(tex, texCoord);
vec4 specularMap = texture2D(specular, texCoord);
float customEmission = GetCustomEmission(specularMap, texCoord);
return customEmission;
}
#endif
#endif //INCLUDE_CUSTOM_EMISSION
#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, float emission) {
vec4 specularMapCheck = texture2DLod(specular, texCoord, 1000.0);
if (specularMapCheck.a == 0.0) return emission;
color = texture2D(tex, texCoord);
vec4 specularMap = texture2D(specular, texCoord);
float customEmission = GetCustomEmission(specularMap, texCoord);
return customEmission;
}
#endif
#endif //INCLUDE_CUSTOM_EMISSION
@@ -1,96 +1,96 @@
#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 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;
const float packSizeGN = 128.0;
#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
const float normalMult = GENERATED_NORMAL_MULT * 0.025;
#else
const 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);
float normalMult = max0(1.0 - mipDelta) * normalMult;
#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 /= NORMAL_RES;
vec2 midCoord = texCoord - midCoordPos;
vec2 maxOffsetCoord = midCoord + absMidCoordPos;
vec2 minOffsetCoord = midCoord - absMidCoordPos;
if (normalMult > 0.0) {
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 *= normalMult;
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));
}
}
#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 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;
const float packSizeGN = 128.0;
#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
const float normalMult = GENERATED_NORMAL_MULT * 0.025;
#else
const 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);
float normalMult = max0(1.0 - mipDelta) * normalMult;
#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 /= NORMAL_RES;
vec2 midCoord = texCoord - midCoordPos;
vec2 maxOffsetCoord = midCoord + absMidCoordPos;
vec2 minOffsetCoord = midCoord - absMidCoordPos;
if (normalMult > 0.0) {
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 *= normalMult;
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));
}
}
@@ -1,104 +1,104 @@
bool intersectsAABB(vec3 ro, vec3 rd, vec3 aabbMin, vec3 aabbMax) {
vec3 t0 = (aabbMin - ro) / rd;
vec3 t1 = (aabbMax - ro) / rd;
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);
t = dot(v0 - ro, n) / dot(n, rd);
if (t < 0.0 || t > tMin) return false;
vec3 b = v2 - v1;
vec3 c = ro + rd * t - v0;
uv = vec2(dot(c, a) / dot(a, a), dot(c, b) / dot(b, b));
if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return false;
normal = normalize(n);
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;
vec2 uv;
vec3 colorP;
vec3 color;
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, ivec2(64 * quadTexCoord), 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.bounds.headMin, playerVerticesSSBO.bounds.headMax)) {
for (int i = 0; i < 12; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Right Hand
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.rightHandMin, playerVerticesSSBO.bounds.rightHandMax)) {
for (int i = 12; i < 24; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Left Leg
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.leftLegMin, playerVerticesSSBO.bounds.leftLegMax)) {
for (int i = 24; i < 36; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Left Hand
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.leftHandMin, playerVerticesSSBO.bounds.leftHandMax)) {
for (int i = 36; i < 48; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Right leg
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.rightLegMin, playerVerticesSSBO.bounds.rightLegMax)) {
for (int i = 48; i < 60; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Torso
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.torsoMin, playerVerticesSSBO.bounds.torsoMax)) {
for (int i = 60; i < 72; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
return tMin < wsrTraceLength;
}
bool intersectsAABB(vec3 ro, vec3 rd, vec3 aabbMin, vec3 aabbMax) {
vec3 t0 = (aabbMin - ro) / rd;
vec3 t1 = (aabbMax - ro) / rd;
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);
t = dot(v0 - ro, n) / dot(n, rd);
if (t < 0.0 || t > tMin) return false;
vec3 b = v2 - v1;
vec3 c = ro + rd * t - v0;
uv = vec2(dot(c, a) / dot(a, a), dot(c, b) / dot(b, b));
if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return false;
normal = normalize(n);
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;
vec2 uv;
vec3 colorP;
vec3 color;
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, ivec2(64 * quadTexCoord), 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.bounds.headMin, playerVerticesSSBO.bounds.headMax)) {
for (int i = 0; i < 12; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Right Hand
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.rightHandMin, playerVerticesSSBO.bounds.rightHandMax)) {
for (int i = 12; i < 24; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Left Leg
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.leftLegMin, playerVerticesSSBO.bounds.leftLegMax)) {
for (int i = 24; i < 36; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Left Hand
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.leftHandMin, playerVerticesSSBO.bounds.leftHandMax)) {
for (int i = 36; i < 48; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Right leg
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.rightLegMin, playerVerticesSSBO.bounds.rightLegMax)) {
for (int i = 48; i < 60; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
// Torso
if (intersectsAABB(aabbPos, rayDir, playerVerticesSSBO.bounds.torsoMin, playerVerticesSSBO.bounds.torsoMax)) {
for (int i = 60; i < 72; i++) {
CheckQuadAt(i, playerPos, rayDir, albedo, tMin, normal, emission);
}
}
return tMin < wsrTraceLength;
}
@@ -1,121 +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);
}
}
#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);
}
}
@@ -1,107 +1,107 @@
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
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2
vec3 skyReflection = GetSky(RVdotU, RVdotS, dither, isEyeInWater == 0, true);
#else
vec3 skyReflection = GetLowQualitySky(RVdotU, RVdotS, dither, isEyeInWater == 0, true);
#endif
#ifdef ATM_COLOR_MULTS
skyReflection *= atmColorMult;
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
skyReflection *= moonPhaseInfluence;
#endif
#ifdef COMPOSITE
skyReflection *= skyLightFactor;
#else
float specularHighlight = GGX(normalM, nViewPos, lightVec, max(dot(normalM, lightVec), 0.0), smoothness);
skyReflection += specularHighlight * highlightColor * shadowMult * highlightMult * invRainFactor;
#if WATER_REFLECT_QUALITY >= 1
#ifdef SKY_EFFECT_REFLECTION
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
vec2 starCoord = GetStarCoord(nViewPos, 0.5);
#ifdef PIXELATED_WATER_REFLECTIONS
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
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
skyReflection = mix(color * 0.5, skyReflection, skyLightFactor);
#else
skyReflection = mix(color, skyReflection, skyLightFactor * 0.5);
#endif
#endif
#elif defined END
#ifdef COMPOSITE
#ifdef END_BEAMS
vec3 skyReflection = (endSkyColor + 0.4 * DrawEnderBeams(RVdotU, playerPos, nViewPosR)) * skyLightFactor;
#else
vec3 skyReflection = endSkyColor * skyLightFactor;
#endif
#else
vec3 skyReflection = endSkyColor * shadowMult;
#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)
vec4 wsrReflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither);
reflection = mix(wsrReflection, vec4(reflection.rgb, 1.0), reflection.a);
refDist = min(refDist, length(wsrHitPos - playerPos));
#endif
reflection.rgb = mix(skyReflection, reflection.rgb, reflection.a);
}
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
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2
vec3 skyReflection = GetSky(RVdotU, RVdotS, dither, isEyeInWater == 0, true);
#else
vec3 skyReflection = GetLowQualitySky(RVdotU, RVdotS, dither, isEyeInWater == 0, true);
#endif
#ifdef ATM_COLOR_MULTS
skyReflection *= atmColorMult;
#endif
#ifdef MOON_PHASE_INF_ATMOSPHERE
skyReflection *= moonPhaseInfluence;
#endif
#ifdef COMPOSITE
skyReflection *= skyLightFactor;
#else
float specularHighlight = GGX(normalM, nViewPos, lightVec, max(dot(normalM, lightVec), 0.0), smoothness);
skyReflection += specularHighlight * highlightColor * shadowMult * highlightMult * invRainFactor;
#if WATER_REFLECT_QUALITY >= 1
#ifdef SKY_EFFECT_REFLECTION
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
vec2 starCoord = GetStarCoord(nViewPos, 0.5);
#ifdef PIXELATED_WATER_REFLECTIONS
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
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
skyReflection = mix(color * 0.5, skyReflection, skyLightFactor);
#else
skyReflection = mix(color, skyReflection, skyLightFactor * 0.5);
#endif
#endif
#elif defined END
#ifdef COMPOSITE
#ifdef END_BEAMS
vec3 skyReflection = (endSkyColor + 0.4 * DrawEnderBeams(RVdotU, playerPos, nViewPosR)) * skyLightFactor;
#else
vec3 skyReflection = endSkyColor * skyLightFactor;
#endif
#else
vec3 skyReflection = endSkyColor * shadowMult;
#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)
vec4 wsrReflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither);
reflection = mix(wsrReflection, vec4(reflection.rgb, 1.0), reflection.a);
refDist = min(refDist, length(wsrHitPos - playerPos));
#endif
reflection.rgb = mix(skyReflection, reflection.rgb, reflection.a);
}
@@ -1,43 +1,43 @@
vec4 sampleBlurFilteredReflection(vec4 centerCol, float dither, float z0) {
vec4 texture4 = texture2D(colortex4, texCoord);
vec3 texture6 = texelFetch(colortex6, texelCoord, 0).rgb;
float smoothnessD = texture6.r;
//float linearZ0 = GetLinearDepth(z0);
const float spatialFactor = 2.5; // higher = smoother in space
const float spatialFactorM = 2.0 * spatialFactor * spatialFactor;
vec4 sum = vec4(0.0);
float wsum = 0.0;
vec2 texelSize = (3.0 + 6.0 * dither) / view; // 1 pixel range doesn't seem to be enough to smooth things out
texelSize *= 1.0 - 0.75 * pow2(pow2(pow2(smoothnessD)));
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) 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) * far > 2.0) continue;
#endif
// Spatial weight (gaussian)
float spatialDist2 = float(dx*dx + dy*dy);
float w_s = exp(-spatialDist2 / spatialFactorM);
float w = w_s;
sum += sampleCol * w;
wsum += w_s;
}
}
return sum / wsum;
}
vec4 sampleBlurFilteredReflection(vec4 centerCol, float dither, float z0) {
vec4 texture4 = texture2D(colortex4, texCoord);
vec3 texture6 = texelFetch(colortex6, texelCoord, 0).rgb;
float smoothnessD = texture6.r;
//float linearZ0 = GetLinearDepth(z0);
const float spatialFactor = 2.5; // higher = smoother in space
const float spatialFactorM = 2.0 * spatialFactor * spatialFactor;
vec4 sum = vec4(0.0);
float wsum = 0.0;
vec2 texelSize = (3.0 + 6.0 * dither) / view; // 1 pixel range doesn't seem to be enough to smooth things out
texelSize *= 1.0 - 0.75 * pow2(pow2(pow2(smoothnessD)));
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) 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) * far > 2.0) continue;
#endif
// Spatial weight (gaussian)
float spatialDist2 = float(dx*dx + dy*dy);
float w_s = exp(-spatialDist2 / spatialFactorM);
float w = w_s;
sum += sampleCol * w;
wsum += w_s;
}
}
return sum / wsum;
}
@@ -1,290 +1,290 @@
#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/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"
#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(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);
#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;
AddBackgroundReflection(reflection, color, playerPos, normalM, normalMR, viewPos, nViewPos, nViewPosR,
shadowMult, RVdotU, RVdotS, z0, dither, skyLightFactor, smoothness, highlightMult);
return reflection;*/
vec4 reflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither);
refDist = length(playerPos - wsrHitPos);
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)
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2 && !defined DH_WATER
// Method 1: Ray Marched Reflection //
// 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 = normalize(vector - 0.5 * (1.0 - smoothness) * (1.0 - fresnel) * normalMR); // reflection anisotropy test
//vector = normalize(vector - 0.075 * dither * (1.0 - pow2(pow2(fresnel))) * normalMR);
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;
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;
rfragpos = vec3(refPos.xy, texture2D(depthtex, refPos.xy).r);
rfragpos = nvec3(gbufferProjectionInverse * vec4(rfragpos * 2.0 - 1.0, 1.0));
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);
// Finalizing Terrain Reflection and Alpha
if (
refPos.z < 0.99997
#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
#ifdef GBUFFERS_WATER
reflection = texture2D(gaux2, refPos.xy);
reflection.rgb = pow2(reflection.rgb * 2.0);
#else
float smoothnessDM = pow2(smoothness);
float lodFactor = 1.0 - exp(-0.125 * (1.0 - smoothnessDM) * dist);
float lod = log2(viewHeight / 8.0 * (1.0 - smoothnessDM) * 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;
#ifdef GBUFFERS_WATER
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);
}
#if !defined COMPOSITE && defined DISTANT_HORIZONS
else
#endif
#endif
#if !defined COMPOSITE && (WATER_REFLECT_QUALITY < 2 || defined DISTANT_HORIZONS) || defined DH_WATER
{ // Method 2: Mirorred Image Reflection //
#if WATER_REFLECT_QUALITY < 2 && !defined DISTANT_HORIZONS
float verticalStretch = 0.013; // for potato quality reflections
#else
float verticalStretch = 0.0025; // for distant horizons reflections
#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.004);
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.9997 && 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 ============================== //
#if (defined COMPOSITE || (WATER_REFLECT_QUALITY >= 2 && defined SKY_EFFECT_REFLECTION)) && (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 SKY_EFFECT_REFLECTION)) && 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;
}
#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/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"
#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(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);
#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;
AddBackgroundReflection(reflection, color, playerPos, normalM, normalMR, viewPos, nViewPos, nViewPosR,
shadowMult, RVdotU, RVdotS, z0, dither, skyLightFactor, smoothness, highlightMult);
return reflection;*/
vec4 reflection = getWSR(playerPos, normalMR, nViewPosR, RVdotU, RVdotS, z0, dither);
refDist = length(playerPos - wsrHitPos);
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)
#if defined COMPOSITE || WATER_REFLECT_QUALITY >= 2 && !defined DH_WATER
// Method 1: Ray Marched Reflection //
// 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 = normalize(vector - 0.5 * (1.0 - smoothness) * (1.0 - fresnel) * normalMR); // reflection anisotropy test
//vector = normalize(vector - 0.075 * dither * (1.0 - pow2(pow2(fresnel))) * normalMR);
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;
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;
rfragpos = vec3(refPos.xy, texture2D(depthtex, refPos.xy).r);
rfragpos = nvec3(gbufferProjectionInverse * vec4(rfragpos * 2.0 - 1.0, 1.0));
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);
// Finalizing Terrain Reflection and Alpha
if (
refPos.z < 0.99997
#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
#ifdef GBUFFERS_WATER
reflection = texture2D(gaux2, refPos.xy);
reflection.rgb = pow2(reflection.rgb * 2.0);
#else
float smoothnessDM = pow2(smoothness);
float lodFactor = 1.0 - exp(-0.125 * (1.0 - smoothnessDM) * dist);
float lod = log2(viewHeight / 8.0 * (1.0 - smoothnessDM) * 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;
#ifdef GBUFFERS_WATER
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);
}
#if !defined COMPOSITE && defined DISTANT_HORIZONS
else
#endif
#endif
#if !defined COMPOSITE && (WATER_REFLECT_QUALITY < 2 || defined DISTANT_HORIZONS) || defined DH_WATER
{ // Method 2: Mirorred Image Reflection //
#if WATER_REFLECT_QUALITY < 2 && !defined DISTANT_HORIZONS
float verticalStretch = 0.013; // for potato quality reflections
#else
float verticalStretch = 0.0025; // for distant horizons reflections
#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.004);
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.9997 && 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 ============================== //
#if (defined COMPOSITE || (WATER_REFLECT_QUALITY >= 2 && defined SKY_EFFECT_REFLECTION)) && (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 SKY_EFFECT_REFLECTION)) && 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;
}
@@ -1,43 +1,43 @@
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;
}
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;
}
@@ -1,19 +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;
}
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;
}
@@ -1,149 +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);
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;
}
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);
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;
}
@@ -1,243 +1,243 @@
#include "/lib/shaderSettings/wavingBlocks.glsl"
#if COLORED_LIGHTING_INTERNAL > 0
#include "/lib/voxelization/lightVoxelization.glsl"
#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
playerPos.y += wave * 0.125 - 0.05;
#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
playerPos.y += wave * 0.0125;
}
}
void DoWave(inout vec3 playerPos, int mat) {
vec3 worldPos = playerPos.xyz + cameraPosition.xyz;
#if defined GBUFFERS_TERRAIN || defined SHADOW
#ifdef WAVING_FOLIAGE
if (mat == 10003 || mat == 10005 || mat == 10029 || mat == 10025 // Grounded Foliage
#ifdef DO_MORE_FOLIAGE_WAVING
|| mat == 10769 // Torchflower
|| mat == 10976 // Open Eye Blossom
#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 == 10021 || mat == 10023 || mat == 10027) { // 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 == 10007 || mat == 10009 || mat == 10011) { // Leaves
DoWave_Leaves(playerPos.xyz, worldPos, 1.0);
} else if (mat == 10013 || mat == 10923) { // 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 == 10884 || mat == 10885) { // Weeping Vines, 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 == 10489) { // 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
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);
}
#include "/lib/shaderSettings/wavingBlocks.glsl"
#if COLORED_LIGHTING_INTERNAL > 0
#include "/lib/voxelization/lightVoxelization.glsl"
#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
playerPos.y += wave * 0.125 - 0.05;
#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
playerPos.y += wave * 0.0125;
}
}
void DoWave(inout vec3 playerPos, int mat) {
vec3 worldPos = playerPos.xyz + cameraPosition.xyz;
#if defined GBUFFERS_TERRAIN || defined SHADOW
#ifdef WAVING_FOLIAGE
if (mat == 10003 || mat == 10005 || mat == 10029 || mat == 10025 // Grounded Foliage
#ifdef DO_MORE_FOLIAGE_WAVING
|| mat == 10769 // Torchflower
|| mat == 10976 // Open Eye Blossom
#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 == 10021 || mat == 10023 || mat == 10027) { // 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 == 10007 || mat == 10009 || mat == 10011) { // Leaves
DoWave_Leaves(playerPos.xyz, worldPos, 1.0);
} else if (mat == 10013 || mat == 10923) { // 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 == 10884 || mat == 10885) { // Weeping Vines, 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 == 10489) { // 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
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);
}
@@ -1,390 +1,390 @@
#extension GL_ARB_shader_image_load_store : enable
#include "/lib/voxelization/reflectionVoxelization.glsl"
#include "/lib/lighting/minimumLighting.glsl"
#include "/lib/shaderSettings/mainLighting.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(vec3 playerPos, ivec3 normal, vec2 localTexCoord) {
ivec3 voxelPos = ivec3(playerToSceneVoxel(playerPos + normal * 0.5));
ivec3 absNormal = ivec3(abs(normal));
ivec3 right = ivec3(0, 0, 1) * absNormal.x + ivec3(1, 0, 0) * absNormal.y + ivec3(1, 0, 0) * absNormal.z;
ivec3 up = ivec3(0, 1, 0) * absNormal.x + ivec3(0, 0, 1) * absNormal.y + ivec3(0, 1, 0) * absNormal.z;
vec2 centerFactorPos = sqrt1(2.0 * clamp01(0.5 - localTexCoord));
vec2 centerFactorNeg = sqrt1(2.0 * clamp01(localTexCoord - 0.5));
ivec3 voxel0 = voxelPos + right;
ivec3 voxel1 = voxelPos - right;
ivec3 voxel2 = voxelPos + up;
ivec3 voxel3 = voxelPos - up;
float occlusion0 = mix(0.0, float(checkVoxelAt(voxel0)), centerFactorPos.x);
float occlusion1 = mix(0.0, float(checkVoxelAt(voxel1)), centerFactorNeg.x);
float occlusion2 = mix(0.0, float(checkVoxelAt(voxel2)), centerFactorPos.y);
float occlusion3 = mix(0.0, float(checkVoxelAt(voxel3)), centerFactorNeg.y);
return 1.0 - (occlusion0 + occlusion1 + occlusion2 + occlusion3) * 0.25;
}
vec4 getShadedReflection(ivec3 voxelPos, vec3 oldPlayerPos, vec3 playerPos, vec3 rayDir, vec3 normal, 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
int mat = int(texelFetch(wsr_sampler, voxelPos, 0).r);
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));
#if SHADOW_QUALITY == 0
int shadowSamples = 0; // We don't use SampleTAAFilteredShadow on Shadow Quality 0
#elif SHADOW_QUALITY == 1
int shadowSamples = 1;
#else
int shadowSamples = 2;
#endif
shadow = GetShadow(GetShadowPos(playerPos + bias), faceData.lightmap.y, offset, shadowSamples, false);
}
}
shadow *= dot(shadow, vec3(0.33333));
#else
vec3 shadow = vec3(1.0);
#endif
#ifdef CLOUD_SHADOWS
shadow *= GetCloudShadow(playerPos);
#endif
faceData.lightmap = pow2(pow2(faceData.lightmap));
float AO = max(0.8, getVoxelSpaceAO(playerPos, 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));
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));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
float alphaFade = min(fadeout.x, min(fadeout.y, fadeout.z));
return vec4(color.rgb * lighting + maRecolor, alphaFade);
}
vec3 wsrHitPos = vec3(-100000);
vec4 traceHighLOD(vec3 rayDir, vec3 stepDir, vec3 stepSizes, vec3 oldPlayerPos, vec3 newPlayerPos, vec3 voxelPos, float RVdotU, float RVdotS, float dither) {
vec3 nextDist = (stepDir * 0.5 + 0.5 - fract(voxelPos)) / rayDir;
float closestDist = 0.0;
const float maxSteps = 14;
for (int i = 0; i < maxSteps; i++) {
closestDist = min(nextDist.x, min(nextDist.y, nextDist.z));
vec3 stepAxis = vec3(lessThanEqual(nextDist, vec3(closestDist)));
voxelPos += stepAxis * stepDir;
nextDist += stepAxis * stepSizes;
if (!CheckInsideSceneVoxelVolume(voxelPos)) return vec4(0.0);
if (checkVoxelAt(ivec3(voxelPos))) {
vec3 normal = -stepAxis * stepDir;
vec3 intersection = newPlayerPos + rayDir * closestDist;
vec4 reflection = getShadedReflection(ivec3(voxelPos), oldPlayerPos, intersection, rayDir, normal, dither);
if (reflection.a < -0.5) continue;
wsrHitPos = intersection;
vec3 fadeout = smoothstep(0.0, 32.0, 0.5 * sceneVoxelVolumeSize - abs(oldPlayerPos));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
reflection *= min(fadeout.x, min(fadeout.y, fadeout.z));
float skyFade = 0.0;
float reflectionPrevAlpha = reflection.a;
DoFog(reflection, skyFade, length(intersection), intersection, RVdotU, RVdotS, dither, true, length(oldPlayerPos));
reflection.a = reflectionPrevAlpha * (1.0 - skyFade);
return reflection;
}
}
return vec4(-1.0);
}
vec4 traceLowLOD(vec3 rayDir ,vec3 stepDir, vec3 stepSizes, vec3 playerPos, vec3 voxelPos, vec3 normalOffset, float RVdotU, float RVdotS, float dither) {
float lodScale = 4.0;
vec3 lodVoxelPos = voxelPos / lodScale;
vec3 nextDist = (stepDir * 0.5 + 0.5 - fract(lodVoxelPos)) / rayDir;
float closestDistPrevious = 0.0;
float closestDist = 0.0;
float maxSteps = length(vec3(sceneVoxelVolumeSize)) / lodScale;
for (int i = 0; i < maxSteps; i++) {
if (any(greaterThan(lodVoxelPos, vec3(sceneVoxelVolumeSize) / lodScale)) || any(lessThan(lodVoxelPos, vec3(0.0))))
return vec4(0.0);
if (checkLodVoxelAt(ivec3(lodVoxelPos))) {
vec3 newPlayerPos = playerPos + rayDir * closestDistPrevious * lodScale;
// Fixes surfaces reflecting themselves at a distance with lower resolutions, but it can cause some rare artifacts
if (i <= 2) newPlayerPos += normalOffset * 0.06;
vec3 newVoxelPos = playerToSceneVoxel(newPlayerPos);
vec4 try = traceHighLOD(rayDir, stepDir, stepSizes, playerPos, newPlayerPos, newVoxelPos, RVdotU, RVdotS, dither);
if (try.a > -0.5) return try;
}
closestDistPrevious = closestDist;
closestDist = min(nextDist.x, min(nextDist.y, nextDist.z));
vec3 stepAxis = vec3(lessThanEqual(nextDist, vec3(closestDist)));
lodVoxelPos += stepAxis * stepDir;
nextDist += stepAxis * stepSizes;
}
return vec4(0.0);
}
vec4 getWSR(vec3 playerPos, vec3 normalMR, vec3 nViewPosR, float RVdotU, float RVdotS, float z0, float dither) {
vec3 normalOffset = normalize(mat3(gbufferModelViewInverse) * normalMR);
vec3 voxelPos = playerToSceneVoxel(playerPos);
// Fixes slabs, stairs, dirt paths, and farmlands reflecting themselves
if (z0 == z1 && z0 > 0.56) {
vec3 playerPosFractAdded = playerPos + cameraPositionBestFract + 256.0;
vec3 normalOffsetM = normalOffset * (0.04 - 0.01 * dither);
ivec3 voxelPosCheck1 = ivec3(playerPosFractAdded - normalOffsetM);
ivec3 voxelPosCheck2 = ivec3(playerPosFractAdded + normalOffsetM);
if (voxelPosCheck1 == voxelPosCheck2) playerPos += normalOffset * 0.5;
}
vec3 rayDir = mat3(gbufferModelViewInverse) * nViewPosR;
if (CheckInsideSceneVoxelVolume(voxelPos)) {
vec3 stepDir = sign(rayDir);
vec3 stepSizes = 1.0 / abs(rayDir);
vec4 wsrResult = traceLowLOD(rayDir, stepDir, stepSizes, playerPos, voxelPos, normalOffset, RVdotU, RVdotS, dither);
#if WORLD_SPACE_PLAYER_REF == 1
if (!is_invisible && z0 > 0.56) {
float wsrTraceLength = length(wsrHitPos - playerPos);
vec3 albedo;
vec3 normal;
float emission;
#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;
vec3 heldLighting = GetHeldLighting(playerPos, vec3(999999.0), tempEmission, vec3(0), vec3(0), vec3(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));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
float alphaFade = min(fadeout.x, min(fadeout.y, fadeout.z));
return vec4(albedo * lighting, alphaFade);
}
}
#endif
return wsrResult;
}
return vec4(0.0);
}
#extension GL_ARB_shader_image_load_store : enable
#include "/lib/voxelization/reflectionVoxelization.glsl"
#include "/lib/lighting/minimumLighting.glsl"
#include "/lib/shaderSettings/mainLighting.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(vec3 playerPos, ivec3 normal, vec2 localTexCoord) {
ivec3 voxelPos = ivec3(playerToSceneVoxel(playerPos + normal * 0.5));
ivec3 absNormal = ivec3(abs(normal));
ivec3 right = ivec3(0, 0, 1) * absNormal.x + ivec3(1, 0, 0) * absNormal.y + ivec3(1, 0, 0) * absNormal.z;
ivec3 up = ivec3(0, 1, 0) * absNormal.x + ivec3(0, 0, 1) * absNormal.y + ivec3(0, 1, 0) * absNormal.z;
vec2 centerFactorPos = sqrt1(2.0 * clamp01(0.5 - localTexCoord));
vec2 centerFactorNeg = sqrt1(2.0 * clamp01(localTexCoord - 0.5));
ivec3 voxel0 = voxelPos + right;
ivec3 voxel1 = voxelPos - right;
ivec3 voxel2 = voxelPos + up;
ivec3 voxel3 = voxelPos - up;
float occlusion0 = mix(0.0, float(checkVoxelAt(voxel0)), centerFactorPos.x);
float occlusion1 = mix(0.0, float(checkVoxelAt(voxel1)), centerFactorNeg.x);
float occlusion2 = mix(0.0, float(checkVoxelAt(voxel2)), centerFactorPos.y);
float occlusion3 = mix(0.0, float(checkVoxelAt(voxel3)), centerFactorNeg.y);
return 1.0 - (occlusion0 + occlusion1 + occlusion2 + occlusion3) * 0.25;
}
vec4 getShadedReflection(ivec3 voxelPos, vec3 oldPlayerPos, vec3 playerPos, vec3 rayDir, vec3 normal, 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
int mat = int(texelFetch(wsr_sampler, voxelPos, 0).r);
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));
#if SHADOW_QUALITY == 0
int shadowSamples = 0; // We don't use SampleTAAFilteredShadow on Shadow Quality 0
#elif SHADOW_QUALITY == 1
int shadowSamples = 1;
#else
int shadowSamples = 2;
#endif
shadow = GetShadow(GetShadowPos(playerPos + bias), faceData.lightmap.y, offset, shadowSamples, false);
}
}
shadow *= dot(shadow, vec3(0.33333));
#else
vec3 shadow = vec3(1.0);
#endif
#ifdef CLOUD_SHADOWS
shadow *= GetCloudShadow(playerPos);
#endif
faceData.lightmap = pow2(pow2(faceData.lightmap));
float AO = max(0.8, getVoxelSpaceAO(playerPos, 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));
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));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
float alphaFade = min(fadeout.x, min(fadeout.y, fadeout.z));
return vec4(color.rgb * lighting + maRecolor, alphaFade);
}
vec3 wsrHitPos = vec3(-100000);
vec4 traceHighLOD(vec3 rayDir, vec3 stepDir, vec3 stepSizes, vec3 oldPlayerPos, vec3 newPlayerPos, vec3 voxelPos, float RVdotU, float RVdotS, float dither) {
vec3 nextDist = (stepDir * 0.5 + 0.5 - fract(voxelPos)) / rayDir;
float closestDist = 0.0;
const float maxSteps = 14;
for (int i = 0; i < maxSteps; i++) {
closestDist = min(nextDist.x, min(nextDist.y, nextDist.z));
vec3 stepAxis = vec3(lessThanEqual(nextDist, vec3(closestDist)));
voxelPos += stepAxis * stepDir;
nextDist += stepAxis * stepSizes;
if (!CheckInsideSceneVoxelVolume(voxelPos)) return vec4(0.0);
if (checkVoxelAt(ivec3(voxelPos))) {
vec3 normal = -stepAxis * stepDir;
vec3 intersection = newPlayerPos + rayDir * closestDist;
vec4 reflection = getShadedReflection(ivec3(voxelPos), oldPlayerPos, intersection, rayDir, normal, dither);
if (reflection.a < -0.5) continue;
wsrHitPos = intersection;
vec3 fadeout = smoothstep(0.0, 32.0, 0.5 * sceneVoxelVolumeSize - abs(oldPlayerPos));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
reflection *= min(fadeout.x, min(fadeout.y, fadeout.z));
float skyFade = 0.0;
float reflectionPrevAlpha = reflection.a;
DoFog(reflection, skyFade, length(intersection), intersection, RVdotU, RVdotS, dither, true, length(oldPlayerPos));
reflection.a = reflectionPrevAlpha * (1.0 - skyFade);
return reflection;
}
}
return vec4(-1.0);
}
vec4 traceLowLOD(vec3 rayDir ,vec3 stepDir, vec3 stepSizes, vec3 playerPos, vec3 voxelPos, vec3 normalOffset, float RVdotU, float RVdotS, float dither) {
float lodScale = 4.0;
vec3 lodVoxelPos = voxelPos / lodScale;
vec3 nextDist = (stepDir * 0.5 + 0.5 - fract(lodVoxelPos)) / rayDir;
float closestDistPrevious = 0.0;
float closestDist = 0.0;
float maxSteps = length(vec3(sceneVoxelVolumeSize)) / lodScale;
for (int i = 0; i < maxSteps; i++) {
if (any(greaterThan(lodVoxelPos, vec3(sceneVoxelVolumeSize) / lodScale)) || any(lessThan(lodVoxelPos, vec3(0.0))))
return vec4(0.0);
if (checkLodVoxelAt(ivec3(lodVoxelPos))) {
vec3 newPlayerPos = playerPos + rayDir * closestDistPrevious * lodScale;
// Fixes surfaces reflecting themselves at a distance with lower resolutions, but it can cause some rare artifacts
if (i <= 2) newPlayerPos += normalOffset * 0.06;
vec3 newVoxelPos = playerToSceneVoxel(newPlayerPos);
vec4 try = traceHighLOD(rayDir, stepDir, stepSizes, playerPos, newPlayerPos, newVoxelPos, RVdotU, RVdotS, dither);
if (try.a > -0.5) return try;
}
closestDistPrevious = closestDist;
closestDist = min(nextDist.x, min(nextDist.y, nextDist.z));
vec3 stepAxis = vec3(lessThanEqual(nextDist, vec3(closestDist)));
lodVoxelPos += stepAxis * stepDir;
nextDist += stepAxis * stepSizes;
}
return vec4(0.0);
}
vec4 getWSR(vec3 playerPos, vec3 normalMR, vec3 nViewPosR, float RVdotU, float RVdotS, float z0, float dither) {
vec3 normalOffset = normalize(mat3(gbufferModelViewInverse) * normalMR);
vec3 voxelPos = playerToSceneVoxel(playerPos);
// Fixes slabs, stairs, dirt paths, and farmlands reflecting themselves
if (z0 == z1 && z0 > 0.56) {
vec3 playerPosFractAdded = playerPos + cameraPositionBestFract + 256.0;
vec3 normalOffsetM = normalOffset * (0.04 - 0.01 * dither);
ivec3 voxelPosCheck1 = ivec3(playerPosFractAdded - normalOffsetM);
ivec3 voxelPosCheck2 = ivec3(playerPosFractAdded + normalOffsetM);
if (voxelPosCheck1 == voxelPosCheck2) playerPos += normalOffset * 0.5;
}
vec3 rayDir = mat3(gbufferModelViewInverse) * nViewPosR;
if (CheckInsideSceneVoxelVolume(voxelPos)) {
vec3 stepDir = sign(rayDir);
vec3 stepSizes = 1.0 / abs(rayDir);
vec4 wsrResult = traceLowLOD(rayDir, stepDir, stepSizes, playerPos, voxelPos, normalOffset, RVdotU, RVdotS, dither);
#if WORLD_SPACE_PLAYER_REF == 1
if (!is_invisible && z0 > 0.56) {
float wsrTraceLength = length(wsrHitPos - playerPos);
vec3 albedo;
vec3 normal;
float emission;
#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;
vec3 heldLighting = GetHeldLighting(playerPos, vec3(999999.0), tempEmission, vec3(0), vec3(0), vec3(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));
fadeout = sqrt3(fadeout) * 0.9 + 0.1;
float alphaFade = min(fadeout.x, min(fadeout.y, fadeout.z));
return vec4(albedo * lighting, alphaFade);
}
}
#endif
return wsrResult;
}
return vec4(0.0);
}
@@ -1,36 +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;
}
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;
}
@@ -1,172 +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
#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
@@ -1,40 +1,40 @@
#if SEASONS == 1
#if SEASON_LENGTH >= 24000
int seasonLength = SEASON_LENGTH;
#else
int seasonLength = SEASON_LENGTH * 24000;
#endif
float YearLoop = (worldDay * 24000 + worldTime + SEASON_START * seasonLength) % (seasonLength * 4);
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 spring = max(0.0, (1.0 + SEASON_TRANSITION_START) * (clamp(YearLoop - seasonLength * 3, 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
#if SEASONS == 1
#if SEASON_LENGTH >= 24000
int seasonLength = SEASON_LENGTH;
#else
int seasonLength = SEASON_LENGTH * 24000;
#endif
float YearLoop = (worldDay * 24000 + worldTime + SEASON_START * seasonLength) % (seasonLength * 4);
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 spring = max(0.0, (1.0 + SEASON_TRANSITION_START) * (clamp(YearLoop - seasonLength * 3, 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 +1 @@
#include "/lib/materials/specificMaterials/entities/itemFrame.glsl"
#include "/lib/materials/specificMaterials/entities/itemFrame.glsl"
@@ -1 +1 @@
noSmoothLighting = true;
noSmoothLighting = true;
@@ -1,36 +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
// 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
@@ -1,140 +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
#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
@@ -1,9 +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;
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
@@ -1,15 +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;
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;
@@ -1,4 +1,4 @@
smoothnessG = color.g;
smoothnessD = color.g;
emission = min(max0(dot(color.rgb, color.rgb) - 1.0) * 6.0, 1.0);
smoothnessG = color.g;
smoothnessD = color.g;
emission = min(max0(dot(color.rgb, color.rgb) - 1.0) * 6.0, 1.0);
@@ -1,6 +1,6 @@
smoothnessG = pow2(pow2(color.r)) * 0.45;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
smoothnessG = pow2(pow2(color.r)) * 0.45;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1,2 +1,2 @@
smoothnessG = color.r * 0.3;
smoothnessD = color.r * 0.25;
smoothnessG = color.r * 0.3;
smoothnessD = color.r * 0.25;
@@ -1,6 +1,6 @@
smoothnessG = pow2(pow2(color.g)) * 0.55;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = pow2(pow2(color.g)) * 0.55;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(pow2(color.g)) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = pow2(pow2(color.g)) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(color.r) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
smoothnessG = pow2(color.r) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
@@ -1,6 +1,6 @@
smoothnessG = dot(color.rgb, vec3(0.2));
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = dot(color.rgb, vec3(0.2));
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,7 +1,7 @@
smoothnessG = pow2(pow2(pow2(color.g))) * 12.0;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = pow2(pow2(pow2(color.g))) * 12.0;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,3 +1,3 @@
smoothnessG = pow2(color.r) * 0.5;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
smoothnessG = pow2(color.r) * 0.5;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
@@ -1,6 +1,6 @@
smoothnessG = pow2(dot(color.rgb, color.rgb)) * 0.105;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
smoothnessG = pow2(dot(color.rgb, color.rgb)) * 0.105;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(color.g) * 0.22;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = pow2(color.g) * 0.22;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(dot(color.rgb, vec3(0.3)));
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = pow2(dot(color.rgb, vec3(0.3)));
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(color.g) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
smoothnessG = pow2(color.g) * 0.5;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
@@ -1,5 +1,5 @@
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(color.r);
smoothnessG = 0.8 - factor * 0.3;
highlightMult = factor * 3.0;
smoothnessD = factor;
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(color.r);
smoothnessG = 0.8 - factor * 0.3;
highlightMult = factor * 3.0;
smoothnessD = factor;
@@ -1,6 +1,6 @@
smoothnessG = color.r;
smoothnessD = color.r;
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
smoothnessG = color.r;
smoothnessD = color.r;
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
@@ -1,17 +1,17 @@
float epsilon = 0.00001;
vec2 absMidCoordPosM = absMidCoordPos - epsilon;
vec3 avgBorderColor = vec3(0.0);
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(epsilon, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(epsilon,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x, epsilon)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x, epsilon)).rgb;
avgBorderColor *= 0.125;
vec3 colorDif = abs(avgBorderColor - color.rgb);
emission = max(colorDif.r, max(colorDif.g, colorDif.b));
emission = pow2(emission * 2.5 - 0.15);
float epsilon = 0.00001;
vec2 absMidCoordPosM = absMidCoordPos - epsilon;
vec3 avgBorderColor = vec3(0.0);
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(epsilon, absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(epsilon,-absMidCoordPosM.y)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2( absMidCoordPosM.x, epsilon)).rgb;
avgBorderColor += texture2D(tex, midCoord + vec2(-absMidCoordPosM.x, epsilon)).rgb;
avgBorderColor *= 0.125;
vec3 colorDif = abs(avgBorderColor - color.rgb);
emission = max(colorDif.r, max(colorDif.g, colorDif.b));
emission = pow2(emission * 2.5 - 0.15);
@@ -1,2 +1,2 @@
smoothnessG = color.r;
smoothnessD = color.r * 0.65;
smoothnessG = color.r;
smoothnessD = color.r * 0.65;
@@ -1,8 +1,8 @@
noSmoothLighting = true;
color.rgb *= 1.0 + 0.7 * pow2(max(-signMidCoordPos.y + 0.6, float(NdotU > 0.9) * 1.6));
#ifdef SNOWY_WORLD
snowFactor = 0.0;
#endif
overlayNoiseIntensity = 0.3;
noSmoothLighting = true;
color.rgb *= 1.0 + 0.7 * pow2(max(-signMidCoordPos.y + 0.6, float(NdotU > 0.9) * 1.6));
#ifdef SNOWY_WORLD
snowFactor = 0.0;
#endif
overlayNoiseIntensity = 0.3;
@@ -1,3 +1,3 @@
smoothnessG = dot(color.rgb, color.rgb) * 0.17;
smoothnessD = smoothnessG;
smoothnessG = max(smoothnessG, 0.3 * color.g * float(color.g > color.b * 1.5));
smoothnessG = dot(color.rgb, color.rgb) * 0.17;
smoothnessD = smoothnessG;
smoothnessG = max(smoothnessG, 0.3 * color.g * float(color.g > color.b * 1.5));
@@ -1,10 +1,10 @@
materialMask = OSIEBCA * 2.0; // Copper Fresnel
smoothnessG = pow2(pow2(color.r)) + pow2(max0(color.g - color.r * 0.5)) * 0.3;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
color.rgb *= min1(0.6 + 0.7 * GetLuminance(color.rgb));
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
materialMask = OSIEBCA * 2.0; // Copper Fresnel
smoothnessG = pow2(pow2(color.r)) + pow2(max0(color.g - color.r * 0.5)) * 0.3;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
color.rgb *= min1(0.6 + 0.7 * GetLuminance(color.rgb));
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1,20 +1,20 @@
noSmoothLighting = true, overlayNoiseIntensity = 0.5;
vec3 hsvColor = rgb2hsv(color.rgb);
if (abs(hsvColor.r - 0.09722) < 0.04305 && hsvColor.b > 0.7) { // Active Light Part
smoothnessG = 0.75;
smoothnessD = 0.35;
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = (floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0;
float dotsignMidCoordPos = dot(signMidCoordPosM, signMidCoordPosM);
float lBlockPosM = pow2(max0(1.0 - 1.7 * pow2(pow2(dotsignMidCoordPos))));
emission = pow2(lmCoordM.x) + 0.3 * color.r;
emission *= (0.7 + 2.0 * pow2(lBlockPosM));
} else if (color.r > 2.5 * (color.g + color.b)) { // Middle Redstone Part
emission = 4.0;
color.rgb *= color.rgb;
} else { // Copper Base
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
}
noSmoothLighting = true, overlayNoiseIntensity = 0.5;
vec3 hsvColor = rgb2hsv(color.rgb);
if (abs(hsvColor.r - 0.09722) < 0.04305 && hsvColor.b > 0.7) { // Active Light Part
smoothnessG = 0.75;
smoothnessD = 0.35;
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = (floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0;
float dotsignMidCoordPos = dot(signMidCoordPosM, signMidCoordPosM);
float lBlockPosM = pow2(max0(1.0 - 1.7 * pow2(pow2(dotsignMidCoordPos))));
emission = pow2(lmCoordM.x) + 0.3 * color.r;
emission *= (0.7 + 2.0 * pow2(lBlockPosM));
} else if (color.r > 2.5 * (color.g + color.b)) { // Middle Redstone Part
emission = 4.0;
color.rgb *= color.rgb;
} else { // Copper Base
#include "/lib/materials/specificMaterials/terrain/copperBlock.glsl"
}
@@ -1,7 +1,7 @@
float lColor = length(color.rgb);
smoothnessG = lColor * 0.2;
smoothnessD = lColor * 0.15;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
float lColor = length(color.rgb);
smoothnessG = lColor * 0.2;
smoothnessD = lColor * 0.15;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,19 +1,19 @@
#include "/lib/materials/specificMaterials/terrain/obsidian.glsl"
highlightMult *= 0.5;
float factor0 = sqrt2(max0(color.b - color.g * 6.0));
float factor1 = pow2(color.b);
emission = 1.35 + pow2(pow2(factor1)) * 7.5;
emission *= factor0;
color.r *= 1.15;
maRecolor = vec3(factor0 * min(max0(factor1 * 0.7 - 0.1) * 1.3, 0.5));
#if defined NETHER && defined BIOME_COLORED_NETHER_PORTALS
float luminance = GetLuminance(color.rgb);
color.rgb = mix(color.rgb, vec3(luminance), 0.88);
color.rgb = normalize(netherColor) * luminance * 2.0;
#endif
overlayNoiseIntensity = 0.65;
overlayNoiseEmission = 0.6;
#include "/lib/materials/specificMaterials/terrain/obsidian.glsl"
highlightMult *= 0.5;
float factor0 = sqrt2(max0(color.b - color.g * 6.0));
float factor1 = pow2(color.b);
emission = 1.35 + pow2(pow2(factor1)) * 7.5;
emission *= factor0;
color.r *= 1.15;
maRecolor = vec3(factor0 * min(max0(factor1 * 0.7 - 0.1) * 1.3, 0.5));
#if defined NETHER && defined BIOME_COLORED_NETHER_PORTALS
float luminance = GetLuminance(color.rgb);
color.rgb = mix(color.rgb, vec3(luminance), 0.88);
color.rgb = normalize(netherColor) * luminance * 2.0;
#endif
overlayNoiseIntensity = 0.65;
overlayNoiseEmission = 0.6;
@@ -1,5 +1,5 @@
smoothnessG = pow(color.g, 1.5) * 0.55;
smoothnessG = smoothnessG;
smoothnessD = smoothnessG;
materialMask = OSIEBCA; // Intense Fresnel
smoothnessG = pow(color.g, 1.5) * 0.55;
smoothnessG = smoothnessG;
smoothnessD = smoothnessG;
materialMask = OSIEBCA; // Intense Fresnel
@@ -1,25 +1,25 @@
materialMask = OSIEBCA; // Intense Fresnel
float factor = max(color.g, 0.8);
float factor2 = pow2(factor);
#ifdef GBUFFERS_TERRAIN
float factor4 = pow2(factor2);
#else
float factor4 = factor2;
#endif
smoothnessG = factor - pow2(pow2(color.g)) * 0.4;
highlightMult = 3.0 * max(pow2(factor4), 0.2);
smoothnessD = factor4 * 0.75;
#if MC_VERSION < 11300
highlightMult *= 2.0;
smoothnessD /= 0.75;
#endif
color.rgb *= 0.7 + 0.4 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = max(color.g, 0.8);
float factor2 = pow2(factor);
#ifdef GBUFFERS_TERRAIN
float factor4 = pow2(factor2);
#else
float factor4 = factor2;
#endif
smoothnessG = factor - pow2(pow2(color.g)) * 0.4;
highlightMult = 3.0 * max(pow2(factor4), 0.2);
smoothnessD = factor4 * 0.75;
#if MC_VERSION < 11300
highlightMult *= 2.0;
smoothnessD /= 0.75;
#endif
color.rgb *= 0.7 + 0.4 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1 +1 @@
smoothnessG = color.r * 0.1 + 0.1;
smoothnessG = color.r * 0.1 + 0.1;
@@ -1,14 +1,14 @@
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(sqrt2(GetLuminance(color.rgb)));
float factor2 = pow2(factor);
float factor4 = pow2(factor2);
smoothnessG = factor - factor4 * 0.4;
highlightMult = 3.0 * factor4;
smoothnessD = factor4 * 0.75;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = pow2(sqrt2(GetLuminance(color.rgb)));
float factor2 = pow2(factor);
float factor4 = pow2(factor2);
smoothnessG = factor - factor4 * 0.4;
highlightMult = 3.0 * factor4;
smoothnessD = factor4 * 0.75;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1,3 +1,3 @@
// End Portal Frame:Green Parts
smoothnessG = 0.25;
smoothnessD = 0.45;
// End Portal Frame:Green Parts
smoothnessG = 0.25;
smoothnessD = 0.45;
@@ -1,34 +1,34 @@
//#define OBSIDIAN_ENDSTONE
#ifdef OBSIDIAN_ENDSTONE
#ifdef GBUFFERS_TERRAIN
vec3 worldPos = cameraPosition + playerPos;
color.rgb *= mix(vec3(0.1686, 0.1216, 0.302), vec3(0.0, 0.0, 0.0), float(hash33(floor(mod(worldPos, vec3(100.0)) * 16 + 0.01) * 16)) * 0.5);
if (color.r < 0.18) color.rgb *= vec3(0.3843, 0.3294, 0.5176);
if (color.r < 0.05) color.rgb *= 0.2;
#else
color.rgb *= vec3(0.0941, 0.0314, 0.149);
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = max0(0.3 - abs(color.r - 0.3)) * 1.5;
smoothnessG = factor;
highlightMult = 2.0 + min1(smoothnessG * 2.0) * 1.5;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(factor + 0.07);
#ifdef COATED_TEXTURES
noiseFactor = 1.25;
#endif
#else
float factor = pow2(pow2(color.r));
smoothnessG = factor * 0.65;
smoothnessD = smoothnessG * 0.6;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
#endif
//#define OBSIDIAN_ENDSTONE
#ifdef OBSIDIAN_ENDSTONE
#ifdef GBUFFERS_TERRAIN
vec3 worldPos = cameraPosition + playerPos;
color.rgb *= mix(vec3(0.1686, 0.1216, 0.302), vec3(0.0, 0.0, 0.0), float(hash33(floor(mod(worldPos, vec3(100.0)) * 16 + 0.01) * 16)) * 0.5);
if (color.r < 0.18) color.rgb *= vec3(0.3843, 0.3294, 0.5176);
if (color.r < 0.05) color.rgb *= 0.2;
#else
color.rgb *= vec3(0.0941, 0.0314, 0.149);
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = max0(0.3 - abs(color.r - 0.3)) * 1.5;
smoothnessG = factor;
highlightMult = 2.0 + min1(smoothnessG * 2.0) * 1.5;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(factor + 0.07);
#ifdef COATED_TEXTURES
noiseFactor = 1.25;
#endif
#else
float factor = pow2(pow2(color.r));
smoothnessG = factor * 0.65;
smoothnessD = smoothnessG * 0.6;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
#endif
@@ -1,23 +1,23 @@
noSmoothLighting = true; noDirectionalShading = true;
lmCoordM = vec2(1.0, 0.0);
#ifndef IPBR_COMPAT_MODE
#ifndef DURING_WORLDSPACE_REF
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = abs((floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0);
#else
vec2 signMidCoordPosM = signMidCoordPos;
#endif
float value = 1.0 - max(signMidCoordPosM.x, signMidCoordPosM.y);
#else
float value = 0.3;
#endif
color.rgb = pow(color.rgb, vec3(FROGLIGHT_SATURATION));
emission = 0.3 + value + pow(dot(color.rgb, color.rgb) * 0.33, frogPow);
emission *= 1.7;
#ifdef DISTANT_LIGHT_BOKEH
DoDistantLightBokehMaterial(emission, 2.0, lViewPos);
#endif
color.rgb = pow2(color.rgb);
noSmoothLighting = true; noDirectionalShading = true;
lmCoordM = vec2(1.0, 0.0);
#ifndef IPBR_COMPAT_MODE
#ifndef DURING_WORLDSPACE_REF
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = abs((floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0);
#else
vec2 signMidCoordPosM = signMidCoordPos;
#endif
float value = 1.0 - max(signMidCoordPosM.x, signMidCoordPosM.y);
#else
float value = 0.3;
#endif
color.rgb = pow(color.rgb, vec3(FROGLIGHT_SATURATION));
emission = 0.3 + value + pow(dot(color.rgb, color.rgb) * 0.33, frogPow);
emission *= 1.7;
#ifdef DISTANT_LIGHT_BOKEH
DoDistantLightBokehMaterial(emission, 2.0, lViewPos);
#endif
color.rgb = pow2(color.rgb);
@@ -1,20 +1,20 @@
materialMask = OSIEBCA * 3.0; // Gold Fresnel
#ifdef GBUFFERS_TERRAIN
float colorG2 = pow2(color.g);
#else
float colorG2 = color.g;
#endif
float colorG4 = pow2(colorG2);
float factor = max(color.g, 0.8);
smoothnessG = min1(factor - colorG4 * 0.5);
highlightMult = 3.5 * max(colorG4, 0.2);
smoothnessD = colorG4;
color.rgb *= 0.5 + 0.4 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
materialMask = OSIEBCA * 3.0; // Gold Fresnel
#ifdef GBUFFERS_TERRAIN
float colorG2 = pow2(color.g);
#else
float colorG2 = color.g;
#endif
float colorG4 = pow2(colorG2);
float factor = max(color.g, 0.8);
smoothnessG = min1(factor - colorG4 * 0.5);
highlightMult = 3.5 * max(colorG4, 0.2);
smoothnessD = colorG4;
color.rgb *= 0.5 + 0.4 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
@@ -1,14 +1,14 @@
#ifdef GBUFFERS_TERRAIN
smoothnessG = pow2(pow2(color.r));
#else
smoothnessG = pow2(color.r);
#endif
highlightMult = smoothnessG * 3.0;
smoothnessD = smoothnessG;
materialMask = OSIEBCA; // Intense Fresnel
color.rgb *= 0.6 + 0.5 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
#ifdef GBUFFERS_TERRAIN
smoothnessG = pow2(pow2(color.r));
#else
smoothnessG = pow2(color.r);
#endif
highlightMult = smoothnessG * 3.0;
smoothnessD = smoothnessG;
materialMask = OSIEBCA; // Intense Fresnel
color.rgb *= 0.6 + 0.5 * GetLuminance(color.rgb);
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
@@ -1,6 +1,6 @@
smoothnessG = color.b;
smoothnessD = color.b;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
smoothnessG = color.b;
smoothnessD = color.b;
#ifdef COATED_TEXTURES
noiseFactor = 0.66;
#endif
@@ -1,6 +1,6 @@
smoothnessG = pow2(color.b) * 0.8;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
smoothnessG = pow2(color.b) * 0.8;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1,62 +1,62 @@
#if !defined IPBR_COMPAT_MODE && defined GBUFFERS_TERRAIN && !defined GBUFFERS_COLORWHEEL
// Tweak to prevent the animation of lava causing brightness pulsing
vec3 avgColor = vec3(0.0);
ivec2 itexCoordC = ivec2(midCoord * atlasSize + 0.0001);
for (int x = -8; x < 8; x += 2) {
for (int y = -8; y < 8; y += 2) {
avgColor += texelFetch(tex, itexCoordC + ivec2(x, y), 0).rgb;
}
}
color.rgb /= max(GetLuminance(avgColor) * 0.0390625, 0.001);
#else
color.rgb *= 0.86;
#endif
noDirectionalShading = true;
lmCoordM = vec2(0.0);
emission = GetLuminance(color.rgb) * 7.48 + 0.5;
vec3 worldPos = playerPos + cameraPosition;
vec2 lavaPos = (floor(worldPos.xz * 16.0) + worldPos.y * 32.0) * 0.000666;
vec2 wind = vec2(frameTimeCounter * 0.012, 0.0);
#ifdef NETHER
float noiseSample = texture2DLod(noisetex, lavaPos + wind, 0.0).g;
noiseSample = noiseSample - 0.5;
noiseSample *= 0.1;
color.rgb = pow(color.rgb, vec3(1.0 + noiseSample));
#endif
vec3 previousLavaColor = color.rgb;
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
color.rgb = changeColorFunction(color.rgb, 3.0, colorSoul, inSoulValley);
color.rgb = mix(color.rgb, (color.rgb - 0.5) * 1.35 + 0.5, inSoulValley); // increase contrast
#endif
#ifdef PURPLE_END_FIRE_INTERNAL
color.rgb = changeColorFunction(color.rgb, 2.5, colorEndBreath * 1.4, 1.0);
color.rgb = (color.rgb - 0.5) * 1.3 + 0.5;
#endif
vec3 lavaNoiseColor = color.rgb;
#if LAVA_VARIATION > 0
if (BLOCK_LAVA_DEFINE) { // Lava
#include "/lib/materials/specificMaterials/terrain/lavaNoise.glsl"
color.rgb = lavaNoiseColor;
}
#else
maRecolor = vec3(clamp(pow2(pow2(pow2(smoothstep1(emission * 0.28)))), 0.12, 0.4) * 1.3) * vec3(0.25, vec2(0.175));
if (LAVA_TEMPERATURE != 0.0) maRecolor += LAVA_TEMPERATURE * 0.5 - 0.2;
lavaNoiseColor *= 1.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;
#if !defined IPBR_COMPAT_MODE && defined GBUFFERS_TERRAIN && !defined GBUFFERS_COLORWHEEL
// Tweak to prevent the animation of lava causing brightness pulsing
vec3 avgColor = vec3(0.0);
ivec2 itexCoordC = ivec2(midCoord * atlasSize + 0.0001);
for (int x = -8; x < 8; x += 2) {
for (int y = -8; y < 8; y += 2) {
avgColor += texelFetch(tex, itexCoordC + ivec2(x, y), 0).rgb;
}
}
color.rgb /= max(GetLuminance(avgColor) * 0.0390625, 0.001);
#else
color.rgb *= 0.86;
#endif
noDirectionalShading = true;
lmCoordM = vec2(0.0);
emission = GetLuminance(color.rgb) * 7.48 + 0.5;
vec3 worldPos = playerPos + cameraPosition;
vec2 lavaPos = (floor(worldPos.xz * 16.0) + worldPos.y * 32.0) * 0.000666;
vec2 wind = vec2(frameTimeCounter * 0.012, 0.0);
#ifdef NETHER
float noiseSample = texture2DLod(noisetex, lavaPos + wind, 0.0).g;
noiseSample = noiseSample - 0.5;
noiseSample *= 0.1;
color.rgb = pow(color.rgb, vec3(1.0 + noiseSample));
#endif
vec3 previousLavaColor = color.rgb;
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
color.rgb = changeColorFunction(color.rgb, 3.0, colorSoul, inSoulValley);
color.rgb = mix(color.rgb, (color.rgb - 0.5) * 1.35 + 0.5, inSoulValley); // increase contrast
#endif
#ifdef PURPLE_END_FIRE_INTERNAL
color.rgb = changeColorFunction(color.rgb, 2.5, colorEndBreath * 1.4, 1.0);
color.rgb = (color.rgb - 0.5) * 1.3 + 0.5;
#endif
vec3 lavaNoiseColor = color.rgb;
#if LAVA_VARIATION > 0
if (BLOCK_LAVA_DEFINE) { // Lava
#include "/lib/materials/specificMaterials/terrain/lavaNoise.glsl"
color.rgb = lavaNoiseColor;
}
#else
maRecolor = vec3(clamp(pow2(pow2(pow2(smoothstep1(emission * 0.28)))), 0.12, 0.4) * 1.3) * vec3(0.25, vec2(0.175));
if (LAVA_TEMPERATURE != 0.0) maRecolor += LAVA_TEMPERATURE * 0.5 - 0.2;
lavaNoiseColor *= 1.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;
@@ -1,62 +1,62 @@
#if LAVA_EDGE_EFFECT > 0 && defined GBUFFERS_TERRAIN && !defined WORLD_CURVATURE
if (mat == 10068){
vec3 voxelPos = SceneToVoxel(playerPos);
if (CheckInsideVoxelVolume(voxelPos)) {
mat2 isSurroundingLava = mat2(0,0,0,0); // Thanks to gri for the help!
ivec3 coordsLava = ivec3(floor(vec3(voxelPos)));
ivec3 coords = ivec3(floor(vec3(voxelPos.x - 0.5, voxelPos.y - 0.3, voxelPos.z - 0.5))); // shift coords to the center of the block
uint lavaVoxel = texelFetch(voxel_sampler, ivec3(coordsLava + ivec3(0, 1, 0)), 0).r; // coords for block above
if (lavaVoxel != uint(13)){ // check if the above block is not lava, to only have the edge effect on the top most lava layer
for (int i = 0; i < 2; i++){ // check if the surrounding blocks are lava or not, 1 at the center of a non-lava block, 0 at the center of a lava block
for ( int j = 0; j < 2; j++){
uint voxel = texelFetch(voxel_sampler, ivec3(coords + ivec3(i, 0, j)), 0).r;
isSurroundingLava[i][j] = voxel != uint(13) ? 1 : 0;
}
}
}
float edge = mix(
mix(isSurroundingLava[0][0],
isSurroundingLava[0][1],
fract(voxelPos.z + 0.5)),
mix(isSurroundingLava[1][0],
isSurroundingLava[1][1],
fract(voxelPos.z + 0.5)),
fract(voxelPos.x + 0.5)
);
float easeAmount = 1.5;
vec3 edgeColor = maxLavaColor;
#if LAVA_EDGE_EFFECT == 2
easeAmount = 1.3;
edgeColor = minLavaColor;
#endif
edge = 1.0 - cos((edge * pi) / easeAmount); // ease in towards the centre of the block to create a better shape
edge *= clamp01(blockUV.y - 0.3) * 10/7; // Gradient towards the bottom, so 0.3 is now 0
edgeColor = mix(vec3(0.4, 0.2, 0.1), edgeColor, 0.9); // make the color vary depending on the lava noise
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
edgeColor = changeColorFunction(edgeColor, 3.0, colorSoul, inSoulValley);
#elif defined PURPLE_END_FIRE_INTERNAL
edgeColor = changeColorFunction(sqrt1(edgeColor), 4.0, colorEndBreath, 1.0);
#endif
edgeColor *= 3.0;
float edgeEmission = 1.3 + emission * 1.1;
#if LAVA_EDGE_EFFECT == 2
edgeColor *= 0.1;
edgeEmission = 0.5;
#endif
vec3 absPlayerPos = abs(playerPos);
float maxPlayerPos = max(absPlayerPos.x, max(absPlayerPos.y * 2.0, absPlayerPos.z));
float edgeDecider = pow2(min1(maxPlayerPos / min(effectiveACTdistance, far) * 2.0)); // this is to make the effect fade at the edge of ACT range
color.rgb = mix(color.rgb, edgeColor, edge * (1.0 - edgeDecider));
emission = mix(emission, min(edgeEmission, 3.5), edge * (1.0 - edgeDecider));
}
}
#endif
#if LAVA_EDGE_EFFECT > 0 && defined GBUFFERS_TERRAIN && !defined WORLD_CURVATURE
if (mat == 10068){
vec3 voxelPos = SceneToVoxel(playerPos);
if (CheckInsideVoxelVolume(voxelPos)) {
mat2 isSurroundingLava = mat2(0,0,0,0); // Thanks to gri for the help!
ivec3 coordsLava = ivec3(floor(vec3(voxelPos)));
ivec3 coords = ivec3(floor(vec3(voxelPos.x - 0.5, voxelPos.y - 0.3, voxelPos.z - 0.5))); // shift coords to the center of the block
uint lavaVoxel = texelFetch(voxel_sampler, ivec3(coordsLava + ivec3(0, 1, 0)), 0).r; // coords for block above
if (lavaVoxel != uint(13)){ // check if the above block is not lava, to only have the edge effect on the top most lava layer
for (int i = 0; i < 2; i++){ // check if the surrounding blocks are lava or not, 1 at the center of a non-lava block, 0 at the center of a lava block
for ( int j = 0; j < 2; j++){
uint voxel = texelFetch(voxel_sampler, ivec3(coords + ivec3(i, 0, j)), 0).r;
isSurroundingLava[i][j] = voxel != uint(13) ? 1 : 0;
}
}
}
float edge = mix(
mix(isSurroundingLava[0][0],
isSurroundingLava[0][1],
fract(voxelPos.z + 0.5)),
mix(isSurroundingLava[1][0],
isSurroundingLava[1][1],
fract(voxelPos.z + 0.5)),
fract(voxelPos.x + 0.5)
);
float easeAmount = 1.5;
vec3 edgeColor = maxLavaColor;
#if LAVA_EDGE_EFFECT == 2
easeAmount = 1.3;
edgeColor = minLavaColor;
#endif
edge = 1.0 - cos((edge * pi) / easeAmount); // ease in towards the centre of the block to create a better shape
edge *= clamp01(blockUV.y - 0.3) * 10/7; // Gradient towards the bottom, so 0.3 is now 0
edgeColor = mix(vec3(0.4, 0.2, 0.1), edgeColor, 0.9); // make the color vary depending on the lava noise
#ifdef SOUL_SAND_VALLEY_OVERHAUL_INTERNAL
edgeColor = changeColorFunction(edgeColor, 3.0, colorSoul, inSoulValley);
#elif defined PURPLE_END_FIRE_INTERNAL
edgeColor = changeColorFunction(sqrt1(edgeColor), 4.0, colorEndBreath, 1.0);
#endif
edgeColor *= 3.0;
float edgeEmission = 1.3 + emission * 1.1;
#if LAVA_EDGE_EFFECT == 2
edgeColor *= 0.1;
edgeEmission = 0.5;
#endif
vec3 absPlayerPos = abs(playerPos);
float maxPlayerPos = max(absPlayerPos.x, max(absPlayerPos.y * 2.0, absPlayerPos.z));
float edgeDecider = pow2(min1(maxPlayerPos / min(effectiveACTdistance, far) * 2.0)); // this is to make the effect fade at the edge of ACT range
color.rgb = mix(color.rgb, edgeColor, edge * (1.0 - edgeDecider));
emission = mix(emission, min(edgeEmission, 3.5), edge * (1.0 - edgeDecider));
}
}
#endif
@@ -1,86 +1,86 @@
#if defined GBUFFERS_TERRAIN || defined DH_TERRAIN
float noise = -1.0 * LAVA_NOISE_AMOUNT;
float lavaNoiseEmission = emission;
float dhLavaSides = 0.0;
#ifdef DH_TERRAIN
dhLavaSides = 1.0 - clamp01(dot(worldGeoNormal, ViewToPlayer(upVec)));
#endif
if (mat == 10070
#ifdef DH_TERRAIN
|| dhLavaSides > 0.5 // vertical lava columns
#endif
) { // Flowing Lava
lavaPos += wind.x * 0.75;
}
#if LAVA_VARIATION == 1 // Adaptive Noise
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 + 0.1;
#ifdef NETHER
#ifdef DH_TERRAIN
if ((worldPos.y > 30 && worldPos.y < 32.3 || (worldPos.y > 35 && worldPos.y < 37.3) && dhLavaSides < 0.5) && BLOCK_LAVA_STILL_DEFINE) { // lava lakes in the nether
#else
if ((worldPos.y > 30 && worldPos.y < 32.3 || (worldPos.y > 35 && worldPos.y < 37.3)) && BLOCK_LAVA_STILL_DEFINE) {
#endif
noise += texture2DLod(noisetex, lavaPos * 0.3 + wind * 0.1, 0.0).r;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.9 + wind * 0.04, 0.0).r * 0.5;
noise *= texture2DLod(noisetex, lavaPos * 0.1 + wind * 0.02, 0.0).r * 0.5;
lavaNoiseEmission *= 1.6;
lavaNoiseColor *= smoothstep(0.00, 0.40, noise);
lavaNoiseColor.r *= 1.2;
} else {
noise += texture2DLod(noisetex, lavaPos * 2.5 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.0, 0.90, noise);
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
}
#else
if (worldPos.y > -56 && worldPos.y < -53.7 && BLOCK_LAVA_STILL_DEFINE) { // lava lakes in the Overworld, End not affected because no negative coords
noise += texture2DLod(noisetex, lavaPos * 0.2 + wind * 0.1, 0.0).r;
noise += texture2DLod(noisetex, lavaPos * 0.8 + wind * 0.04, 0.0).r * 0.5;
noise *= texture2DLod(noisetex, lavaPos * 0.1 + wind * 0.02, 0.0).r * 0.5;
lavaNoiseEmission *= 1.6;
lavaNoiseColor *= smoothstep(0.00, 0.45, noise);
lavaNoiseColor.r *= 1.2;
} else {
noise += texture2DLod(noisetex, lavaPos * 2.5 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.0, 0.90, noise);
lavaNoiseIntensity *= 0.5;
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
}
#endif
#elif LAVA_VARIATION == 2 // Blushing Hotness
noise += texture2DLod(noisetex, lavaPos * 0.05 + wind * 0.1, 0.0).r;
lavaNoiseColor -= vec3(0.03) * noise * 8.0;
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 - 0.05;
#elif LAVA_VARIATION == 3 // Molten Cheese
lavaNoiseColor += vec3(min(pow2(pow2(pow2(smoothstep1(lavaNoiseEmission * 0.5)))), 0.25)) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 0.01 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 2.0 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.00, 0.70, noise);
#elif LAVA_VARIATION == 4 // Dark Islands
lavaNoiseColor += vec3(min(pow2(pow2(pow2(smoothstep1(lavaNoiseEmission * 0.5)))), 0.25)) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 0.01 + wind * 0.01, 0.0).r;
noise -= texture2DLod(noisetex, lavaPos * 1.1 + wind * 0.05, 0.0).r * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.1, 0.0).r * 0.7;
lavaNoiseColor *= smoothstep(0.00, 0.70, noise);
#elif LAVA_VARIATION == 5 // Chaotic Flow
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 1.0 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.5, 0.70, noise);
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
#endif
lavaNoiseColor = max(vec3(0.01), lavaNoiseColor); // prevent going too dark
lavaNoiseColor = mix(color.rgb, lavaNoiseColor, lavaNoiseIntensity);
emission = mix(emission, lavaNoiseEmission, lavaNoiseIntensity);
#endif
#if defined GBUFFERS_TERRAIN || defined DH_TERRAIN
float noise = -1.0 * LAVA_NOISE_AMOUNT;
float lavaNoiseEmission = emission;
float dhLavaSides = 0.0;
#ifdef DH_TERRAIN
dhLavaSides = 1.0 - clamp01(dot(worldGeoNormal, ViewToPlayer(upVec)));
#endif
if (mat == 10070
#ifdef DH_TERRAIN
|| dhLavaSides > 0.5 // vertical lava columns
#endif
) { // Flowing Lava
lavaPos += wind.x * 0.75;
}
#if LAVA_VARIATION == 1 // Adaptive Noise
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 + 0.1;
#ifdef NETHER
#ifdef DH_TERRAIN
if ((worldPos.y > 30 && worldPos.y < 32.3 || (worldPos.y > 35 && worldPos.y < 37.3) && dhLavaSides < 0.5) && BLOCK_LAVA_STILL_DEFINE) { // lava lakes in the nether
#else
if ((worldPos.y > 30 && worldPos.y < 32.3 || (worldPos.y > 35 && worldPos.y < 37.3)) && BLOCK_LAVA_STILL_DEFINE) {
#endif
noise += texture2DLod(noisetex, lavaPos * 0.3 + wind * 0.1, 0.0).r;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.9 + wind * 0.04, 0.0).r * 0.5;
noise *= texture2DLod(noisetex, lavaPos * 0.1 + wind * 0.02, 0.0).r * 0.5;
lavaNoiseEmission *= 1.6;
lavaNoiseColor *= smoothstep(0.00, 0.40, noise);
lavaNoiseColor.r *= 1.2;
} else {
noise += texture2DLod(noisetex, lavaPos * 2.5 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.0, 0.90, noise);
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
}
#else
if (worldPos.y > -56 && worldPos.y < -53.7 && BLOCK_LAVA_STILL_DEFINE) { // lava lakes in the Overworld, End not affected because no negative coords
noise += texture2DLod(noisetex, lavaPos * 0.2 + wind * 0.1, 0.0).r;
noise += texture2DLod(noisetex, lavaPos * 0.8 + wind * 0.04, 0.0).r * 0.5;
noise *= texture2DLod(noisetex, lavaPos * 0.1 + wind * 0.02, 0.0).r * 0.5;
lavaNoiseEmission *= 1.6;
lavaNoiseColor *= smoothstep(0.00, 0.45, noise);
lavaNoiseColor.r *= 1.2;
} else {
noise += texture2DLod(noisetex, lavaPos * 2.5 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.0, 0.90, noise);
lavaNoiseIntensity *= 0.5;
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
}
#endif
#elif LAVA_VARIATION == 2 // Blushing Hotness
noise += texture2DLod(noisetex, lavaPos * 0.05 + wind * 0.1, 0.0).r;
lavaNoiseColor -= vec3(0.03) * noise * 8.0;
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 - 0.05;
#elif LAVA_VARIATION == 3 // Molten Cheese
lavaNoiseColor += vec3(min(pow2(pow2(pow2(smoothstep1(lavaNoiseEmission * 0.5)))), 0.25)) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 0.01 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 2.0 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.00, 0.70, noise);
#elif LAVA_VARIATION == 4 // Dark Islands
lavaNoiseColor += vec3(min(pow2(pow2(pow2(smoothstep1(lavaNoiseEmission * 0.5)))), 0.25)) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 0.01 + wind * 0.01, 0.0).r;
noise -= texture2DLod(noisetex, lavaPos * 1.1 + wind * 0.05, 0.0).r * 0.3;
noise += texture2DLod(noisetex, lavaPos * 0.1, 0.0).r * 0.7;
lavaNoiseColor *= smoothstep(0.00, 0.70, noise);
#elif LAVA_VARIATION == 5 // Chaotic Flow
lavaNoiseColor += min(pow2(pow2(lavaNoiseEmission * 0.50)), 0.2) * LAVA_TEMPERATURE * 0.65 + 0.1;
noise += texture2DLod(noisetex, lavaPos * 1.0 + wind * 0.01, 0.0).g;
noise -= texture2DLod(noisetex, lavaPos * 10.1 + wind * 0.05, 0.0).g * 0.3;
noise += texture2DLod(noisetex, lavaPos * 2.1, 0.0).g * 0.3;
lavaNoiseColor *= smoothstep(0.5, 0.70, noise);
lavaNoiseColor.r *= 1.25;
lavaNoiseEmission *= 1.1;
#endif
lavaNoiseColor = max(vec3(0.01), lavaNoiseColor); // prevent going too dark
lavaNoiseColor = mix(color.rgb, lavaNoiseColor, lavaNoiseIntensity);
emission = mix(emission, lavaNoiseEmission, lavaNoiseIntensity);
#endif
@@ -1,31 +1,31 @@
subsurfaceMode = 2, isFoliage = true;
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
#ifdef GBUFFERS_TERRAIN
materialMask = OSIEBCA * 253.0; // Reduced Edge TAA
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
#ifdef IPBR
float factor = min1(pow2(color.g - 0.15 * (color.r + color.b)) * 2.5);
smoothnessG = factor * 0.4;
highlightMult = factor * 4.0 + 2.0;
#ifdef GBUFFERS_TERRAIN
float fresnel = clamp(1.0 + dot(normalM, normalize(viewPos)), 0.0, 1.0);
highlightMult *= 1.0 - pow2(pow2(fresnel));
#else
highlightMult *= 0.5;
#endif
#endif
#ifdef SNOWY_WORLD
snowMinNdotU = min(pow2(pow2(color.g)), 0.1);
color.rgb = color.rgb * 0.5 + 0.5 * (color.rgb / glColor.rgb);
#endif
#if SHADOW_QUALITY > -1 && SHADOW_QUALITY < 3 && defined OVERWORLD
shadowMult = vec3(sqrt1(max0(max(lmCoordM.y, min1(lmCoordM.x * 2.0)) - 0.95) * 20.0));
#endif
subsurfaceMode = 2, isFoliage = true;
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
#ifdef GBUFFERS_TERRAIN
materialMask = OSIEBCA * 253.0; // Reduced Edge TAA
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
#ifdef IPBR
float factor = min1(pow2(color.g - 0.15 * (color.r + color.b)) * 2.5);
smoothnessG = factor * 0.4;
highlightMult = factor * 4.0 + 2.0;
#ifdef GBUFFERS_TERRAIN
float fresnel = clamp(1.0 + dot(normalM, normalize(viewPos)), 0.0, 1.0);
highlightMult *= 1.0 - pow2(pow2(fresnel));
#else
highlightMult *= 0.5;
#endif
#endif
#ifdef SNOWY_WORLD
snowMinNdotU = min(pow2(pow2(color.g)), 0.1);
color.rgb = color.rgb * 0.5 + 0.5 * (color.rgb / glColor.rgb);
#endif
#if SHADOW_QUALITY > -1 && SHADOW_QUALITY < 3 && defined OVERWORLD
shadowMult = vec3(sqrt1(max0(max(lmCoordM.y, min1(lmCoordM.x * 2.0)) - 0.95) * 20.0));
#endif
@@ -1,8 +1,8 @@
smoothnessG = pow2(color.r * 2.0);
smoothnessG = min1(smoothnessG);
highlightMult = smoothnessG * 2.0;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
smoothnessG = pow2(color.r * 2.0);
smoothnessG = min1(smoothnessG);
highlightMult = smoothnessG * 2.0;
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.33;
#endif
@@ -1,7 +1,7 @@
#if MC_VERSION >= 11300
smoothnessG = pow2(color.r) * 1.5;
smoothnessG = min1(smoothnessG);
#else
smoothnessG = color.r * 0.4 + 0.2;
#endif
smoothnessD = smoothnessG;
#if MC_VERSION >= 11300
smoothnessG = pow2(color.r) * 1.5;
smoothnessG = min1(smoothnessG);
#else
smoothnessG = color.r * 0.4 + 0.2;
#endif
smoothnessD = smoothnessG;
@@ -1,3 +1,3 @@
smoothnessG = pow2(pow2(color.g)) * 2.5;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
smoothnessG = pow2(pow2(color.g)) * 2.5;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
@@ -1,13 +1,13 @@
materialMask = OSIEBCA; // Intense Fresnel
float factor = max0(0.3 - abs(color.r - 0.3)) * 1.5;
smoothnessG = factor;
highlightMult = 2.0 + min1(smoothnessG * 2.0) * 1.5;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(factor + 0.07);
#ifdef COATED_TEXTURES
noiseFactor = 1.25;
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = max0(0.3 - abs(color.r - 0.3)) * 1.5;
smoothnessG = factor;
highlightMult = 2.0 + min1(smoothnessG * 2.0) * 1.5;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(factor + 0.07);
#ifdef COATED_TEXTURES
noiseFactor = 1.25;
#endif
@@ -1,15 +1,15 @@
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
#ifdef GBUFFERS_TERRAIN
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
if (color.r > 0.7 && color.r > color.g * 1.2 && color.g > color.b * 2.0) { // Emissive Part
lmCoordM.x = 0.5;
emission = 5.0 * color.g;
color.rgb *= color.rgb;
}
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
#ifdef GBUFFERS_TERRAIN
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
if (color.r > 0.7 && color.r > color.g * 1.2 && color.g > color.b * 2.0) { // Emissive Part
lmCoordM.x = 0.5;
emission = 5.0 * color.g;
color.rgb *= color.rgb;
}
@@ -1,2 +1,2 @@
smoothnessD = pow2(color.g) * 0.7;
smoothnessG = smoothnessD;
smoothnessD = pow2(color.g) * 0.7;
smoothnessG = smoothnessD;
@@ -1 +1 @@
smoothnessG = color.g * 0.25;
smoothnessG = color.g * 0.25;
@@ -1,19 +1,19 @@
materialMask = OSIEBCA; // Intense Fresnel
float factor = color.g;
float factor2 = pow2(factor);
float factor4 = pow2(factor2);
float factor8 = pow2(factor4);
smoothnessG = factor - factor8 * 0.5;
highlightMult = 3.5 * factor8;
smoothnessD = factor8;
#ifdef GBUFFERS_TERRAIN
DoBrightBlockTweaks(color.rgb, 0.5, shadowMult, highlightMult);
#endif
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
materialMask = OSIEBCA; // Intense Fresnel
float factor = color.g;
float factor2 = pow2(factor);
float factor4 = pow2(factor2);
float factor8 = pow2(factor4);
smoothnessG = factor - factor8 * 0.5;
highlightMult = 3.5 * factor8;
smoothnessD = factor8;
#ifdef GBUFFERS_TERRAIN
DoBrightBlockTweaks(color.rgb, 0.5, shadowMult, highlightMult);
#endif
#ifdef COATED_TEXTURES
noiseFactor = 0.5;
#endif
@@ -1,4 +1,4 @@
materialMask = OSIEBCA * 2.0; // Copper Fresnel
smoothnessG = pow2(color.r + color.g * 0.25) * 0.4;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(smoothnessG * smoothnessG * 2.0);
materialMask = OSIEBCA * 2.0; // Copper Fresnel
smoothnessG = pow2(color.r + color.g * 0.25) * 0.4;
smoothnessG = min1(smoothnessG);
smoothnessD = min1(smoothnessG * smoothnessG * 2.0);
@@ -1,3 +1,3 @@
materialMask = OSIEBCA * 3.0; // Gold Fresnel
smoothnessG = pow2(pow2(color.g));
smoothnessD = 0.5 * (smoothnessG + color.b);
materialMask = OSIEBCA * 3.0; // Gold Fresnel
smoothnessG = pow2(pow2(color.g));
smoothnessD = 0.5 * (smoothnessG + color.b);
@@ -1,3 +1,3 @@
materialMask = OSIEBCA; // Intense Fresnel
smoothnessG = pow2(pow2(color.r)) * 0.7;
smoothnessD = smoothnessG * 0.6;
materialMask = OSIEBCA; // Intense Fresnel
smoothnessG = pow2(pow2(color.r)) * 0.7;
smoothnessD = smoothnessG * 0.6;
@@ -1,11 +1,11 @@
materialMask = OSIEBCA * 5.0; // Redstone Fresnel
float factor = pow2(color.r);
smoothnessG = 0.4;
highlightMult = factor + 0.2;
smoothnessD = factor * 0.5 + 0.1;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
materialMask = OSIEBCA * 5.0; // Redstone Fresnel
float factor = pow2(color.r);
smoothnessG = 0.4;
highlightMult = factor + 0.2;
smoothnessD = factor * 0.5 + 0.1;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
@@ -1,16 +1,16 @@
if (color.r > 0.65 && abs(color.g - color.b) < 0.1) {
emission = (3.5 - 2.25 * color.g) * 0.97;
color.rgb *= color.rgb;
#if MC_VERSION >= 12102 // redstone torch model got changed in 1.21.2
color.gb = max(color.gb * vec2(0.75, 0.5), pow2(color.gb));
#endif
} else if (color.r > color.g * 2.0) {
materialMask = OSIEBCA * 5.0; // Redstone Fresnel
float factor = pow2(color.r);
smoothnessG = 0.4;
highlightMult = factor + 0.4;
smoothnessD = factor * 0.7 + 0.3;
}
if (color.r > 0.65 && abs(color.g - color.b) < 0.1) {
emission = (3.5 - 2.25 * color.g) * 0.97;
color.rgb *= color.rgb;
#if MC_VERSION >= 12102 // redstone torch model got changed in 1.21.2
color.gb = max(color.gb * vec2(0.75, 0.5), pow2(color.gb));
#endif
} else if (color.r > color.g * 2.0) {
materialMask = OSIEBCA * 5.0; // Redstone Fresnel
float factor = pow2(color.r);
smoothnessG = 0.4;
highlightMult = factor + 0.4;
smoothnessD = factor * 0.7 + 0.3;
}
@@ -1,17 +1,17 @@
smoothnessG = (1.0 - pow(color.g, 64.0) * 0.3) * 0.4;
highlightMult = 2.0;
smoothnessD = smoothnessG;
#ifdef GBUFFERS_TERRAIN
DoBrightBlockTweaks(color.rgb, 0.5, shadowMult, highlightMult);
#endif
#if RAIN_PUDDLES >= 1
noPuddles = 1.0;
#endif
#ifdef SSS_SNOW_ICE
subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
color.rgb *= mix(vec3(1), vec3(0.76, 0.8, 0.84), sunVisibility);
#endif
smoothnessG = (1.0 - pow(color.g, 64.0) * 0.3) * 0.4;
highlightMult = 2.0;
smoothnessD = smoothnessG;
#ifdef GBUFFERS_TERRAIN
DoBrightBlockTweaks(color.rgb, 0.5, shadowMult, highlightMult);
#endif
#if RAIN_PUDDLES >= 1
noPuddles = 1.0;
#endif
#ifdef SSS_SNOW_ICE
subsurfaceMode = 3, noSmoothLighting = true, noDirectionalShading = true;
color.rgb *= mix(vec3(1), vec3(0.76, 0.8, 0.84), sunVisibility);
#endif
@@ -1,7 +1,7 @@
smoothnessG = pow2(pow2(color.g)) * 2.0;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
smoothnessG = pow2(pow2(color.g)) * 2.0;
smoothnessG = min1(smoothnessG);
smoothnessD = smoothnessG;
#ifdef COATED_TEXTURES
noiseFactor = 0.77;
#endif
@@ -1,19 +1,19 @@
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
#ifdef GBUFFERS_TERRAIN
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
#if defined GBUFFERS_TERRAIN && !defined IPBR_COMPAT_MODE
emission = (1.0 - abs(signMidCoordPos.x)) * max0(0.7 - abs(signMidCoordPos.y + 0.7));
emission = pow1_5(emission) * 2.5;
#else
if (color.r + color.g > color.b + 1.1) emission = 0.8;
else if (color.r > color.g + color.b) emission = 0.2;
#endif
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
subsurfaceMode = 1, noSmoothLighting = true, noDirectionalShading = true;
#ifdef GBUFFERS_TERRAIN
DoFoliageColorTweaks(color.rgb, shadowMult, snowMinNdotU, viewPos, nViewPos, lViewPos, dither);
#ifdef COATED_TEXTURES
doTileRandomisation = false;
#endif
#endif
#if defined GBUFFERS_TERRAIN && !defined IPBR_COMPAT_MODE
emission = (1.0 - abs(signMidCoordPos.x)) * max0(0.7 - abs(signMidCoordPos.y + 0.7));
emission = pow1_5(emission) * 2.5;
#else
if (color.r + color.g > color.b + 1.1) emission = 0.8;
else if (color.r > color.g + color.b) emission = 0.2;
#endif
sandNoiseIntensity = 0.3, mossNoiseIntensity = 0.0;
@@ -1,24 +1,24 @@
if (min(color.a, texture2DLod(tex, texCoord, 0).a) > 0.001) {
smoothnessG = 1.0;
highlightMult = 3.5;
reflectMult = 0.5;
translucentMultCalculated = true;
translucentMult = vec4(0.0, 0.0, 0.0, 1.0);
}
#ifdef FANCY_GLASS
else {
smoothnessG = 0.5;
highlightMult = 2.5;
reflectMult = 1.0;
color.rgb = vec3(0.75, 0.8, 0.85);
translucentMultCalculated = true;
translucentMult.a = 0.0;
color.a = max(color.a, GLASS_OPACITY);
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
}
#endif
if (min(color.a, texture2DLod(tex, texCoord, 0).a) > 0.001) {
smoothnessG = 1.0;
highlightMult = 3.5;
reflectMult = 0.5;
translucentMultCalculated = true;
translucentMult = vec4(0.0, 0.0, 0.0, 1.0);
}
#ifdef FANCY_GLASS
else {
smoothnessG = 0.5;
highlightMult = 2.5;
reflectMult = 1.0;
color.rgb = vec3(0.75, 0.8, 0.85);
translucentMultCalculated = true;
translucentMult.a = 0.0;
color.a = max(color.a, GLASS_OPACITY);
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
}
#endif
@@ -1,133 +1,133 @@
#define NETHER_PORTAL_VARIATION 1 //[1 2]
//#define NETHER_PORTAL_NOISE
#if NETHER_PORTAL_VARIATION == 1
lmCoordM = vec2(0.0);
color = vec4(0.0);
int sampleCount = 8;
float multiplier = 0.4 / (-viewVector.z * sampleCount);
vec2 interval = viewVector.xy * multiplier;
vec2 coord = signMidCoordPos * 0.5 + 0.5;
vec2 absMidCoordPos2 = absMidCoordPos * 2.0;
vec2 midCoord = texCoord - absMidCoordPos * signMidCoordPos;
vec2 minimumMidCoordPos = midCoord - absMidCoordPos;
for (int i = 0; i < sampleCount; i++) {
float portalStep = (i + dither) / sampleCount;
coord += interval * portalStep;
vec2 sampleCoord = fract(coord) * absMidCoordPos2 + minimumMidCoordPos;
vec4 psample = texture2DLod(tex, sampleCoord, 0);
float factor = 1.0 - portalStep;
psample *= pow(factor, 0.1);
emission = max(emission, psample.r);
color += psample;
}
color /= sampleCount;
color.rgb *= color.rgb * vec3(1.25, 1.0, 0.65);
color.a = sqrt1(color.a) * 0.8;
emission *= emission;
emission *= emission;
emission *= emission;
emission = clamp(emission * 120.0, 0.03, 1.2) * 8.0;
#else
#ifdef GENERATED_NORMALS
noGeneratedNormals = true;
#endif
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
wpos.xz /= wpos.y;
vec2 wind = vec2(0.0, frameTimeCounter * 0.03);
float noise = texture2DLod(noisetex, wpos.xz * 0.20 + wind * 0.2, 0.0).r * 0.01;
noise+= texture2DLod(noisetex, wpos.xz * 0.15 + wind * 0.15, 0.0).r * 0.02;
noise+= texture2DLod(noisetex, wpos.xz * 0.10 + wind * 0.10, 0.0).r * 0.06;
noise+= texture2DLod(noisetex, wpos.xz * 0.05 + wind * 0.05, 0.0).r * 0.12;
color.rgb = vec3(0.4431, 0.102, 0.6118) * noise * 3.0;
color.rgb *= color.rgb * 24.0;
float fogFactor = smoothstep(0.0, 1.0, 0.03 / -wpos.y);
fogFactor += smoothstep(0.0, 1.0, 0.03 / wpos.y);
vec3 fogColor = vec3(0.3373, 0.0431, 0.1176) * 25.0;
color.rgb = mix(color.rgb, fogColor, fogFactor);
color.a = 0.7;
#endif
#ifdef NETHER_PORTAL_NOISE
vec2 portalUV;
if (abs(worldGeoNormal.x) > 0.5) {
portalUV = worldPos.yz;
} else {
portalUV = worldPos.yx;
}
float baseNoise = texture2DLod(noisetex, portalUV * 0.03 + frameTimeCounter * 0.01, 0.0).b;
vec2 timeWaves = vec2(
sin(frameTimeCounter * 0.7 + portalUV.x * 2.0),
cos(frameTimeCounter * 0.5 + portalUV.y * 2.0)
);
vec2 warpedUV = portalUV * 0.1 + baseNoise * 0.05 * timeWaves + frameTimeCounter * 0.0083;
float portalNoise = 1.0 - texture2DLod(noisetex, warpedUV, 0.0).g;
color.rgb = mix(color.rgb * 0.66, color.rgb * 0.66 + pow2(vec3(portalNoise * 1.2)), portalNoise);
emission = mix(0, emission, portalNoise);
noGeneratedNormals = portalNoise > 0.25;
#endif
#define PORTAL_REDUCE_CLOSEUP
#ifdef PORTAL_REDUCE_CLOSEUP
color.a *= min1(lViewPos - 0.2);
if (color.a < 0.101) {
if (color.a < 0.101 * dither) discard;
else color.a = 0.101;
}
#endif
#ifdef PORTAL_EDGE_EFFECT
vec3 playerPosCurved = playerPos;
#ifdef WORLD_CURVATURE
playerPosCurved.y += doWorldCurvature(playerPosCurved.xz);
#endif
vec3 voxelPos = SceneToVoxel(playerPosCurved);
if (CheckInsideVoxelVolume(voxelPos)) {
float portalOffset = 0.0625 * dither;
vec3[6] portalOffsets = vec3[](
vec3( portalOffset, 0, 0),
vec3(-portalOffset, 0, 0),
vec3( 0, portalOffset, 0),
vec3( 0,-portalOffset, 0),
vec3( 0, 0, portalOffset),
vec3( 0, 0,-portalOffset)
);
float edge = 0.0;
for (int i = 0; i < 6; i++) {
uint voxel = GetVoxelVolume(ivec3(voxelPos + portalOffsets[i]));
if (voxel != uint(25)) {
edge = 1.0; break;
}
}
vec4 edgeColor = vec4(normalize(color.rgb), 1.0);
edgeColor.b *= 0.8;
color = mix(color, edgeColor, edge);
emission = mix(emission, 5.0, edge);
}
#endif
#if defined NETHER && defined BIOME_COLORED_NETHER_PORTALS
color.rgb = normalize(netherColor) * GetLuminance(color.rgb) * 2.5;
#endif
// color.rgb = vec3(0);
// emission = 0;
#define NETHER_PORTAL_VARIATION 1 //[1 2]
//#define NETHER_PORTAL_NOISE
#if NETHER_PORTAL_VARIATION == 1
lmCoordM = vec2(0.0);
color = vec4(0.0);
int sampleCount = 8;
float multiplier = 0.4 / (-viewVector.z * sampleCount);
vec2 interval = viewVector.xy * multiplier;
vec2 coord = signMidCoordPos * 0.5 + 0.5;
vec2 absMidCoordPos2 = absMidCoordPos * 2.0;
vec2 midCoord = texCoord - absMidCoordPos * signMidCoordPos;
vec2 minimumMidCoordPos = midCoord - absMidCoordPos;
for (int i = 0; i < sampleCount; i++) {
float portalStep = (i + dither) / sampleCount;
coord += interval * portalStep;
vec2 sampleCoord = fract(coord) * absMidCoordPos2 + minimumMidCoordPos;
vec4 psample = texture2DLod(tex, sampleCoord, 0);
float factor = 1.0 - portalStep;
psample *= pow(factor, 0.1);
emission = max(emission, psample.r);
color += psample;
}
color /= sampleCount;
color.rgb *= color.rgb * vec3(1.25, 1.0, 0.65);
color.a = sqrt1(color.a) * 0.8;
emission *= emission;
emission *= emission;
emission *= emission;
emission = clamp(emission * 120.0, 0.03, 1.2) * 8.0;
#else
#ifdef GENERATED_NORMALS
noGeneratedNormals = true;
#endif
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
wpos.xz /= wpos.y;
vec2 wind = vec2(0.0, frameTimeCounter * 0.03);
float noise = texture2DLod(noisetex, wpos.xz * 0.20 + wind * 0.2, 0.0).r * 0.01;
noise+= texture2DLod(noisetex, wpos.xz * 0.15 + wind * 0.15, 0.0).r * 0.02;
noise+= texture2DLod(noisetex, wpos.xz * 0.10 + wind * 0.10, 0.0).r * 0.06;
noise+= texture2DLod(noisetex, wpos.xz * 0.05 + wind * 0.05, 0.0).r * 0.12;
color.rgb = vec3(0.4431, 0.102, 0.6118) * noise * 3.0;
color.rgb *= color.rgb * 24.0;
float fogFactor = smoothstep(0.0, 1.0, 0.03 / -wpos.y);
fogFactor += smoothstep(0.0, 1.0, 0.03 / wpos.y);
vec3 fogColor = vec3(0.3373, 0.0431, 0.1176) * 25.0;
color.rgb = mix(color.rgb, fogColor, fogFactor);
color.a = 0.7;
#endif
#ifdef NETHER_PORTAL_NOISE
vec2 portalUV;
if (abs(worldGeoNormal.x) > 0.5) {
portalUV = worldPos.yz;
} else {
portalUV = worldPos.yx;
}
float baseNoise = texture2DLod(noisetex, portalUV * 0.03 + frameTimeCounter * 0.01, 0.0).b;
vec2 timeWaves = vec2(
sin(frameTimeCounter * 0.7 + portalUV.x * 2.0),
cos(frameTimeCounter * 0.5 + portalUV.y * 2.0)
);
vec2 warpedUV = portalUV * 0.1 + baseNoise * 0.05 * timeWaves + frameTimeCounter * 0.0083;
float portalNoise = 1.0 - texture2DLod(noisetex, warpedUV, 0.0).g;
color.rgb = mix(color.rgb * 0.66, color.rgb * 0.66 + pow2(vec3(portalNoise * 1.2)), portalNoise);
emission = mix(0, emission, portalNoise);
noGeneratedNormals = portalNoise > 0.25;
#endif
#define PORTAL_REDUCE_CLOSEUP
#ifdef PORTAL_REDUCE_CLOSEUP
color.a *= min1(lViewPos - 0.2);
if (color.a < 0.101) {
if (color.a < 0.101 * dither) discard;
else color.a = 0.101;
}
#endif
#ifdef PORTAL_EDGE_EFFECT
vec3 playerPosCurved = playerPos;
#ifdef WORLD_CURVATURE
playerPosCurved.y += doWorldCurvature(playerPosCurved.xz);
#endif
vec3 voxelPos = SceneToVoxel(playerPosCurved);
if (CheckInsideVoxelVolume(voxelPos)) {
float portalOffset = 0.0625 * dither;
vec3[6] portalOffsets = vec3[](
vec3( portalOffset, 0, 0),
vec3(-portalOffset, 0, 0),
vec3( 0, portalOffset, 0),
vec3( 0,-portalOffset, 0),
vec3( 0, 0, portalOffset),
vec3( 0, 0,-portalOffset)
);
float edge = 0.0;
for (int i = 0; i < 6; i++) {
uint voxel = GetVoxelVolume(ivec3(voxelPos + portalOffsets[i]));
if (voxel != uint(25)) {
edge = 1.0; break;
}
}
vec4 edgeColor = vec4(normalize(color.rgb), 1.0);
edgeColor.b *= 0.8;
color = mix(color, edgeColor, edge);
emission = mix(emission, 5.0, edge);
}
#endif
#if defined NETHER && defined BIOME_COLORED_NETHER_PORTALS
color.rgb = normalize(netherColor) * GetLuminance(color.rgb) * 2.5;
#endif
// color.rgb = vec3(0);
// emission = 0;
@@ -1,5 +1,5 @@
smoothnessG = 0.5;
highlightMult = 1.5;
reflectMult = 1.0;
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
smoothnessG = 0.5;
highlightMult = 1.5;
reflectMult = 1.0;
DoTranslucentTweaks(color, fresnelM, reflectMult, lViewPos);
@@ -1,313 +1,313 @@
// ============================== Step 1: Color Prep ============================== //
#include "/lib/shaderSettings/water.glsl"
vec3 glColorM = vec3(0.43, 0.6, 0.8);
#if MC_VERSION >= 11300
#if WATERCOLOR_MODE >= 2
glColorM = glColor.rgb;
#if WATERCOLOR_MODE >= 3
glColorM.g = max(glColorM.g, 0.39);
#endif
#ifdef GBUFFERS_WATER
translucentMultCalculated = true;
translucentMult.rgb = normalize(sqrt2(glColor.rgb));
translucentMult.g *= 0.88;
#endif
#ifdef COMP_WATER_TWEAKS
glColorM = sqrt1(glColorM) * vec3(1.0, 0.85, 0.8);
#endif
#endif
#endif
#if PIXEL_WATER > 0 && (defined GBUFFERS_TERRAIN || defined GBUFFERS_WATER || defined DH_WATER)
const float water_scroll_speed = 0.002;
vec3 worldPosPixel = playerPos + cameraPosition;
vec3 waterPosPixel = worldPosPixel + (vec3(frameTimeCounter) * water_scroll_speed);
vec3 waterMask = waterMaskFunc(waterPosPixel, water_scroll_speed, glColorM, mat, normalM);
vec3 colorOriginal = colorP.rgb;
if (abs(NdotU) > 0.01) colorP.rgb = waterMask;
#endif
#if MC_VERSION >= 11300
#if WATER_STYLE < 3 || PIXEL_WATER == 1
vec3 colorPM = pow2(colorP.rgb);
color.rgb = colorPM * glColorM;
#else
vec3 colorPM = vec3(0.25);
color.rgb = 0.375 * glColorM;
#endif
#else
#if WATER_STYLE < 3 || PIXEL_WATER == 1
color.rgb = mix(color.rgb, vec3(GetLuminance(color.rgb)), 0.88);
color.rgb = pow2(color.rgb) * vec3(2.3, 3.5, 3.1) * 0.9;
#else
color.rgb = vec3(0.13, 0.2, 0.27);
#endif
#endif
#ifdef WATERCOLOR_CHANGED
color.rgb *= vec3(WATERCOLOR_RM, WATERCOLOR_GM, WATERCOLOR_BM);
#endif
// ============================== End of Step 1 ============================== //
#define PHYSICS_OCEAN_INJECTION
#if defined GENERATED_NORMALS && (WATER_STYLE >= 2 || defined PHYSICS_OCEAN || !defined WATER_GENERATED_NORMALS || PIXEL_WATER == 1) && !defined DH_WATER
noGeneratedNormals = true;
#endif
#ifdef WATER_GENERATED_NORMALS
#endif
#if defined GBUFFERS_WATER || defined DH_WATER
SSBLAlpha = 0.0;
lmCoordM.y = min(lmCoord.y * 1.07, 1.0); // Iris/Sodium skylight inconsistency workaround
float fresnel2 = pow2(fresnel);
float fresnel4 = pow2(fresnel2);
// ============================== Step 2: Water Normals ============================== //
reflectMult = 1.0;
float waterBumpNoise = 1.0;
#if WATER_MAT_QUALITY >= 3
materialMask = OSIEBCA * 241.0; // Water
#endif
#if WATER_MAT_QUALITY >= 2 || WATER_STYLE >= 2
#define WATER_SPEED_MULT_M WATER_SPEED_MULT * 0.018
float rawWind = frameTimeCounter * WATER_SPEED_MULT_M;
vec2 wind = vec2(0.0, -rawWind);
vec3 worldPos = playerPos + cameraPosition;
vec2 waterPos = worldPos.xz;
#if WATER_STYLE < 3 && defined GBUFFERS_WATER
float blockRes = absMidCoordPos.x * atlasSize.x * 2.0;
waterPos = floor(waterPos * blockRes) / blockRes;
#endif
waterPos = 0.032 * (waterPos + worldPos.y * 2.0);
#ifdef CLEAR_WATER_SPOTS
waterBumpNoise = 1 - clamp01((1 - smoothstep(0.0, 0.5, texture2DLod(noisetex, waterPos.x * 0.045 + waterPos * 0.042 + wind * 0.006, 0.0).g)) * 2) * 0.85;
#endif
#endif
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2
vec3 normalMap = vec3(0.0, 0.0, 1.0);
#if WATER_STYLE >= 2
vec2 waterPosM = waterPos;
#if WATER_SIZE_MULT != 100
#define WATER_SIZE_MULT_M WATER_SIZE_MULT * 0.01
waterPosM *= WATER_SIZE_MULT_M;
#endif
#define WATER_BUMPINESS_M WATER_BUMPINESS * 0.8
#if WATER_STYLE >= 2
waterPosM *= 2.5; wind *= 2.5;
#if WATER_MAT_QUALITY >= 2
vec2 parallaxMult = -0.01 * viewVector.xy / viewVector.z;
for (int i = 0; i < 4; i++) {
waterPosM += parallaxMult * texture2D(gaux4, waterPosM - wind).a;
waterPosM += parallaxMult * texture2D(gaux4, waterPosM * 0.25 - 0.5 * wind).a;
}
#endif
vec2 normalMed = texture2D(gaux4, waterPosM + wind).rg - 0.5;
vec2 normalSmall = texture2D(gaux4, waterPosM * 4.0 - 2.0 * wind).rg - 0.5;
vec2 normalBig = texture2D(gaux4, waterPosM * 0.25 - 0.5 * wind).rg - 0.5;
normalBig += texture2D(gaux4, waterPosM * 0.05 - 0.05 * wind).rg - 0.5;
normalMap.xy = normalMed * WATER_BUMP_MED + normalSmall * WATER_BUMP_SMALL + normalBig * WATER_BUMP_BIG;
normalMap.xy *= 6.0 * (1.0 - 0.7 * fresnel) * WATER_BUMPINESS_M * waterBumpNoise;
#endif
normalMap.xy *= 0.03 * lmCoordM.y + 0.01;
#else
float pNormalMult = 0.02 * rainFactor * inRainy * pow2(lmCoordM.y);
if (pNormalMult > 0.0005) {
vec2 puddlePos = floor((playerPos.xz + cameraPosition.xz) * 16.0) * 0.00625;
vec2 puddleWind = vec2(frameTimeCounter) * 0.015;
vec2 pNormalCoord1 = puddlePos + vec2(puddleWind.x, puddleWind.y);
vec2 pNormalCoord2 = puddlePos + vec2(puddleWind.x * -1.5, puddleWind.y * -1.0);
vec3 pNormalNoise1 = texture2DLod(noisetex, pNormalCoord1, 0.0).rgb;
vec3 pNormalNoise2 = texture2DLod(noisetex, pNormalCoord2, 0.0).rgb;
normalMap.xy = (pNormalNoise1.xy + pNormalNoise2.yx - vec2(1.0)) * pNormalMult;
normalMap.xy *= 2.0 - 1.8 * fresnel2;
#endif
normalMap.z = sqrt(1.0 - (pow2(normalMap.x) + pow2(normalMap.y)));
normalM = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
#if WATER_STYLE == 1
}
#endif
#if WATER_STYLE >= 2
vec3 vector = reflect(nViewPos, normalize(normalM));
float norMix = pow2(pow2(pow2(1.0 - max0(dot(normal, vector))))) * 0.5;
normalM = mix(normalM, normal, norMix); // Fixes normals pointing inside water
float fresnelP = fresnel;
fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
#endif
#endif
// color.rgb = vec3(waterBumpNoise);
// ============================== End of Step 2 ============================== //
// ============================== Step 3: Water Material Features ============================== //
#if WATER_MAT_QUALITY >= 2
if (isEyeInWater != 1) {
// Noise Coloring //
float noise = texture2DLod(noisetex, (waterPos + wind) * 0.25, 0.0).g;
noise = noise - 0.5;
noise *= 0.25;
color.rgb = pow(color.rgb, vec3(1.0 + noise));
// Water Alpha //
#ifdef GBUFFERS_WATER
float depthT = texelFetch(depthtex1, texelCoord, 0).r;
#elif defined DH_WATER
float depthT = texelFetch(dhDepthTex1, texelCoord, 0).r;
#endif
vec3 screenPosT = vec3(screenPos.xy, depthT);
#ifdef TAA
vec3 viewPosT = ScreenToView(vec3(TAAJitter(screenPosT.xy, -0.5), screenPosT.z));
#else
vec3 viewPosT = ScreenToView(screenPosT);
#endif
float lViewPosT = length(viewPosT);
float lViewPosDifM = lViewPos - lViewPosT;
#if WATER_STYLE < 3 || PIXEL_WATER == 1
color.a = sqrt1(color.a);
#else
color.a = 0.98;
#endif
#ifdef DISTANT_HORIZONS
if (depthT == 1.0) color.a *= smoothstep(far, far * 0.9, lViewPos);
#endif
#if WATER_FOG_MULT != 100
#define WATER_FOG_MULT_M WATER_FOG_MULT * 0.01;
lViewPosDifM *= WATER_FOG_MULT_M;
#endif
float waterFog = max0(1.0 - exp(lViewPosDifM * 0.075));
color.a *= 0.25 + 0.75 * waterFog;
#if defined BRIGHT_CAVE_WATER && WATER_ALPHA_MULT < 200
// For better water visibility in caves and some extra color pop outdoors
color.rgb *= 2.5 - sqrt2(waterFog) - 0.5 * lmCoordM.y;
#endif
#if WATER_ALPHA_MULT != 100
#define WATER_ALPHA_MULT_M 100.0 / WATER_ALPHA_MULT
color.a = pow(color.a, WATER_ALPHA_MULT_M);
#endif
////
// Water Foam //
#if WATER_FOAM_I > 0 && defined GBUFFERS_WATER && !(defined MIRROR_DIMENSION || defined WORLD_CURVATURE)
if (NdotU > 0.99) {
vec3 matrixM = vec3(
gbufferModelViewInverse[0].y,
gbufferModelViewInverse[1].y,
gbufferModelViewInverse[2].y
);
float playerPosTY = dot(matrixM, viewPosT) + gbufferModelViewInverse[3].y;
float yPosDif = playerPosTY - playerPos.y;
#if (WATER_STYLE < 3 || PIXEL_WATER > 0) && MC_VERSION >= 11300
#if PIXEL_WATER > 0
float dotColorPM = dot(waterMask, pow1_5(colorOriginal));
#else
float dotColorPM = dot(colorPM, colorPM);
#endif
float foamThreshold = min(pow2(dotColorPM) * 1.6, 1.2);
#else
float foamThreshold = pow2(texture2DLod(noisetex, waterPos * 4.0 + wind * 0.5, 0.0).g) * 1.6;
#endif
float foam = pow2(clamp((foamThreshold + yPosDif) / foamThreshold, 0.0, 1.0));
#ifndef END
foam *= 0.4 + 0.25 * lmCoord.y;
#else
foam *= 0.6;
#endif
foam *= clamp((fract(worldPos.y) - 0.7) * 10.0, 0.0, 1.0);
vec3 foamColor3 = vec3(0.9, 0.95, 1.05);
#if PIXEL_WATER > 0
foamColor3 *= 2.0;
#endif
vec4 foamColor = vec4(foamColor3, 1.0);
#define WATER_FOAM_IM WATER_FOAM_I * 0.01
#if WATER_FOAM_I < 100
foam *= WATER_FOAM_IM;
#elif WATER_FOAM_I > 100
foamColor *= WATER_FOAM_IM;
#endif
color = mix(color, foamColor, foam);
reflectMult = 1.0 - foam;
}
#endif
////
} else { // Underwater
noDirectionalShading = true;
reflectMult = 0.5;
#if MC_VERSION < 11300 && WATER_STYLE >= 3 && PIXEL_WATER == 0
color.a = 0.7;
#endif
#ifdef GBUFFERS_WATER
#if WATER_STYLE == 1 || PIXEL_WATER == 1
translucentMult.rgb *= 1.0 - fresnel4;
#else
translucentMult.rgb *= 1.0 - 0.9 * max(0.5 * sqrt(fresnel4), fresnel4);
#endif
#endif
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0
reflectMult = 1.0 / color.a;
fresnelM = 1.0;
#endif
reflectMult = clamp01(reflectMult * FRESNEL_MULTIPLIER);
}
#else
shadowMult = vec3(0.0);
#endif
// ============================== End of Step 3 ============================== //
// ============================== Step 4: Final Tweaks ============================== //
reflectMult *= 0.5 + 0.5 * NdotUmax0;
color.a = mix(color.a, 1.0, fresnel4);
#ifdef GBUFFERS_WATER
#if WATER_STYLE == 3 || WATER_STYLE == 2 && SUN_MOON_STYLE >= 2
smoothnessG = 1.0;
const float WATER_BUMPINESS_M2 = min(WATER_BUMP_MED * WATER_BUMP_SMALL * WATER_BUMPINESS * 0.65, 1.0);
vec2 lightNormalP = WATER_BUMPINESS_M2 * (normalMed + 0.5 * normalSmall) * waterBumpNoise;
vec3 lightNormal = normalize(vec3(lightNormalP, 1.0) * tbnMatrix);
highlightMult = dot(lightNormal, lightVec);
highlightMult = max0(highlightMult) / max(dot(normal, lightVec), 0.17);
highlightMult = mix(pow2(pow2(highlightMult * 1.1)), 1.0, min1(sqrt(miplevel) * 0.45)) * 0.24;
#else
smoothnessG = 0.5;
highlightMult = min(pow2(pow2(dot(colorP.rgb, colorP.rgb) * 0.4)), 0.5);
highlightMult *= (16.0 - 15.0 * fresnel2) * (sunVisibility > 0.5 ? 0.85 : 0.425);
#endif
#endif
// ============================== End of Step 4 ============================== //
#endif
// ============================== Step 1: Color Prep ============================== //
#include "/lib/shaderSettings/water.glsl"
vec3 glColorM = vec3(0.43, 0.6, 0.8);
#if MC_VERSION >= 11300
#if WATERCOLOR_MODE >= 2
glColorM = glColor.rgb;
#if WATERCOLOR_MODE >= 3
glColorM.g = max(glColorM.g, 0.39);
#endif
#ifdef GBUFFERS_WATER
translucentMultCalculated = true;
translucentMult.rgb = normalize(sqrt2(glColor.rgb));
translucentMult.g *= 0.88;
#endif
#ifdef COMP_WATER_TWEAKS
glColorM = sqrt1(glColorM) * vec3(1.0, 0.85, 0.8);
#endif
#endif
#endif
#if PIXEL_WATER > 0 && (defined GBUFFERS_TERRAIN || defined GBUFFERS_WATER || defined DH_WATER)
const float water_scroll_speed = 0.002;
vec3 worldPosPixel = playerPos + cameraPosition;
vec3 waterPosPixel = worldPosPixel + (vec3(frameTimeCounter) * water_scroll_speed);
vec3 waterMask = waterMaskFunc(waterPosPixel, water_scroll_speed, glColorM, mat, normalM);
vec3 colorOriginal = colorP.rgb;
if (abs(NdotU) > 0.01) colorP.rgb = waterMask;
#endif
#if MC_VERSION >= 11300
#if WATER_STYLE < 3 || PIXEL_WATER == 1
vec3 colorPM = pow2(colorP.rgb);
color.rgb = colorPM * glColorM;
#else
vec3 colorPM = vec3(0.25);
color.rgb = 0.375 * glColorM;
#endif
#else
#if WATER_STYLE < 3 || PIXEL_WATER == 1
color.rgb = mix(color.rgb, vec3(GetLuminance(color.rgb)), 0.88);
color.rgb = pow2(color.rgb) * vec3(2.3, 3.5, 3.1) * 0.9;
#else
color.rgb = vec3(0.13, 0.2, 0.27);
#endif
#endif
#ifdef WATERCOLOR_CHANGED
color.rgb *= vec3(WATERCOLOR_RM, WATERCOLOR_GM, WATERCOLOR_BM);
#endif
// ============================== End of Step 1 ============================== //
#define PHYSICS_OCEAN_INJECTION
#if defined GENERATED_NORMALS && (WATER_STYLE >= 2 || defined PHYSICS_OCEAN || !defined WATER_GENERATED_NORMALS || PIXEL_WATER == 1) && !defined DH_WATER
noGeneratedNormals = true;
#endif
#ifdef WATER_GENERATED_NORMALS
#endif
#if defined GBUFFERS_WATER || defined DH_WATER
SSBLAlpha = 0.0;
lmCoordM.y = min(lmCoord.y * 1.07, 1.0); // Iris/Sodium skylight inconsistency workaround
float fresnel2 = pow2(fresnel);
float fresnel4 = pow2(fresnel2);
// ============================== Step 2: Water Normals ============================== //
reflectMult = 1.0;
float waterBumpNoise = 1.0;
#if WATER_MAT_QUALITY >= 3
materialMask = OSIEBCA * 241.0; // Water
#endif
#if WATER_MAT_QUALITY >= 2 || WATER_STYLE >= 2
#define WATER_SPEED_MULT_M WATER_SPEED_MULT * 0.018
float rawWind = frameTimeCounter * WATER_SPEED_MULT_M;
vec2 wind = vec2(0.0, -rawWind);
vec3 worldPos = playerPos + cameraPosition;
vec2 waterPos = worldPos.xz;
#if WATER_STYLE < 3 && defined GBUFFERS_WATER
float blockRes = absMidCoordPos.x * atlasSize.x * 2.0;
waterPos = floor(waterPos * blockRes) / blockRes;
#endif
waterPos = 0.032 * (waterPos + worldPos.y * 2.0);
#ifdef CLEAR_WATER_SPOTS
waterBumpNoise = 1 - clamp01((1 - smoothstep(0.0, 0.5, texture2DLod(noisetex, waterPos.x * 0.045 + waterPos * 0.042 + wind * 0.006, 0.0).g)) * 2) * 0.85;
#endif
#endif
#if WATER_STYLE >= 2 || RAIN_PUDDLES >= 1 && WATER_STYLE == 1 && WATER_MAT_QUALITY >= 2
vec3 normalMap = vec3(0.0, 0.0, 1.0);
#if WATER_STYLE >= 2
vec2 waterPosM = waterPos;
#if WATER_SIZE_MULT != 100
#define WATER_SIZE_MULT_M WATER_SIZE_MULT * 0.01
waterPosM *= WATER_SIZE_MULT_M;
#endif
#define WATER_BUMPINESS_M WATER_BUMPINESS * 0.8
#if WATER_STYLE >= 2
waterPosM *= 2.5; wind *= 2.5;
#if WATER_MAT_QUALITY >= 2
vec2 parallaxMult = -0.01 * viewVector.xy / viewVector.z;
for (int i = 0; i < 4; i++) {
waterPosM += parallaxMult * texture2D(gaux4, waterPosM - wind).a;
waterPosM += parallaxMult * texture2D(gaux4, waterPosM * 0.25 - 0.5 * wind).a;
}
#endif
vec2 normalMed = texture2D(gaux4, waterPosM + wind).rg - 0.5;
vec2 normalSmall = texture2D(gaux4, waterPosM * 4.0 - 2.0 * wind).rg - 0.5;
vec2 normalBig = texture2D(gaux4, waterPosM * 0.25 - 0.5 * wind).rg - 0.5;
normalBig += texture2D(gaux4, waterPosM * 0.05 - 0.05 * wind).rg - 0.5;
normalMap.xy = normalMed * WATER_BUMP_MED + normalSmall * WATER_BUMP_SMALL + normalBig * WATER_BUMP_BIG;
normalMap.xy *= 6.0 * (1.0 - 0.7 * fresnel) * WATER_BUMPINESS_M * waterBumpNoise;
#endif
normalMap.xy *= 0.03 * lmCoordM.y + 0.01;
#else
float pNormalMult = 0.02 * rainFactor * inRainy * pow2(lmCoordM.y);
if (pNormalMult > 0.0005) {
vec2 puddlePos = floor((playerPos.xz + cameraPosition.xz) * 16.0) * 0.00625;
vec2 puddleWind = vec2(frameTimeCounter) * 0.015;
vec2 pNormalCoord1 = puddlePos + vec2(puddleWind.x, puddleWind.y);
vec2 pNormalCoord2 = puddlePos + vec2(puddleWind.x * -1.5, puddleWind.y * -1.0);
vec3 pNormalNoise1 = texture2DLod(noisetex, pNormalCoord1, 0.0).rgb;
vec3 pNormalNoise2 = texture2DLod(noisetex, pNormalCoord2, 0.0).rgb;
normalMap.xy = (pNormalNoise1.xy + pNormalNoise2.yx - vec2(1.0)) * pNormalMult;
normalMap.xy *= 2.0 - 1.8 * fresnel2;
#endif
normalMap.z = sqrt(1.0 - (pow2(normalMap.x) + pow2(normalMap.y)));
normalM = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
#if WATER_STYLE == 1
}
#endif
#if WATER_STYLE >= 2
vec3 vector = reflect(nViewPos, normalize(normalM));
float norMix = pow2(pow2(pow2(1.0 - max0(dot(normal, vector))))) * 0.5;
normalM = mix(normalM, normal, norMix); // Fixes normals pointing inside water
float fresnelP = fresnel;
fresnel = clamp(1.0 + dot(normalM, nViewPos), 0.0, 1.0);
#endif
#endif
// color.rgb = vec3(waterBumpNoise);
// ============================== End of Step 2 ============================== //
// ============================== Step 3: Water Material Features ============================== //
#if WATER_MAT_QUALITY >= 2
if (isEyeInWater != 1) {
// Noise Coloring //
float noise = texture2DLod(noisetex, (waterPos + wind) * 0.25, 0.0).g;
noise = noise - 0.5;
noise *= 0.25;
color.rgb = pow(color.rgb, vec3(1.0 + noise));
// Water Alpha //
#ifdef GBUFFERS_WATER
float depthT = texelFetch(depthtex1, texelCoord, 0).r;
#elif defined DH_WATER
float depthT = texelFetch(dhDepthTex1, texelCoord, 0).r;
#endif
vec3 screenPosT = vec3(screenPos.xy, depthT);
#ifdef TAA
vec3 viewPosT = ScreenToView(vec3(TAAJitter(screenPosT.xy, -0.5), screenPosT.z));
#else
vec3 viewPosT = ScreenToView(screenPosT);
#endif
float lViewPosT = length(viewPosT);
float lViewPosDifM = lViewPos - lViewPosT;
#if WATER_STYLE < 3 || PIXEL_WATER == 1
color.a = sqrt1(color.a);
#else
color.a = 0.98;
#endif
#ifdef DISTANT_HORIZONS
if (depthT == 1.0) color.a *= smoothstep(far, far * 0.9, lViewPos);
#endif
#if WATER_FOG_MULT != 100
#define WATER_FOG_MULT_M WATER_FOG_MULT * 0.01;
lViewPosDifM *= WATER_FOG_MULT_M;
#endif
float waterFog = max0(1.0 - exp(lViewPosDifM * 0.075));
color.a *= 0.25 + 0.75 * waterFog;
#if defined BRIGHT_CAVE_WATER && WATER_ALPHA_MULT < 200
// For better water visibility in caves and some extra color pop outdoors
color.rgb *= 2.5 - sqrt2(waterFog) - 0.5 * lmCoordM.y;
#endif
#if WATER_ALPHA_MULT != 100
#define WATER_ALPHA_MULT_M 100.0 / WATER_ALPHA_MULT
color.a = pow(color.a, WATER_ALPHA_MULT_M);
#endif
////
// Water Foam //
#if WATER_FOAM_I > 0 && defined GBUFFERS_WATER && !(defined MIRROR_DIMENSION || defined WORLD_CURVATURE)
if (NdotU > 0.99) {
vec3 matrixM = vec3(
gbufferModelViewInverse[0].y,
gbufferModelViewInverse[1].y,
gbufferModelViewInverse[2].y
);
float playerPosTY = dot(matrixM, viewPosT) + gbufferModelViewInverse[3].y;
float yPosDif = playerPosTY - playerPos.y;
#if (WATER_STYLE < 3 || PIXEL_WATER > 0) && MC_VERSION >= 11300
#if PIXEL_WATER > 0
float dotColorPM = dot(waterMask, pow1_5(colorOriginal));
#else
float dotColorPM = dot(colorPM, colorPM);
#endif
float foamThreshold = min(pow2(dotColorPM) * 1.6, 1.2);
#else
float foamThreshold = pow2(texture2DLod(noisetex, waterPos * 4.0 + wind * 0.5, 0.0).g) * 1.6;
#endif
float foam = pow2(clamp((foamThreshold + yPosDif) / foamThreshold, 0.0, 1.0));
#ifndef END
foam *= 0.4 + 0.25 * lmCoord.y;
#else
foam *= 0.6;
#endif
foam *= clamp((fract(worldPos.y) - 0.7) * 10.0, 0.0, 1.0);
vec3 foamColor3 = vec3(0.9, 0.95, 1.05);
#if PIXEL_WATER > 0
foamColor3 *= 2.0;
#endif
vec4 foamColor = vec4(foamColor3, 1.0);
#define WATER_FOAM_IM WATER_FOAM_I * 0.01
#if WATER_FOAM_I < 100
foam *= WATER_FOAM_IM;
#elif WATER_FOAM_I > 100
foamColor *= WATER_FOAM_IM;
#endif
color = mix(color, foamColor, foam);
reflectMult = 1.0 - foam;
}
#endif
////
} else { // Underwater
noDirectionalShading = true;
reflectMult = 0.5;
#if MC_VERSION < 11300 && WATER_STYLE >= 3 && PIXEL_WATER == 0
color.a = 0.7;
#endif
#ifdef GBUFFERS_WATER
#if WATER_STYLE == 1 || PIXEL_WATER == 1
translucentMult.rgb *= 1.0 - fresnel4;
#else
translucentMult.rgb *= 1.0 - 0.9 * max(0.5 * sqrt(fresnel4), fresnel4);
#endif
#endif
#if WORLD_SPACE_REFLECTIONS_INTERNAL > 0
reflectMult = 1.0 / color.a;
fresnelM = 1.0;
#endif
reflectMult = clamp01(reflectMult * FRESNEL_MULTIPLIER);
}
#else
shadowMult = vec3(0.0);
#endif
// ============================== End of Step 3 ============================== //
// ============================== Step 4: Final Tweaks ============================== //
reflectMult *= 0.5 + 0.5 * NdotUmax0;
color.a = mix(color.a, 1.0, fresnel4);
#ifdef GBUFFERS_WATER
#if WATER_STYLE == 3 || WATER_STYLE == 2 && SUN_MOON_STYLE >= 2
smoothnessG = 1.0;
const float WATER_BUMPINESS_M2 = min(WATER_BUMP_MED * WATER_BUMP_SMALL * WATER_BUMPINESS * 0.65, 1.0);
vec2 lightNormalP = WATER_BUMPINESS_M2 * (normalMed + 0.5 * normalSmall) * waterBumpNoise;
vec3 lightNormal = normalize(vec3(lightNormalP, 1.0) * tbnMatrix);
highlightMult = dot(lightNormal, lightVec);
highlightMult = max0(highlightMult) / max(dot(normal, lightVec), 0.17);
highlightMult = mix(pow2(pow2(highlightMult * 1.1)), 1.0, min1(sqrt(miplevel) * 0.45)) * 0.24;
#else
smoothnessG = 0.5;
highlightMult = min(pow2(pow2(dot(colorP.rgb, colorP.rgb) * 0.4)), 0.5);
highlightMult *= (16.0 - 15.0 * fresnel2) * (sunVisibility > 0.5 ? 0.85 : 0.425);
#endif
#endif
// ============================== End of Step 4 ============================== //
#endif