remake and improve underwater lighting. add new method for indirect SSS. improve nametag rendering. fix translucent rendering on DH LODs. begin work on WIP cloud raymarcher

This commit is contained in:
Xonk
2025-01-15 23:08:16 -05:00
parent 5d0ff0856f
commit 6c41c008c0
24 changed files with 701 additions and 693 deletions

View File

@ -23,7 +23,7 @@ void GriAndEminShadowFix(
// stop lightleaking by zooming up, centered on blocks
vec2 scale = vec2(0.5); scale.y *= 0.5;
vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y*0.1);
if(SkyLightmap < 0.1 && isEyeInWater != 1 && VanillaAO > 0.0) Bias = zoomShadow;
if(SkyLightmap < 0.1 && isEyeInWater != 1) Bias = zoomShadow;
WorldPos += Bias;
}

View File

@ -92,50 +92,6 @@ vec4 BilateralUpscale_SSAO(sampler2D tex, sampler2D depth, vec2 coord, float ref
return RESULT / SUM;
}
float ScreenSpace_SSS(
vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise
){
if(hand) return 0.0;
int samples = 7;
float occlusion = 0.0;
float sss = 0.0;
float dist = 1.0 + clamp(viewPos.z*viewPos.z/50.0,0,5); // shrink sample size as distance increases
float mulfov2 = gbufferProjection[1][1]/(3 * dist);
float maxR2_2 = viewPos.z*viewPos.z*mulfov2*2.*2./50.0;
float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1);
if(leaves) maxR2_2 = mix(10, maxR2_2, dist3);
vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ;
int n = 0;
for (int i = 0; i < samples; i++) {
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2;
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE);
if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) {
vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize, texelFetch2D(depthtex1, offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) );
vec3 vec = (t0.xyz - viewPos);
float dsquared = dot(vec, vec);
if (dsquared > 1e-5){
if(dsquared > maxR2_2){
float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.);
sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0);
}
n += 1;
}
}
}
return max(1.0 - sss/n, 0.0);
}
////////////////////////////////////////////////////////////////////
///////////////////////////// RTAO/SSGI ////////////////////////
////////////////////////////////////////////////////////////////////
@ -177,51 +133,7 @@ vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
}
return vec3(1.1);
}
// vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
// vec3 clipPosition = toClipSpace3(position);
// float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
// (-near -position.z) / dir.z : far*sqrt(3.);
// vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space
// direction.xy = normalize(direction.xy);
// //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(RENDER_SCALE,1.0);
// vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0);
// spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE ;
// spos += stepv*dither;
// float minZ = spos.z;
// float maxZ = spos.z;
// for(int i = 0; i < int(quality); i++){
// if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1);
// #ifdef UseQuarterResDepth
// float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0));
// #else
// float sp = texelFetch2D(depthtex1,ivec2(spos.xy/ texelSize),0).r;
// #endif
// float currZ = linZ(spos.z);
// float nextZ = linZ(sp);
// if(nextZ < currZ && (sp <= max(minZ,maxZ) && sp >= min(minZ,maxZ))) return vec3(spos.xy/RENDER_SCALE,sp);
// float biasamount = 0.00005;
// minZ = maxZ - biasamount / currZ;
// maxZ += stepv.z;
// spos += stepv;
// }
// return vec3(1.1);
// }
float convertHandDepth_3(in float depth, bool hand) {
if(!hand) return depth;
@ -229,6 +141,7 @@ float convertHandDepth_3(in float depth, bool hand) {
ndcDepth /= MC_HAND_DEPTH;
return ndcDepth * 0.5 + 0.5;
}
vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes, bool hand){
float dist = 1.0 + clamp(position.z*position.z,0,2); // shrink sample size as distance increases
@ -305,9 +218,13 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha
vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(noise-0.5);
spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE;
float ascribeAmount = 255.0 * 1.0 * (1.0 / viewHeight) * gbufferProjectionInverse[1].y;
float minZ = spos.z;
float maxZ = spos.z;
CURVE = 0.0;
bool intersected = false;
for(int i = 0; i < iterations; i++){
if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1);
@ -324,11 +241,11 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha
float biasamount = 0.00005;
minZ = maxZ-biasamount / currZ;
minZ = maxZ;
maxZ += stepv.z;
spos += stepv;
CURVE += 1.0/iterations;
}
return vec3(1.1);
@ -384,7 +301,7 @@ vec3 ApplySSRT(
#endif
#else
#ifdef OVERWORLD_SHADER
skycontribution = unchangedIndirect * (max(rayDir.y,pow(1.0-lightmap,2))*0.95+0.05);
skycontribution = unchangedIndirect;// * (max(rayDir.y,pow(1.0-lightmap,2))*0.95+0.05);
#endif
#endif

View File

@ -11,15 +11,15 @@
#define WATER_WAVE_SPEED 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define Dirt_Amount 0.14 // [0.0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1.0 1.04 1.08 1.12 1.16 1.2 1.24 1.28 1.32 1.36 1.4 1.44 1.48 1.52 1.56 1.6 1.64 1.68 1.72 1.76 1.8 1.84 1.88 1.92 1.96 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
#define Dirt_Scatter_R 0.6 // [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 ]
#define Dirt_Scatter_G 0.9 // [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 ]
#define Dirt_Scatter_B 0.9 // [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 ]
#define Dirt_Scatter_R 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 ]
#define Dirt_Scatter_G 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 ]
#define Dirt_Scatter_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 ]
#define Dirt_Absorb_R 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define Dirt_Absorb_G 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define Dirt_Absorb_B 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define Water_Absorb_R 0.25 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
#define Water_Absorb_G 0.05 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
#define Water_Absorb_B 0.01 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
#define Water_Absorb_R 0.392389 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define Water_Absorb_G 0.108329 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define Water_Absorb_B 0.0660636 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
#define MINIMUM_WATER_ABSORBANCE -1 // [-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 60 70 80 90 100]
#define rayMarchSampleCount 2 // [1 2 3 4 6 8 12 16 32 64]
@ -209,7 +209,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.
#undef DISTANT_HORIZONS
#endif
#define SEA_LEVEL 70 // [0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190]
#define SEA_LEVEL 62 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
//////////////////////////////////////////////////////
// ----- BIOME SPECIFIC ENVIORNMENTS SETTINGS ----- //
@ -714,6 +714,10 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
// #define PLANET_CURVATURE
#define CURVATURE_AMOUNT 1.0 // [-10.0 -9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 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 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
// #define OLD_INDIRECT_SSS
#define DIMENSION_FALLBACK_SHADER 0 // [0 1 2 3]
///////////////////////////////////////////
// ----- DISTANT HORIZONS SETTINGS ----- //
///////////////////////////////////////////

View File

@ -1,31 +1,3 @@
// 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.);
vec3 lerp(vec3 X, vec3 Y, float A){
return X * (1.0 - A) + Y * A;
}
float lerp(float X, float Y, float A){
return X * (1.0 - A) + Y * A;
}
float square(float x){
return x*x;
}
// vec3 toClipSpace3(vec3 viewSpacePosition) {
// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
// }
float invLinZ (float lindepth){
return -((2.0*near/lindepth)-far-near)/(far-near);
}
@ -120,22 +92,10 @@ float shlickFresnelRoughness(float XdotN, float roughness){
float shlickFresnel = clamp(1.0 + XdotN,0.0,1.0);
// shlickFresnel = pow(1.0-pow(1.0-shlickFresnel, mix(1.0,2.1,roughness)), mix(5.0,3.0,roughness));
// shlickFresnel = mix(0.0, mix(1.0,0.065,1-pow(1-roughness,3.5)), shlickFresnel);
// float curves = 1.0-exp(-1.3*roughness);
// float brightness = 1.0-exp(-4.0*roughness);
float curves = exp(-4.0*pow(1-(roughness),2.5));
float brightness = exp(-3.0*pow(1-sqrt(roughness),3.50));
shlickFresnel = pow(1.0-pow(1.0-shlickFresnel, mix(1.0, 1.9, curves)),mix(5.0, 2.6, curves));
shlickFresnel = mix(0.0, mix(1.0,0.065, brightness) , clamp(shlickFresnel,0.0,1.0));
return shlickFresnel;
@ -159,15 +119,13 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo
vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(dither-0.5);
#ifndef FORWARD_SPECULAR
#ifdef DEFERRED_SPECULAR
spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
#endif
float minZ = spos.z;
float maxZ = spos.z;
for (int i = 0; i <= int(quality); i++) {
float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0));
@ -344,14 +302,6 @@ vec3 specularReflections(
bool isMetal = f0 > 229.5/255.0;
// #ifndef FORWARD_SPECULAR
// // underwater, convert from f0 air, to ior, then back to f0 water
// if(!isMetal || isWater){
// f0 = 2.0 / (1.0 - sqrt(f0)) - 1.0;
// f0 = clamp(pow((1.33 - f0) / (1.33 + f0), 2.0),0.0,1.0);
// }
// #endif
// get reflected vector
mat3 basis = CoordBase(normal);
vec3 viewDir = -playerPos*basis;
@ -397,6 +347,8 @@ vec3 specularReflections(
vec3 backgroundReflection = volumetricsFromTex(reflectedVector_L, colortex4, roughness).rgb / 1200.0;
#else
vec3 backgroundReflection = skyCloudsFromTex(reflectedVector_L, colortex4).rgb / 1200.0;
if(isEyeInWater == 1) backgroundReflection *= exp(-vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B) * 15.0)*2;
#endif
#endif
@ -411,6 +363,7 @@ vec3 specularReflections(
// composite all the different reflections together
#if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION
specularReflections = mix(DarkenedDiffuseLighting, backgroundReflection, lightmap);
#endif
@ -431,155 +384,4 @@ vec3 specularReflections(
#endif
return specularReflections;
}
/*
void DoSpecularReflections(
inout vec3 Output,
vec3 FragPos, // toScreenspace(vec3(screenUV, depth)
vec3 WorldPos,
vec3 LightPos, // should be in world space
vec2 Noise, // x = bluenoise z = interleaved gradient noise
vec3 Normal, // normals in world space
float Roughness, // red channel of specular texture _S
float F0, // green channel of specular texture _S
vec3 Albedo,
vec3 Diffuse, // should contain the light color and NdotL. and maybe shadows.
float Lightmap, // in anything other than world0, this should be 1.0;
bool Hand // mask for the hand
){
vec3 Final_Reflection = Output;
vec3 Background_Reflection = Output;
vec3 Lightsource_Reflection = vec3(0.0);
vec4 SS_Reflections = vec4(0.0);
float reflectLength = 0.0;
Lightmap = clamp((Lightmap-0.8)*7.0, 0.0,1.0);
Roughness = 1.0 - Roughness; Roughness *= Roughness;
F0 = F0 == 0.0 ? 0.02 : F0;
// F0 = 230.0/255.0;
// Roughness = 0.0;
// F0 = 230.0/255.0;
bool isMetal = F0 > 229.5/255.0;
// underwater, convert from f0 air, to ior, then back to f0 water
// if(!isMetal){
// F0 = 2.0 / (1.0 - sqrt(F0)) - 1.0;
// F0 = clamp(pow((1.33 - F0) / (1.33 + F0), 2.0),0.0,1.0);
// }
// Roughness = 0.0;
mat3 Basis = CoordBase(Normal);
vec3 ViewDir = -WorldPos*Basis;
#ifdef Rough_reflections
vec3 SamplePoints = SampleVNDFGGX(ViewDir, Roughness, Noise.xy);
// vec3 SamplePoints = SampleVNDFGGX(ViewDir, vec2(0.1), Noise.x);
if(Hand) SamplePoints = vec3(0.0,0.0,1.0);
#else
vec3 SamplePoints = vec3(0.0,0.0,1.0);
#endif
vec3 Ln = reflect(-ViewDir, SamplePoints);
vec3 L = Basis * Ln;
float Fresnel = pow(clamp(1.0 + dot(-Ln, SamplePoints),0.0,1.0),5.0); // Schlick's approximation
// F0 < 230 dialectrics
// F0 >= 230 hardcoded metal f0
// F0 == 255 use albedo for f0
Albedo = F0 == 1.0 ? sqrt(Albedo) : Albedo;
vec3 metalAlbedoTint = isMetal ? Albedo : vec3(1.0);
// metalAlbedoTint = vec3(1.0);
// get F0 values for hardcoded metals.
vec3 hardCodedMetalsF0 = F0 == 1.0 ? Albedo : HCM_F0[int(max(F0*255.0 - 229.5,0.0))];
vec3 reflectance = isMetal ? hardCodedMetalsF0 : vec3(F0);
vec3 f0 = (reflectance + (1.0-reflectance) * Fresnel) * metalAlbedoTint;
// reflectance = mix(vec3(F0), vec3(1.0), Fresnel);
// vec3 reflectance = mix(R0, vec3(1.0), Fresnel); // ensure that when the angle is 0 that the correct F0 is used.
// #ifdef Rough_reflections
// if(Hand) Fresnel = Fresnel * pow(1.0-Roughness,F0 > 229.5/255.0 ? 1.0 : 3.0);
// #else
// Fresnel = Fresnel * pow(1.0-Roughness,3.0);
// #endif
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 ? normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3) : vec3(1.0);
// vec3 Metals = F0 > 229.5/255.0 ? Albedo : vec3(1.0);
// --------------- BACKGROUND REFLECTIONS
// apply background reflections to the final color. make sure it does not exist based on the lightmap
#ifdef Sky_reflection
#ifdef OVERWORLD_SHADER
if(hasReflections) Background_Reflection = (skyCloudsFromTex(L, colortex4).rgb / 1200.0) ;
#else
if(hasReflections) Background_Reflection = (volumetricsFromTex(L, colortex4, sqrt(Roughness) * 6.0).rgb / 1200.0) ;
#endif
// take fresnel and lightmap levels into account and write to the final color
// the minimum color being the output is for when the background reflection color is close to dark, it will fallback to a dimmed diffuse
// Final_Reflection = mix(Output, Background_Reflection, Lightmap * reflectance);
Final_Reflection = mix(Output, mix(isMetal ? vec3(0.0) : Output, Background_Reflection, f0 * Lightmap), Lightmap);
// Final_Reflection = Background_Reflection * reflectance;
#endif
// --------------- SCREENSPACE REFLECTIONS
// apply screenspace reflections to the final color and mask out background reflections.
#ifdef Screen_Space_Reflections
if(hasReflections){
float SSR_Quality =reflection_quality;// mix(6.0, reflection_quality, Fresnel); // Scale quality with fresnel
vec3 RaytracePos = rayTraceSpeculars(mat3(gbufferModelView) * L, FragPos, Noise.y, float(SSR_Quality), Hand, reflectLength);
float LOD = clamp(pow(reflectLength, pow(1.0-sqrt(Roughness),5.0) * 3.0) * 6.0, 0.0, 6.0); // use higher LOD as the reflection goes on, to blur it. this helps denoise a little.
// float LOD = clamp((1-pow(clamp(1.0-reflectLength,0,1),5.0)) * 6.0, 0.0, 6.0); // use higher LOD as the reflection goes on, to blur it. this helps denoise a little.
if(Roughness <= 0.0) LOD = 0.0;
// LOD = 0.0;
if (RaytracePos.z < 1.0){
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(RaytracePos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) {
SS_Reflections.a = 1.0;
SS_Reflections.rgb = texture2DLod(colortex5, previousPosition.xy, LOD).rgb;
}
}
// make sure it takes the fresnel into account for SSR.
SS_Reflections.rgb = mix(isMetal ? vec3(0.0) : Output, SS_Reflections.rgb, f0);
// occlude the background with the SSR and write to the final color.
Final_Reflection = mix(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a);
}
#endif
// --------------- LIGHTSOURCE REFLECTIONS
// slap the main lightsource reflections to the final color.
#ifdef LIGHTSOURCE_REFLECTION
Lightsource_Reflection = Diffuse * GGX(Normal, -WorldPos, LightPos, Roughness, reflectance, metalAlbedoTint) * Sun_specular_Strength;
Final_Reflection += Lightsource_Reflection;
#endif
Output = Final_Reflection;
// Output = exp(-100 * (reflectLength*reflectLength*reflectLength)) * vec3(1.0);
}
*/
}

View File

@ -351,11 +351,14 @@ vec3 getRayOrigin(
float minHeight,
float maxHeight
){
vec3 cloudDist = vec3(1.0); cloudDist.xz = vec2(25.0);
// allow passing through/above/below the plane without limits
float flip = mix(max(cameraPos.y - maxHeight,0.0), max(minHeight - cameraPos.y,0.0), clamp(rayStartPos.y,0.0,1.0));
// orient the ray to be a flat plane facing up/down
vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/abs(rayStartPos.y)) * flip;
// vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/abs(rayStartPos.y)) * flip;
vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/length(rayStartPos/cloudDist)) * flip;
return position;
}
@ -382,7 +385,7 @@ vec4 GetVolumetricClouds(
float heightRelativeToClouds = clamp(1.0 - max(cameraPosition.y - minHeight,0.0) / 100.0 ,0.0,1.0);
#if defined DISTANT_HORIZONS
float maxdist = dhFarPlane;
float maxdist = dhFarPlane - 16.0;
#else
float maxdist = far + 16.0*5.0;
#endif
@ -402,7 +405,9 @@ vec4 GetVolumetricClouds(
// int samples = 30;
///------- setup the ray
vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples);
vec3 cloudDist = vec3(1.0); cloudDist.xz *= 25.0;
// vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples);
vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
vec3 rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
///------- do color stuff outside of the raymarcher loop
@ -419,6 +424,8 @@ vec4 GetVolumetricClouds(
// sunScattering *= rayleighScatter;
float distanceFade = 1.0 - clamp(exp2(pow(abs(distanceEstimation.y),1.5) * -100.0),0.0,1.0)*heightRelativeToClouds;
distanceFade = 1.0;
// - pow(1.0-clamp(signedSunVec.y,0.0,1.0),5.0)
skyScattering *= mix(1.0, 2.0, distanceFade);
sunScattering *= distanceFade;
@ -439,7 +446,7 @@ vec4 GetVolumetricClouds(
minHeight = CloudLayer1_height;
maxHeight = cloudheight + minHeight;
rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples);
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM);
@ -453,7 +460,7 @@ vec4 GetVolumetricClouds(
minHeight = CloudLayer2_height;
maxHeight = cloudheight + minHeight;
rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y));
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist));
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM);