From 05f8dd803d8f8c288153e54f7694ff6d37ae3c61 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Tue, 18 Nov 2025 09:30:15 +0100 Subject: [PATCH] downgrade to v1.53 -> fix dark nights, but removes DH compat too --- shaders/composite.fsh | 38 -------- shaders/composite1.fsh | 184 ++++++++++++++++--------------------- shaders/dh_terrain.fsh | 31 ------- shaders/dh_terrain.vsh | 43 --------- shaders/dh_water.fsh | 125 ------------------------- shaders/dh_water.vsh | 167 --------------------------------- shaders/final.fsh | 21 ++--- shaders/shaders.properties | 5 - shaders/shaders.settings | 14 +-- 9 files changed, 91 insertions(+), 537 deletions(-) delete mode 100644 shaders/dh_terrain.fsh delete mode 100644 shaders/dh_terrain.vsh delete mode 100644 shaders/dh_water.fsh delete mode 100644 shaders/dh_water.vsh diff --git a/shaders/composite.fsh b/shaders/composite.fsh index 7ce5eeb..6d1f696 100644 --- a/shaders/composite.fsh +++ b/shaders/composite.fsh @@ -1,14 +1,5 @@ #version 120 /* DRAWBUFFERS:34 */ -/* -Sildur's Vibrant Shaders: -https://www.patreon.com/Sildur -https://sildurs-shaders.github.io/ -https://twitter.com/SildurFX - -Permissions: -You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours. -*/ #define gbuffers_shadows #define composite0 @@ -971,13 +962,6 @@ vec3 YCoCg2RGB(vec3 c){ return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b); } -#ifdef DISTANT_HORIZONS -uniform sampler2D dhDepthTex0; -uniform sampler2D dhDepthTex1; -uniform float dhNearPlane; -uniform float dhFarPlane; -#endif - void main() { //sample half-resolution buffer with correct texture coordinates @@ -987,14 +971,7 @@ vec4 hr = pow(texture2D(composite,(floor(gl_FragCoord.xy/2.)*2+1.0)/vec2(viewWid float depth0 = texture2D(depthtex0, texcoord).x; //everything float depth1 = texture2D(depthtex1, texcoord).x; //transparency -//DH -#ifndef DISTANT_HORIZONS bool sky = (depth0 >= 1.0); -#else -float DHdepth0 = texture2D(dhDepthTex0, texcoord).x; -float DHdepth1 = texture2D(dhDepthTex1, texcoord).x; -bool sky = (depth0 >= 1.0) && !(DHdepth1 < depth1); -#endif vec4 albedo = texture2D(colortex0,texcoord); vec3 normal = decode(texture2D(colortex1, texcoord).xy); @@ -1217,21 +1194,11 @@ if (ntc2.x < 1.0 && ntc2.y < 1.0 && ntc2.x > 0.0 && ntc2.y > 0.0){ vec2 noisetc = ntc2 + deltatexcoord*raysNoise(ntc2) + deltatexcoord; //maybe doesnt need to be filtered bool underwater = (isEyeInWater == 1.0); -#ifndef DISTANT_HORIZONS for (int i = 0; i < grays_sample; i++) { float depth = underwater? texture2D(depthtex1, noisetc).x : texture2D(depthtex0, noisetc).x; //swap depth for now, wip noisetc += deltatexcoord; gr += dot(step(comp, depth), 1.0)*cdist(noisetc); } -#else - comp = 1.0-dhNearPlane/dhFarPlane/dhFarPlane; - for (int i = 0; i < grays_sample; i++) { - float depth = underwater? texture2D(dhDepthTex1, noisetc).x : texture2D(dhDepthTex0, noisetc).x; - depth *= underwater? texture2D(depthtex1, noisetc).x : texture2D(depthtex0, noisetc).x; //swap depth for now, wip - noisetc += deltatexcoord; - gr += dot(step(comp, depth), 1.0)*cdist(noisetc); - } -#endif gr /= grays_sample; #endif #endif @@ -1247,12 +1214,7 @@ gr = 0.0; for (int i = -6; i < 7;i++) { for (int j = -6; j < 7 ;j++) { vec2 ij = vec2(i,j); - #ifndef DISTANT_HORIZONS float depth = texture2D(depthtex0, ntc+lightPos + sign(ij)*sqrt(abs(ij))*vec2(0.006)).x; - #else - float depth = texture2D(dhDepthTex0, ntc+lightPos + sign(ij)*sqrt(abs(ij))*vec2(0.006)).x; - depth *= texture2D(depthtex0, ntc+lightPos + sign(ij)*sqrt(abs(ij))*vec2(0.006)).x; - #endif gr += dot(step(comp, depth), 1.0); } } diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 8f4223e..2772eee 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -2,15 +2,6 @@ #extension GL_ARB_shader_texture_lod : enable const bool gaux1MipmapEnabled = true; /* DRAWBUFFERS:3 */ -/* -Sildur's Vibrant Shaders: -https://www.patreon.com/Sildur -https://sildurs-shaders.github.io/ -https://twitter.com/SildurFX - -Permissions: -You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours. -*/ #define composite2 #define composite1 @@ -81,6 +72,7 @@ uniform float darknessFactor; uniform float darknessLightFactor; #endif +/*------------------------------------------*/ float comp = 1.0-near/far/far; float tmult = mix(min(abs(worldTime-6000.0)/6000.0,1.0),1.0,rainStrength); float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0); @@ -105,7 +97,7 @@ vec3 drawMoon(vec3 fposition, vec3 color, float vis) { vec3 moonlightC = mix(pow(moonlight*40.0,vec3(1.0))*44.0,vec3(0.25,0.3,0.4),rainStrength*0.8); return mix(color,moonlightC,moon*vis); -} +}/**--------------------------------------*/ #ifdef Fog float getAirDensity (float h) { @@ -168,16 +160,6 @@ gradN = mix(gradN,moonlightRain,rainStrength); return pow(L*(c*exp(d*Y)+A),invRain07)*sunVisibility *length(rawAvg) * (0.85+rainStrength*0.425)*grad3+ 0.2*pow(L2*1.2+1.2,invRain07)*moonVisibility*gradN; }/*---------------------------------*/ -#ifdef DISTANT_HORIZONS -uniform sampler2D dhDepthTex0; -uniform sampler2D dhDepthTex1; -uniform int dhRenderDistance; -uniform float dhFarPlane; -uniform float dhNearPlane; -uniform mat4 dhProjection; -uniform mat4 dhProjectionInverse; -#endif - #if defined waterRefl || defined iceRefl ||defined metallicRefl || defined polishedRefl || defined RainReflections const int maxf = 3; //number of refinements const float ref = 0.11; //refinement multiplier @@ -193,7 +175,7 @@ float cdist(vec2 coord) { return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0; } -vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector, sampler2D depth, mat4 projection, mat4 projectionInverse) { +vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector) { vec4 color = vec4(0.0); vec3 start = fragpos; rvector *= 1.2; @@ -202,15 +184,15 @@ vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector, sampler2D depth, mat4 p int sr = 0; for(int i=0;i<25;i++){ - vec3 pos = nvec3(projection * nvec4(fragpos)) * 0.5 + 0.5; + vec3 pos = nvec3(gbufferProjection * nvec4(fragpos)) * 0.5 + 0.5; if(pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1 || pos.z < 0 || pos.z > 1.0) break; - vec3 fragpos0 = vec3(pos.st, texture2D(depth, pos.st).r); - fragpos0 = nvec3(projectionInverse * nvec4(fragpos0 * 2.0 - 1.0)); + vec3 fragpos0 = vec3(pos.st, texture2D(depthtex1, pos.st).r); + fragpos0 = nvec3(gbufferProjectionInverse * nvec4(fragpos0 * 2.0 - 1.0)); float err = distance(fragpos,fragpos0); - if(err < pow(length(rvector),1.175)){ + if(err < pow(length(rvector),1.175)){ //if(err < pow(length(rvector)*1.85,1.15)){ <- old, adjusted error check to reduce banding issues/glitches sr++; if(sr >= maxf){ - bool land = texture2D(depth, pos.st).r < comp; + bool land = texture2D(depthtex1, pos.st).r < comp; color = pow(texture2DLod(gaux1, pos.st, 1),vec4(2.2))*257.0; if (isEyeInWater == 0) color.rgb = land ? mix(color.rgb,skycolor*(0.7+0.3*tmult)*(1.33-rainStrength*0.8),calcFog(fragpos0.xyz)) : drawSun(rvector,skycolor,1.0); color.a = clamp(1.0 - pow(cdist(pos.st), 20.0), 0.0, 1.0); @@ -219,12 +201,8 @@ vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector, sampler2D depth, mat4 p tvector -= rvector; rvector *= ref; - } - #ifndef DISTANT_HORIZONS - rvector *= inc - 0.0000275 / (2.0 * near / (far + near - rvector.z * far - near)); //offset to reduce reflection errors - #else - rvector *= texture2D(dhDepthTex1, texcoord).x > texture2D(dhDepthTex0, texcoord).x ? inc : inc - 0.0000275 / (2.0 * near / (far + near - rvector.z * far - near)); //offset to reduce reflection errors - #endif +} + rvector *= inc; tvector += rvector; fragpos = start + tvector; } @@ -250,7 +228,7 @@ vec4 raytraceLand(vec3 fragpos, vec3 skycolor, vec3 rvector) { vec3 fragpos0 = vec3(pos.st, texture2D(depthtex1, pos.st).r); fragpos0 = nvec3(gbufferProjectionInverse * nvec4(fragpos0 * 2.0 - 1.0)); float err = distance(fragpos,fragpos0); - if(err < pow(length(rvector),errorstep)){ + if(err < pow(length(rvector),errorstep)){ //if(err < pow(length(rvector)*1.85,1.15)){ <- old, adjusted error check to reduce banding issues/glitches sr++; if(sr >= maxf){ bool land = texture2D(depthtex1, pos.st).r < comp; @@ -460,7 +438,8 @@ float calcWaves(vec2 coord){ coord1 *= waveSize; float wave = texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves - wave -= texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves + wave -= texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves + wave += 1.0-sqrt(texture2D(noisetex,coord2 * 0.0416).x * 6.5) * 1.33; //noise texture wave *= 0.0157; return wave; @@ -523,17 +502,23 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(3,7.)/8., vec2(7.,-7.)/8.); -vec3 ScreenSpace() { +vec3 toScreenSpace(vec3 p) { vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = vec3(gl_FragCoord.xy*texelSize-offsets[framemod8]*texelSize*0.5, texture2D(depthtex0, gl_FragCoord.xy*texelSize).x) * 2.0 - 1.0; + vec3 p3 = p * 2.0 - 1.0; vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return normalize(fragposition.xyz / fragposition.w); + return fragposition.xyz / fragposition.w; } +vec2 newTC = gl_FragCoord.xy*texelSize; +vec3 TAAfragpos = toScreenSpace(vec3(newTC-offsets[framemod8]*texelSize*0.5, texture2D(depthtex0, newTC).x)); + #if defined waterRefl || defined iceRefl vec3 toClipSpace(vec3 viewSpacePosition) { return (vec3(gbufferProjection[0].x, gbufferProjection[1].y, gbufferProjection[2].z) * viewSpacePosition + gbufferProjection[3].xyz) / -viewSpacePosition.z * 0.5 + 0.5; } +float ld(float dist) { + return (2.0 * near) / (far + near - dist * (far - near)); +} vec3 newTrace(vec3 dir, vec3 position, float dither, float fresnel){ #define SSR_STEPS 40 //[10 15 20 25 30 35 40 50 100 200 400] @@ -541,22 +526,28 @@ vec3 newTrace(vec3 dir, vec3 position, float dither, float fresnel){ vec3 clipPosition = toClipSpace(position); float rayLength = ((position.z + dir.z * far*1.732) > -near) ? (-near -position.z) / dir.z : far*1.732; - vec3 direction = normalize(toClipSpace(position+dir*rayLength) - clipPosition); + vec3 direction = normalize(toClipSpace(position+dir*rayLength)-clipPosition); //convert to clip space - vec3 maxLengths = (step(0.0, direction) - clipPosition) / direction; - vec3 stepv = direction * min(min(maxLengths.x, maxLengths.y), maxLengths.z) / quality; + //get at which length the ray intersects with the edge of the screen + vec3 maxLengths = (step(0.0,direction)-clipPosition) / direction; + float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z); + + vec3 stepv = direction * mult / quality; vec3 spos = clipPosition + stepv*dither; float minZ = clipPosition.z; float maxZ = spos.z+stepv.z*0.5; spos.xy+=offsets[framemod8]*texelSize*0.5; - + //raymarch on a quarter res depth buffer for improved cache coherency + for (int i = 0; i < int(quality+1); i++) { - float sp = texture2D(depthtex1, spos.xy).x; + //float sp = texelFetch2D(depthtex1, ivec2(spos.xy/texelSize), 0).x; + float sp = texture2D(depthtex1, spos.xy).x; //might be slower then texelfetch but doesn't require shader4 extension if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy,sp); spos += stepv; - minZ = maxZ - 0.00004 / (2.0 * near / (far + near - spos.z * (far - near))); //small offset + //small bias + minZ = maxZ-0.00004/ld(spos.z); maxZ += stepv.z; } @@ -564,6 +555,15 @@ vec3 newTrace(vec3 dir, vec3 position, float dither, float fresnel){ } #endif */ +vec2 decodeVec2(float a){ + const vec2 constant1 = 65535. / vec2( 256., 65536.); + const float constant2 = 256. / 255.; + return fract( a * constant1 ) * constant2 ; +} + +float ld(float depth) { + return 1.0 / (far+near - depth * far-near); +} void main() { @@ -581,35 +581,14 @@ float depth1 = texture2D(depthtex1, texcoord).x; vec4 fragpos1 = gbufferProjectionInverse * (vec4(texcoord, depth1, 1.0) * 2.0 - 1.0); fragpos1 /= fragpos1.w; vec3 normalfragpos1 = normalize(fragpos1.xyz); - -#ifndef DISTANT_HORIZONS - bool island = !(dot(texture2D(colortex0,texcoord).rgb,vec3(1.0))<0.00000000001 || (depth1 > comp)); //must be depth1 > comp for transparency -#else - float DHdepth0 = texture2D(dhDepthTex0, texcoord).x; - vec4 DHfragpos0 = dhProjectionInverse * (vec4(texcoord, DHdepth0, 1.0) * 2.0 - 1.0); - DHfragpos0 /= DHfragpos0.w; - vec3 DHnormalfragpos0 = normalize(DHfragpos0.xyz); - - float DHdepth1 = texture2D(dhDepthTex1, texcoord).x; - vec4 DHfragpos1 = dhProjectionInverse * (vec4(texcoord, DHdepth1, 1.0) * 2.0 - 1.0); - DHfragpos1 /= DHfragpos1.w; - vec3 DHnormalfragpos1 = normalize(DHfragpos1.xyz); - - bool DH_reflective = DHdepth1 > DHdepth0; - bool island = !(dot(texture2D(colortex0,texcoord).rgb,vec3(1.0))<0.00000000001 || (depth1 > comp)) || (DHdepth1 < depth1); //Fix DH terrain rendering against sky - #ifdef Fog - float dither = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y); - dither = fract(frameTimeCounter * 16.0 + dither); - if(length(fragpos1.xyz) > dither * 32.0 - 16.0 + far) c = mix(c.rgb, hr.rgb*(1.0-rainStrength*0.25), clamp((length(DHfragpos1.xyz) - dhRenderDistance * 0.05) / dhRenderDistance, 0.0, 1.0)); - #endif -#endif - +/*--------------------------------------------------------------------------------------------*/ float mats = texture2D(colortex0,texcoord).b; + vec4 trp = texture2D(gaux3,texcoord.xy); + bool transparency = dot(trp.xyz,trp.xyz) > 0.000001; bool isMetallic = mats > 0.39 && mats < 0.41; bool isPolished = mats > 0.49 && mats < 0.51; - #ifndef polishedRefl isPolished = false; #endif @@ -620,20 +599,18 @@ bool isPolished = mats > 0.49 && mats < 0.51; #ifdef Refraction if (texture2D(colortex2, texcoord).z < 0.2499 && dot(texture2D(colortex2,texcoord).xyz,texture2D(colortex2,texcoord).xyz) > 0.0 || isEyeInWater == 1.0) { //reflective water vec2 wpos = (gbufferModelViewInverse*fragpos0).xz+cameraPosition.xz; - + vec2 refraction = texcoord.xy + calcBump(wpos); float caustics = 0.0; + #ifdef Caustics float skylight = pow(max(lightmap.y-1.0/16.0,0.0)*1.14285714286, 0.5); + //vec2 wposC = (gbufferModelViewInverse*fragpos1).xz+cameraPosition.xz; caustics = calcWaves(wpos*3.0); - caustics = mix(caustics*4.25, 1.0, 1.0-skylight); - caustics = clamp(caustics*causticsStrength, -0.8, 0.2); //adjust color and filter out dark parts + caustics = mix(caustics*4.0, 1.0, 1.0-skylight); + caustics = clamp(caustics*causticsStrength, -1.0, 0.1); //adjust color and filter out dark parts caustics *= (1.0-rainStrength); #endif -#ifdef DISTANT_HORIZONS - if(DH_reflective) wpos = (gbufferModelViewInverse*DHfragpos0).xz+cameraPosition.xz; //should be before caustics but we disable them on DH water anyways - if(length(fragpos1.xyz) > 16.0 + far) caustics *= 0.0; //blend caustics with DH water -#endif - vec2 refraction = texcoord.xy + calcBump(wpos); + c = pow(texture2D(gaux1, refraction).xyz, vec3(2.2) + caustics)*257.0; #ifdef uwatertint if(isEyeInWater == 1.0){ @@ -645,6 +622,8 @@ if (texture2D(colortex2, texcoord).z < 0.2499 && dot(texture2D(colortex2,texcoor } #endif +bool island = !(dot(texture2D(colortex0,texcoord).rgb,vec3(1.0))<0.00000000001 || (depth1 > comp)); //must be depth1 > comp for transparency + if (!island){ //breaks transparency rendering against the sky vec3 cpos = normalize(gbufferModelViewInverse*fragpos1).xyz; #ifdef defskybox @@ -686,14 +665,17 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud fresnel = mix(0.09,1.0,fresnel); //F0 vec3 sky_c = getSkyc(reflectedVector)*metallicSky; - vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector, depthtex1, gbufferProjection, gbufferProjectionInverse); + vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector); reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5; c = mix(c,reflection.rgb,fresnel*metalStrength); } #endif -//if (transparency) { //this broke in iris 1.21.5+ + //Draw entities etc + //c = c*(1.0-texture2D(colortex2, texcoord).a)+texture2D(colortex2, texcoord).rgb; + +if (transparency) { vec3 normal = texture2D(colortex2,texcoord).xyz; float sky = normal.z; @@ -712,15 +694,13 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud normal = max(normalize(decode(normal.xy)),vec3(-1.0)); //Using max to fix issues on widescreens. -#ifndef DISTANT_HORIZONS //draw fog for transparency float iswater2 = float(iswater); float skylight = pow(max(lightmap.y-2.0/16.0,0.0)*1.14285714286, 1.0); c = mix(c, fogC, fogF-fogF) / (1.0 + 5.0*night*iswater2*skylight); if(depth1 < comp)c = mix(hr.rgb*(1.0-rainStrength*0.25), c, exp(-exp2(length(fragpos1.xyz) / far * 16.0 - 14.0))); //chunk border fog through transparency, land only -#endif - //Draw transparency and entities + //Draw transparency vec3 finalAc = texture2D(gaux2, texcoord.xy).rgb; float alphaT = clamp(length(trp.rgb)*1.02,0.0,1.0); @@ -729,7 +709,7 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud /* #if defined waterRefl || defined iceRefl if (reflectiveWater || reflectiveIce) { - vec3 wFragpos1 = ScreenSpace(); + vec3 wFragpos1 = normalize(TAAfragpos); vec3 reflectedVector = reflect(wFragpos1, normal); float normalDotEye = dot(normal, wFragpos1); @@ -772,13 +752,8 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud #endif */ + if (reflectiveWater || reflectiveIce) { - #ifdef DISTANT_HORIZONS - if(DH_reflective){ - normalfragpos0 = DHnormalfragpos0; - fragpos0.xyz = DHfragpos0.xyz; - } - #endif vec3 reflectedVector = reflect(normalfragpos0, normal); float normalDotEye = dot(normal, normalfragpos0); @@ -797,10 +772,7 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud #endif #endif #if defined waterRefl || defined iceRefl - vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector, depthtex1, gbufferProjection, gbufferProjectionInverse); - #ifdef DISTANT_HORIZONS - if(DH_reflective) reflection = raytrace(DHfragpos0.xyz, sky_c, reflectedVector, dhDepthTex1, dhProjection, dhProjectionInverse); - #endif + vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector); #else vec4 reflection = vec4(0.0); #endif @@ -815,14 +787,10 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.85; c = mix(c,reflection.rgb,fresnel); - #ifdef DISTANT_HORIZONS - #ifdef Fog - if(length(fragpos0.xyz) > dither * 32.0 - 16.0 + far) c = mix(c.rgb, hr.rgb*(1.0-rainStrength*0.25), clamp((length(DHfragpos0.xyz) - dhRenderDistance * 0.05) / dhRenderDistance, 0.0, 1.0)); - #endif - #endif } +} bool land = depth0 < comp; #ifdef RainReflections @@ -852,19 +820,31 @@ if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderCloud reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5; c = mix(c.rgb, reflection.rgb, fresnel*iswet); //smooth out wetness start and end + //c.rgb = wnormal; } #endif #if Clouds == 3 - if(!island && rainStrength > 0.01)c = mix(c,fogC,fogF*0.75); //tint vl clouds with fog while raining, changed from land to island check for DH, might cause issues + if(!land && rainStrength > 0.01)c = mix(c,fogC,fogF*0.75); //tint vl clouds with fog while raining #endif +/* +//Draw rain +vec4 rain = texture2D(gaux4, texcoord); +if (rain.r > 0.0001 && rainStrength > 0.01 && !(depth1 < texture2D(depthtex2, texcoord).x)){ + float rainRGB = 0.25; + float rainA = rain.r; + float torch_lightmap = 12.0 - min(rain.g/rain.r * 12.0,11.0); + torch_lightmap = 0.05 / torch_lightmap / torch_lightmap - 0.002595; + + vec3 rainC = rainRGB*(pow(max(dot(normalfragpos0, sunVec)*0.1+0.9,0.0),6.0)*(0.1+tr*0.9)*pow(sunlight,vec3(0.25))*sunVisibility+pow(max(dot(normalfragpos0, -sunVec)*0.05+0.95,0.0),6.0)*48.0*moonlight*moonVisibility)*0.04 + 0.05*rainRGB*length(avgAmbient2); + rainC += max(torch_lightmap,0.0)*vec3(emissive_R,emissive_G,emissive_B); + c = c*(1.0-rainA*0.3)+rainC*1.5*rainA; +} +*/ #ifndef Volumetric_Lighting #ifdef Godrays float sunpos = abs(dot(normalfragpos0,normalize(sunPosition.xyz))); - #ifdef DISTANT_HORIZONS - if(DHdepth1 < depth1) sunpos = abs(dot(DHnormalfragpos0,normalize(sunPosition.xyz))); - #endif float illuminationDecay = pow(sunpos,30.0)+pow(sunpos,16.0)*0.8+pow(sunpos,2.0)*0.125; vec2 deltaTextCoord = (lightPos-texcoord)*0.01; @@ -915,7 +895,6 @@ vec3 vgrC = lightcol*exposure*phase*0.08*(0.25+0.75*tmult*tmult)*tr*(1.0+pow(1.0 c += texture2D(composite,texcoord.xy*0.5+0.5+1.0/vec2(viewWidth,viewHeight)).rgb*fading*30*30/100*pow(dot(texture2D(gaux1, vec2(1.0)/vec2(viewWidth,viewHeight)).w, 1.0), 2.0); #endif -#ifndef DISTANT_HORIZONS #ifdef Fog //Render fog at the end. //land fog @@ -923,8 +902,7 @@ c += texture2D(composite,texcoord.xy*0.5+0.5+1.0/vec2(viewWidth,viewHeight)).rgb //Chunk border fog if(land)c = mix(hr.rgb*(1.0-rainStrength*0.25), c, exp(-exp2(length(fragpos0.xyz) / far * 16.0 - 14.0))); #endif -#endif - + vec3 ufogC = sky1.rgb*0.1; // ufogC.g *= 1.0+2.0*inSwamp; //make fog greenish in swamp biomes ufogC.r *= 0.0; diff --git a/shaders/dh_terrain.fsh b/shaders/dh_terrain.fsh deleted file mode 100644 index 627a4f1..0000000 --- a/shaders/dh_terrain.fsh +++ /dev/null @@ -1,31 +0,0 @@ -#version 120 -/* DRAWBUFFERS:01 */ - -#define gbuffers_terrain -#include "shaders.settings" - -varying vec4 color; -varying vec4 normal; -varying float lmcoord; - -//encode normal in two channel (xy), emissive lightmap (z) and sky lightmap (w), blend mode must be disabled in shaders.properties for this to work without issues. -vec4 encode (vec3 n){ - return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, lmcoord, 1.0); // set sky lightmap to 1 for distant horizons -} - -vec3 RGB2YCoCg(vec3 c){ - return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5); -} - -void main() { - - vec4 cAlbedo = vec4(RGB2YCoCg(color.rgb),color.a); - - bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0)); - cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g; - cAlbedo.b = normal.a; - - gl_FragData[0] = cAlbedo; - gl_FragData[1] = encode(normal.xyz); - -} \ No newline at end of file diff --git a/shaders/dh_terrain.vsh b/shaders/dh_terrain.vsh deleted file mode 100644 index 3db9b6d..0000000 --- a/shaders/dh_terrain.vsh +++ /dev/null @@ -1,43 +0,0 @@ -#version 120 - -#define composite2 -#define gbuffers_terrain -#include "shaders.settings" - -varying vec4 color; -varying vec4 normal; -varying float lmcoord; - -uniform mat4 gbufferModelView; -uniform mat4 gbufferModelViewInverse; - -#ifdef TAA -uniform float viewWidth; -uniform float viewHeight; -vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight); -uniform int framemod8; -const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), - vec2(-1.,3.)/8., - vec2(5.0,1.)/8., - vec2(-3,-5.)/8., - vec2(-5.,5.)/8., - vec2(-7.,-1.)/8., - vec2(3,7.)/8., - vec2(7.,-7.)/8.); -#endif - -void main() { - - lmcoord = gl_MultiTexCoord1.x/255.0; - - normal.a = 0.02; - normal.xyz = normalize(gl_NormalMatrix * gl_Normal); - - color = gl_Color; - - gl_Position = gl_ProjectionMatrix * gbufferModelView * gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex; -#ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; -#endif - -} \ No newline at end of file diff --git a/shaders/dh_water.fsh b/shaders/dh_water.fsh deleted file mode 100644 index f3f40e3..0000000 --- a/shaders/dh_water.fsh +++ /dev/null @@ -1,125 +0,0 @@ -#version 120 - -#define gbuffers_shadows -#define gbuffers_water -#include "shaders.settings" - -varying vec4 color; -varying vec4 ambientNdotL; -varying vec2 lmcoord; - -varying float dist; -varying vec3 viewVector; -varying vec3 worldpos; -varying mat3 tbnMatrix; - -uniform sampler2D noisetex; -uniform sampler2D depthtex0; - -uniform float far; -uniform float viewHeight; -uniform float viewWidth; -uniform float frameTimeCounter; - -vec4 encode (vec3 n,float dif){ - float p = sqrt(n.z*8+8); - - float vis = lmcoord.t; - if (ambientNdotL.a > 0.9) vis = vis * 0.25; - if (ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) vis = vis*0.25+0.25; - if (ambientNdotL.a < 0.1) vis = vis*0.25+0.5; - - return vec4(n.xy/p + 0.5,vis,1.0); -} - -mat2 rmatrix(float rad){ - return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad))); -} - -float calcWaves(vec2 coord, float iswater){ - - if(iswater > 0.9){ - vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.31365)); - - coord *= 0.262144; - vec2 coord0 = coord * rmatrix(1.0) - movement * 4.0; - coord0.y *= 3.0; - vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5; - coord1.y *= 3.0; - vec2 coord2 = coord + movement * 0.5; - coord2.y *= 3.0; - - coord0 *= waveSize; - coord1 *= waveSize; - - float wave = 1.0 - texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves - wave += texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves - wave += sqrt(texture2D(noisetex,coord2 * 0.045).x * 6.5) * 1.33; //noise texture - wave *= 0.0157; - return wave; - } else return sqrt(texture2D(noisetex,coord * 0.5).x) * 0.035; //translucent noise, non water - -} - -vec3 calcBump(vec2 coord, float iswater){ - const vec2 deltaPos = vec2(0.25, 0.0); - - float h0 = calcWaves(coord, iswater); - float h1 = calcWaves(coord + deltaPos.xy, iswater); - float h2 = calcWaves(coord - deltaPos.xy, iswater); - float h3 = calcWaves(coord + deltaPos.yx, iswater); - float h4 = calcWaves(coord - deltaPos.yx, iswater); - - float xDelta = ((h1-h0)+(h0-h2)); - float yDelta = ((h3-h0)+(h0-h4)); - - return vec3(vec2(xDelta,yDelta)*0.5, 0.5); //z = 1.0-0.5 -} - -vec3 calcParallax(vec3 pos, float iswater){ - float getwave = calcWaves(pos.xz - pos.y, iswater); - - pos.xz += (getwave * viewVector.xy) * waterheight; - - return pos; -} - -void main() { - - //Fix DH rendering through terrain, offset for reflections - if(texture2D(depthtex0, gl_FragCoord.xy / vec2(viewWidth, viewHeight)).x < 0.9990) discard; - - float iswater = clamp(ambientNdotL.a*2.0-1.0,0.0,1.0); - - vec4 albedo = color; - albedo.rgb = pow(albedo.rgb,vec3(2.2)); - float texvis = wtexblend; - -#ifndef watertex - texvis = 0.11; - if(iswater > 0.9)albedo.rgb = vec3(waterCR,waterCG,waterCB); -#endif - - //Bump and parallax mapping - vec3 waterpos = worldpos; -#ifdef WaterParallax - waterpos = calcParallax(waterpos, iswater); -#endif - vec3 bump = calcBump(waterpos.xz - waterpos.y, iswater); - vec3 newnormal = normalize(bump * tbnMatrix); - - vec3 fColor = albedo.rgb*(ambientNdotL.rgb); - float alpha = mix(albedo.a,texvis,iswater); - //if(iswater > 0.9)alpha *= waterA; - - float dither = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y); - dither = fract(frameTimeCounter * 16.0 + dither); - - if(dist > dither * 32.0 - 16.0 + far && iswater > 0.9) alpha *= waterA; //blend water transparency - if(dist < dither * 32.0 - 16.0 + far && ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) alpha *= 0.0; //blend ice transparency - -/* DRAWBUFFERS:526 */ - gl_FragData[0] = vec4(fColor,alpha); - gl_FragData[1] = encode(newnormal.xyz, 0.0); - gl_FragData[2] = vec4(normalize(albedo.rgb+0.00001),alpha); -} \ No newline at end of file diff --git a/shaders/dh_water.vsh b/shaders/dh_water.vsh deleted file mode 100644 index 69ad0a2..0000000 --- a/shaders/dh_water.vsh +++ /dev/null @@ -1,167 +0,0 @@ -#version 120 - -#define composite2 -#define gbuffers_shadows -#define gbuffers_water -#define lightingColors -#include "shaders.settings" - -varying vec4 color; -varying vec4 ambientNdotL; -varying vec2 lmcoord; - -varying float dist; -varying vec3 viewVector; -varying vec3 worldpos; -varying mat3 tbnMatrix; - -uniform vec3 cameraPosition; -uniform vec3 sunPosition; -uniform vec3 upPosition; -uniform mat4 gbufferModelView; -uniform mat4 gbufferModelViewInverse; -uniform int worldTime; -uniform float rainStrength; -uniform float nightVision; - -#ifdef Waving_Water -uniform float frameTimeCounter; -const float PI = 3.1415927; -#endif - -const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005), - vec3(0.58597,0.31,0.05), - vec3(0.58597,0.45,0.16), - vec3(0.58597,0.5,0.35), - vec3(0.58597,0.5,0.36), - vec3(0.58597,0.5,0.37), - vec3(0.58597,0.5,0.38)); - -float SunIntensity(float zenithAngleCos, float sunIntensity, float cutoffAngle, float steepness){ - return sunIntensity * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness))); -} - -float luma(vec3 color) { - return dot(color,vec3(0.299, 0.587, 0.114)); -} - -#ifdef TAA -uniform float viewWidth; -uniform float viewHeight; -vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight); -uniform int framemod8; -const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), - vec2(-1.,3.)/8., - vec2(5.0,1.)/8., - vec2(-3,-5.)/8., - vec2(-5.,5.)/8., - vec2(-7.,-1.)/8., - vec2(3,7.)/8., - vec2(7.,-7.)/8.); -#endif - -void main() { - - //pos - vec3 normal = normalize(gl_NormalMatrix * gl_Normal).xyz; - vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex; - worldpos = position.xyz + cameraPosition; - - color = gl_Color; - - lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; - - //Transparency stuff - ambientNdotL.a = 0.0; - float iswater = 1.0; //disable lightmap on water, make light go through instead - if(dhMaterialId == DH_BLOCK_WATER) { - ambientNdotL.a = 1.0; - iswater = 0.0; - #ifdef Waving_Water - float fy = fract(worldpos.y + 0.001); - float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0)) - + 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0)); - position.y += clamp(wave, -fy, 1.0-fy)*waves_amplitude; - #endif - } else ambientNdotL.a = 0.5; - //--- - - gl_Position = gl_ProjectionMatrix * gbufferModelView * position; -#ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; -#endif - //ToD - float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1 - float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12 - float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1 - -#ifdef MC_GL_VENDOR_ATI - vec3 sunlight = vec3(1.0); //Time of day calculation breaks water on amd drivers 18.8.1, last working driver was 18.6.1, causes heavy flickering. TESTED ON RX460 -#else - vec3 sunlight = mix(ToD[int(cmpH)], ToD[int(cmpH1)], fract(hour)); -#endif - sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked. - sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors. - //--- - - //lightmap - float torch_lightmap = 16.0-min(15.0,(lmcoord.s-0.5/16.0)*16.0*16.0/15.0); - float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0); - torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0); - torch_lightmap *= iswater; - vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap*0.2; - //--- - - //light bounce - vec3 sunVec = normalize(sunPosition); - vec3 upVec = normalize(upPosition); - - vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec)); - - float cutoffAngle = 1.608; - float steepness = 1.5; - float cosSunUpAngle = dot(sunVec, upVec) * 0.95 + 0.05; //Has a lower offset making it scatter when sun is below the horizon. - float sunE = SunIntensity(cosSunUpAngle, 1000.0, cutoffAngle, steepness); // Get sun intensity based on how high in the sky it is - - float NdotL = dot(normal,sunVec); - float NdotU = dot(normal,upVec); - - vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother - float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0); - visibility = pow(clamp(visibility+0.15,0.0,0.3)/0.3,vec2(4.4)); - sunlight = sunlight/luma(sunlight)*sunE*0.0075*0.075*3.*visibility.x; - - float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286; - float SkyL2 = skyL*skyL; - float skyc2 = mix(1.0,SkyL2,skyL); - - vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25); - bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8); - - vec3 ambientC = mix(vec3(0.3, 0.5, 1.1),vec3(0.08,0.1,0.1),rainStrength)*length(sunlight)*bounced.w; - ambientC += 0.25*sunlight*(bounced.x + bounced.z)*(0.03+tr*0.17)/0.4*(1.0-rainStrength*0.98) + length(sunlight)*0.2*(1.0-rainStrength*0.9); - ambientC += sunlight*(NdotL*0.5+0.45)*visibility.x*(1.0-tr)*(1.0-tr)*4.*(1.0-rainStrength*0.98); - - //lighting during night time - const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078); - vec3 moon_ambient = (moonlight*2.0 + moonlight*bounced.y)*(4.0-rainStrength*0.95)*0.2; - vec3 moonC = (moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65); - - float wminlight = (nightVision > 0.01)? 0.075: 0.00008; - ambientNdotL.rgb = ambientC*SkyL2*0.3 + moonC + emissiveLightC + wminlight; - - //sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr; - sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition - //--- - - vec3 binormal = normalize(gbufferModelView[2].xyz); - vec3 tangent = normalize(gbufferModelView[0].xyz); - - tbnMatrix = mat3(tangent.x, binormal.x, normal.x, - tangent.y, binormal.y, normal.y, - tangent.z, binormal.z, normal.z); - - dist = length(gl_ModelViewMatrix * gl_Vertex); - viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz; - viewVector.xy = viewVector.xy / dist * 8.25; -} \ No newline at end of file diff --git a/shaders/final.fsh b/shaders/final.fsh index ed006f2..42d5d82 100644 --- a/shaders/final.fsh +++ b/shaders/final.fsh @@ -1,14 +1,4 @@ #version 120 -/* -Sildur's Vibrant Shaders: -https://www.patreon.com/Sildur -https://sildurs-shaders.github.io/ -https://twitter.com/SildurFX - -Permissions: -You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours. -*/ - #define final #include "shaders.settings" @@ -137,6 +127,7 @@ const float centerDepthHalflife = 2.0f; #endif #ifdef Cloudsblur +float comp = 1.0-near/far/far; vec3 cblur(vec2 tc){ float pw = 1.0 / viewWidth; float getdist = 1.0-(exp(-pow(ld(texture2D(depthtex1, tc).r)/256.0*far,4.0)*4.0)); @@ -247,10 +238,12 @@ float rainlens = 0.0; vec2 newTC = clamp(texcoord + fake_refract * 0.01 * (rainlens+isEyeInWater*0.2),1.0/vec2(viewWidth,viewHeight),1.0-1.0/vec2(viewWidth,viewHeight)); vec3 color = texture2D(gaux4, newTC.xy).rgb*50.0; -#ifndef DISTANT_HORIZONS - #ifdef Cloudsblur - if(depth1 >= 1.0)color.rgb = cblur(newTC.xy); - #endif +#ifdef Cloudsblur +#if defined MC_GL_VENDOR_ATI || defined MC_OS_LINUX + color.rgb = cblur(newTC.xy); //checking only for sky causes weird outlines on amd cards and linux drivers +#else + if(depth1 > comp)color.rgb = cblur(newTC.xy); +#endif #endif #ifdef Depth_of_Field diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 2589b5e..52542f8 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -1,9 +1,4 @@ #Global Settings - -# The DH shadow pass is automatically enabled. It can be turned on or off with the shader property dhShadow.enabled. -# Distant Horizons has no set shadow distance; all chunks will be rendered. -dhShadow.enabled=false - # Enable or disable old hand light # Backwards compatibility for shader packs not supporting main and off hand. # When enabled uses the handheld item with higher light value for the main hand. diff --git a/shaders/shaders.settings b/shaders/shaders.settings index 13cdb0e..545dd08 100644 --- a/shaders/shaders.settings +++ b/shaders/shaders.settings @@ -1,11 +1,6 @@ /* -Sildur's Vibrant Shaders: -https://www.patreon.com/Sildur +Thank you for downloading Sildur's vibrant shaders, make sure you got it from the official source found here: https://sildurs-shaders.github.io/ -https://twitter.com/SildurFX - -Permissions: -You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours. */ #ifdef composite0 @@ -23,9 +18,8 @@ You are not allowed to edit, copy code or share my shaderpack under a different #define Godrays const int grays_sample = 23; //17=lite, 17=med, 20=high, 23=extreme -#ifndef DISTANT_HORIZONS //#define Volumetric_Lighting //Disable godrays before enabling volumetric lighting. -#endif + //#define Lens_Flares //#define Celshading //Cel shades everything, making it look somewhat like Borderlands. Zero performance impact. @@ -73,9 +67,7 @@ You are not allowed to edit, copy code or share my shaderpack under a different #define Godrays_Density 1.15 //[0.575 1.15 2.3 4.6 9.2] //#define Lens_Flares -#ifndef DISTANT_HORIZONS - //#define Volumetric_Lighting //Disable godrays before enabling volumetric lighting. -#endif + //#define Volumetric_Lighting //Disable godrays before enabling volumetric lighting. #define VL_amount 1.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] Adjust volumetric lighting amount. #define Fog //Toggle fog