diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index cec41f3..8480dc8 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -631,7 +631,6 @@ void main() { bool inShadowmapBounds = false; #endif ///////////////////////////// start drawin :D - if (z >= 1.0) { #ifdef OVERWORLD_SHADER diff --git a/shaders/dimensions/composite3.fsh b/shaders/dimensions/composite3.fsh index 4db76e5..dc081b9 100644 --- a/shaders/dimensions/composite3.fsh +++ b/shaders/dimensions/composite3.fsh @@ -182,8 +182,6 @@ void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, vec2 depths){ vec2 UnalteredTexcoord = Texcoord; - // Texcoord = min(Texcoord, 1.0-abs(Texcoord)); - Texcoord = abs(Texcoord + (TangentNormals * clamp((ld(depths.x) - ld(depths.y)) * 0.5,0.0,0.15)) * RENDER_SCALE ); float DistortedAlpha = decodeVec2(texture2D(colortex11,Texcoord).b).g; @@ -192,85 +190,70 @@ void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, vec2 depths){ } uniform float eyeAltitude; + void main() { /* DRAWBUFFERS:73 */ + ////// --------------- SETUP STUFF --------------- ////// vec2 texcoord = gl_FragCoord.xy*texelSize; - vec4 trpData = texture2D(colortex7,texcoord); - - bool iswater = trpData.a > 0.99; - float translucentAlpha = trpData.a; - - // vec4 speculartex = texture2D(colortex8,texcoord); // translucents - // float sunlight = speculartex.b; - - //3x3 bilateral upscale from half resolution float z = texture2D(depthtex0,texcoord).x; float z2 = texture2D(depthtex1,texcoord).x; float frDepth = ld(z2); - // vec4 vl = texture2D(colortex0,texcoord * 0.5); - - ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - // vec4 data_opaque = texture2D(colortex1,texcoord); - // vec4 dataUnpacked1 = vec4(decodeVec2(data_opaque.z),decodeVec2(data_opaque.w)); // normals, lightmaps - // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - - // bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - // vec2 lightmap = dataUnpacked1.yz; - - ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// - - vec3 data = texture2D(colortex11,texcoord).rgb; - - vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; - vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; - - - - vec4 albedo = vec4(unpack0.ba,unpack1.rg); - - vec2 tangentNormals = unpack0.xy*2.0-1.0; - - if(albedo.a <= 0.0) tangentNormals = vec2(0.0); - - vec4 TranslucentShader = texture2D(colortex2,texcoord); - - - vec2 tempOffset = TAA_Offset; vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2)); - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; vec3 np3 = normVec(p3); + float linearDistance = length(p3); + float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); + + ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// + vec3 data = texture2D(colortex11,texcoord).rgb; + vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; + vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; + + vec4 albedo = vec4(unpack0.ba,unpack1.rg); + vec2 tangentNormals = unpack0.xy*2.0-1.0; + if(albedo.a <= 0.0) tangentNormals = vec2(0.0); + vec4 TranslucentShader = texture2D(colortex2,texcoord); + + ////// --------------- UNPACK MISC --------------- ////// + float trpData = texture2D(colortex7,texcoord).a; + + ////// --------------- MASKS/BOOLEANS --------------- ////// + bool iswater = trpData > 0.99; + float translucentAlpha = trpData; + + ////// --------------- get volumetrics + vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth); + float bloomyFogMult = 1.0; + + ////// --------------- distort texcoords as a refraction effect vec2 refractedCoord = texcoord; - - /// --- REFRACTION --- /// #ifdef Refraction ApplyDistortion(refractedCoord, tangentNormals, vec2(z2,z)); #endif - /// --- MAIN COLOR BUFFER --- /// - // it is sampled with distorted texcoords - vec3 color = texture2D(colortex3,refractedCoord).rgb; + ////// --------------- MAIN COLOR BUFFER + vec3 color = texture2D(colortex3, refractedCoord).rgb; - float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); - #if defined OVERWORLD_SHADER && defined BorderFog - float fog = exp2(-100.0 * pow(clamp(1.0-length(p3)/far,0.0,1.0),2.0)); - fog *= exp(-30.0*(pow(clamp(np3.y,0.0,1.0),2.0))) ; - - if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, skyGroundColor, fog); + ////// --------------- BLEND TRANSLUCENT GBUFFERS + //////////// and do border fog on opaque and translucents + + #if defined BorderFog + float fog = exp(-50.0 * pow(clamp(1.0-linearDistance/far,0.0,1.0),2.0)); + fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0)); + if(z >= 1.0 || isEyeInWater != 0) fog = 0.0; + + color.rgb = mix(color.rgb, skyGroundColor, fog); #endif - vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth); - float bloomyFogMult = 1.0; - if (TranslucentShader.a > 0.0){ #ifdef Glass_Tint if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0); @@ -278,83 +261,89 @@ void main() { color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb; - #ifdef BorderFog - if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, skyGroundColor, fog); + color.rgb = mix(color.rgb, skyGroundColor, fog); #endif } -#if defined OVERWORLD_SHADER && defined Cave_fog - if (isEyeInWater == 0 && eyeAltitude < 1500){ +////// --------------- VARIOUS FOG EFFECTS (behind volumetric fog) +//////////// blindness, nightvision, liquid fogs and misc fogs - float fogdistfade = clamp( pow(length(fragpos) / far, CaveFogFallOff) ,0.0,1.0); - - fogdistfade = fogdistfade*0.95 + clamp( pow(1.0 - exp((length(fragpos) / far) * -5), 2.0) ,0.0,1.0)*0.05; - float fogfade = clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); - - vec3 cavefogCol = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B); - - #ifdef PER_BIOME_ENVIRONMENT +#if defined OVERWORLD_SHADER && defined CAVE_FOG + if (isEyeInWater == 0 && eyeAltitude < 1500 && lightleakfix < 1.0){ + + float cavefog = clamp( pow(linearDistance / far, CaveFogFallOff) ,0.0,1.0); + cavefog = cavefog*0.95 + clamp( pow(1.0 - exp((linearDistance / far) * -5), 2.0) ,0.0,1.0)*0.05; + + cavefog *= exp(-30.0*(pow(clamp(np3.y-0.5,0.0,1.0),2.0))); // create a hole in the fog above, so the sky is a little visible. + + vec3 cavefogCol = vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B); + cavefogCol *= clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); // apply a vertical gradient to the fog color + + #ifdef PER_BIOME_ENVIRONMENT BiomeFogColor(cavefogCol); #endif - - color.rgb = mix(color.rgb, cavefogCol*fogfade, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor) * clamp( 1.5 - np3.y,0.,1)) ; + + color.rgb = mix(color.rgb, cavefogCol, cavefog * (1-lightleakfix)); } #endif +////// --------------- Distance fog for the end shader #ifdef END_SHADER if (isEyeInWater == 0){ vec3 hazeColor = vec3(0.3,0.75,1.0) * 0.3; - float hazeDensity = clamp(1.0 - length(fragpos) / max(far, 32.0 * 24.0),0.0,1.0); + float hazeDensity = clamp(1.0 - linearDistance / max(far, 32.0 * 24.0),0.0,1.0); color.rgb = mix(hazeColor, color.rgb, hazeDensity) ; } #endif - - // underwater fog +////// --------------- underwater fog if (isEyeInWater == 1){ float dirtAmount = Dirt_Amount; vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - // float fogfade = clamp( exp(length(fragpos) / -20) ,0.0,1.0); - // vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); - vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); - fogfade *= 1.0 - clamp( length(fragpos) / far,0.0,1.0); + vec3 fogfade = clamp( exp( (linearDistance / -4) * totEpsilon ) ,0.0,1.0); + fogfade *= 1.0 - clamp( linearDistance / far,0.0,1.0); - color.rgb *= fogfade ; + color.rgb *= fogfade; bloomyFogMult *= 0.3; } - // apply VL fog to the scene +////// --------------- BLEND FOG INTO SCENE +//////////// apply VL fog over opaque and translucents color *= vl.a; color += vl.rgb; +////// --------------- VARIOUS FOG EFFECTS (in front of volumetric fog) +//////////// blindness, nightvision, liquid fogs and misc fogs + +////// --------------- bloomy rain effect #ifdef OVERWORLD_SHADER - // bloomy rain effect float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); if(rainDrops > 0.0) bloomyFogMult *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0); #endif - /// lava. +////// --------------- lava. if (isEyeInWater == 2){ color.rgb = vec3(4.0,0.5,0.1); } - /// powdered snow +///////// --------------- powdered snow if (isEyeInWater == 3){ - color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.)); + color.rgb = mix(color.rgb,vec3(10,15,20),clamp(linearDistance*0.5,0.,1.)); bloomyFogMult = 0.0; } - // blidnesss - color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -5),0.,1.) , blindness); +////// --------------- blidnesss + color.rgb *= mix(1.0,clamp( exp(pow(linearDistance*(blindness*0.2),2) * -5),0.,1.) , blindness); - // darkness effect +//////// --------------- darkness effect color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); +////// --------------- FINALIZE #ifdef display_LUT vec2 movedTC = texcoord; vec3 thingy = texture2D(colortex4,movedTC).rgb / 30; @@ -366,7 +355,5 @@ void main() { #endif gl_FragData[0].r = vl.a * bloomyFogMult; // pass fog alpha so bloom can do bloomy fog - gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0); - } \ No newline at end of file diff --git a/shaders/lang/zh_cn.lang b/shaders/lang/zh_cn.lang index 8d3229c..dc11e97 100644 --- a/shaders/lang/zh_cn.lang +++ b/shaders/lang/zh_cn.lang @@ -122,7 +122,7 @@ screen.Fog = 雾气设置 option.PER_BIOME_ENVIRONMENT = 生物群系特定雾气 screen.Cave_Fog = 洞穴雾气 - option.Cave_fog = 洞穴雾气 + option.CAVE_FOG = 洞穴雾气 option.CaveFogFallOff = 洞穴雾气渐消曲线 option.CaveFogColor_R = 洞穴雾气红色比重 option.CaveFogColor_G = 洞穴雾气绿色比重 diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 60189bd..f349a92 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -169,14 +169,15 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8 #define BLOOMY_FOG 1.5 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0] #define BLOOM_STRENGTH 4.0 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0] -#define Cave_fog +#define CAVE_FOG +#ifdef CAVE_FOG +#endif #define CaveFogFallOff 2.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] #define CaveFogColor_R 0.1 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] #define CaveFogColor_G 0.2 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] #define CaveFogColor_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] -// #define BorderFog - +#define BorderFog #if !defined OVERWORLD_SHADER #undef BorderFog #endif diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index a870482..4c337ab 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -221,7 +221,7 @@ void DoSpecularReflections( bool hasReflections = Roughness_Threshold == 1.0 ? true : F0 * (1.0 - Roughness * Roughness_Threshold) > 0.01; // mulitply all reflections by the albedo if it is a metal. - vec3 Metals = F0 > 229.5/255.0 ? lerp(Albedo, vec3(1.0), Fresnel) : vec3(1.0); + vec3 Metals = F0 > 229.5/255.0 ? max(Albedo, Fresnel) : vec3(1.0); // --------------- BACKGROUND REFLECTIONS // apply background reflections to the final color. make sure it does not exist based on the lightmap diff --git a/shaders/shaders.properties b/shaders/shaders.properties index fd5e4ab..b2e34e6 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -185,12 +185,30 @@ PhysicsMod_support [LabPBR] ### FOG screen.Fog.columns=2 - screen.Fog = VL_RENDER_RESOLUTION Haze_amount \ - VL_SAMPLES RainFog_amount \ - BLOOMY_FOG [TOD_fog] \ - BorderFog [Cave_Fog] \ - FOG_START_HEIGHT [END_AND_NETHER_FOG] \ - RAYMARCH_CLOUDS_WITH_FOG PER_BIOME_ENVIRONMENT + + # screen.Fog = VL_RENDER_RESOLUTION VL_SAMPLES FOG_START_HEIGHT \ + # Haze_amount RainFog_amount BLOOMY_FOG \ + # BorderFog PER_BIOME_ENVIRONMENT RAYMARCH_CLOUDS_WITH_FOG \ + # [Cave_Fog] [TOD_fog] [END_AND_NETHER_FOG] + + + screen.Fog = VL_RENDER_RESOLUTION VL_SAMPLES \ + FOG_START_HEIGHT BLOOMY_FOG \ + \ + Haze_amount RainFog_amount \ + [TOD_fog] [Cave_Fog] \ + [END_AND_NETHER_FOG] \ + \ + BorderFog PER_BIOME_ENVIRONMENT \ + RAYMARCH_CLOUDS_WITH_FOG + + + # screen.Fog = VL_RENDER_RESOLUTION Haze_amount \ + # VL_SAMPLES RainFog_amount \ + # BLOOMY_FOG [TOD_fog] \ + # FOG_START_HEIGHT [Cave_Fog] \ + # PER_BIOME_ENVIRONMENT [END_AND_NETHER_FOG] \ + # RAYMARCH_CLOUDS_WITH_FOG BorderFog @@ -198,12 +216,12 @@ PhysicsMod_support [LabPBR] screen.TOD_fog = TOD_Fog_mult Morning_Uniform_Fog Morning_Cloudy_Fog Noon_Uniform_Fog Noon_Cloudy_Fog Evening_Uniform_Fog Evening_Cloudy_Fog Night_Uniform_Fog Night_Cloudy_Fog screen.Cave_Fog.columns=1 - screen.Cave_Fog = Cave_fog CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B + screen.Cave_Fog = CAVE_FOG CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B screen.Fog_Color.columns=1 screen.Fog_Color = fog_coefficientRayleighR fog_coefficientRayleighG fog_coefficientRayleighB fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB - screen.END_AND_NETHER_FOG.columns=2 + screen.END_AND_NETHER_FOG.columns=1 screen.END_AND_NETHER_FOG = END_STORM_DENSTIY PLUME_DENSITY ### WATER