diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index d95c206..b5c6c22 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -243,7 +243,7 @@ void main() { #endif vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0)); - color *= vl.a; + if (TranslucentShader.a > 0.0){ #ifdef Glass_Tint @@ -257,6 +257,7 @@ void main() { #endif } + //cave fog #ifdef Cave_fog if (isEyeInWater == 0){ @@ -274,6 +275,7 @@ void main() { vl.a *= fogfade*0.7+0.3 ; } + color *= vl.a; color += vl.rgb; // bloomy rain effect diff --git a/shaders/lib/diffuse_lighting.glsl b/shaders/lib/diffuse_lighting.glsl index f7a9a79..3128987 100644 --- a/shaders/lib/diffuse_lighting.glsl +++ b/shaders/lib/diffuse_lighting.glsl @@ -7,26 +7,26 @@ vec3 DoAmbientLighting (vec3 SkyColor, vec3 TorchColor, vec2 Lightmap, float sky // Lightmap.y = 1.0; + // old torchlight curves // vec3 TorchLight = TorchColor * pow(1.0-pow(1.0-clamp(Lightmap.x,0.0,1.0) ,0.1),2); // TorchLight = clamp(exp(TorchLight * 30) - 1.0,0.0,5.0); // TorchLight *= TORCH_AMOUNT; - // SkyColor = SkyColor * 2.0 * ambient_brightness; - // vec3 SkyLight = max((SkyColor * 8./150./3.) * min(pow(Lightmap.y,3.0),1.0) , vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)) ; - float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1)); TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5; //pow(TorchLM/4.5,10)*2.5 + pow(Lightmap.x,1.5)*0.5; vec3 TorchLight = TorchColor * TorchLM * 0.75; TorchLight *= TORCH_AMOUNT; - - float skyLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.y)),5.0)+0.1)); - skyLM = pow(skyLM/4,10) + pow(Lightmap.y,1.5)*0.5; + // old skylight curves + // SkyColor = (SkyColor * 2.0 * ambient_brightness) * 8./150./3.; + // vec3 SkyLight = max(SkyColor * min(pow(Lightmap.y,3.0),1.0), vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)) ; - SkyColor = SkyColor * ambient_brightness; - vec3 SkyLight = max((SkyColor * skyLM * 0.75) * 8./150./3., vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)); + SkyColor = (SkyColor * 2.0 * ambient_brightness) * 8./150./3.; + float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5)*0.5)*0.5; + vec3 SkyLight = max(SkyColor * skyLM, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)); + return SkyLight * skyLightDir + TorchLight; } diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index 3eceeaa..37c95e5 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -121,6 +121,8 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool float maxZ = spos.z; spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; + float depthcancle = pow(1.0-(quality/reflection_quality),5); + float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases for (int i = 0; i <= int(quality); i++) { @@ -133,7 +135,7 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool spos += stepv; //small bias - float biasamount = 0.0002 / dist; + float biasamount = max(0.0002, depthcancle*0.0035) / dist; if(hand) biasamount = 0.01; minZ = maxZ-biasamount / ld(spos.z); maxZ += stepv.z; @@ -145,6 +147,35 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool return vec3(1.1); } +float xonk_fma(float a,float b,float c){ + return a * b + c; +} + +//// thank you Zombye | the paper: https://ggx-research.github.io/publication/2023/06/09/publication-ggx.html +vec3 SampleVNDFGGX( + vec3 viewerDirection, // Direction pointing towards the viewer, oriented such that +Z corresponds to the surface normal + vec2 alpha, // Roughness parameter along X and Y of the distribution + vec2 xy // Pair of uniformly distributed numbers in [0, 1) +) { + // Transform viewer direction to the hemisphere configuration + viewerDirection = normalize(vec3(alpha * viewerDirection.xy, viewerDirection.z)); + + // Sample a reflection direction off the hemisphere + const float tau = 6.2831853; // 2 * pi + float phi = tau * xy.x; + float cosTheta = xonk_fma(1.0 - xy.y, 1.0 + viewerDirection.z, -viewerDirection.z); + float sinTheta = sqrt(clamp(1.0 - cosTheta * cosTheta, 0.0, 1.0)*0.25); + vec3 reflected = vec3(vec2(cos(phi), sin(phi)) * sinTheta, cosTheta); + + // Evaluate halfway direction + // This gives the normal on the hemisphere + vec3 halfway = reflected + viewerDirection; + + // Transform the halfway direction back to hemiellispoid configuation + // This gives the final sampled normal + return normalize(vec3(alpha * halfway.xy, halfway.z)); +} + vec3 sampleGGXVNDF(vec3 V_, float roughness, float U1, float U2){ // stretch view vec3 V = normalize(vec3(roughness * V_.x, roughness * V_.y, V_.z)); @@ -222,7 +253,8 @@ void MaterialReflections( #ifdef Rough_reflections int seed = frameCounter%40000; vec2 ij = fract(R2_samples_spec(seed) + noise.rg) ; - vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y); + // vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y); + vec3 H = SampleVNDFGGX(normSpaceView, vec2(roughness), ij.xy); if(hand) H = normalize(vec3(0.0,0.0,1.0)); #else @@ -257,12 +289,12 @@ void MaterialReflections( // #ifdef SCREENSHOT_MODEFconst // float rayQuality = reflection_quality; // #else - float rayQuality = mix_float(reflection_quality,4.0,luma(rayContrib)); // Scale quality with ray contribution + float rayQuality = mix_float(reflection_quality,6.0,luma(rayContrib)); // Scale quality with ray contribution // #endif // float rayQuality = reflection_quality; - vec3 rtPos = rayTraceSpeculars(mat3(gbufferModelView) * L, fragpos.xyz, noise.b, reflection_quality, hand, reflectLength); + vec3 rtPos = rayTraceSpeculars(mat3(gbufferModelView) * L, fragpos.xyz, noise.b, rayQuality, hand, reflectLength); float LOD = clamp(reflectLength * 6.0, 0.0,6.0); diff --git a/shaders/lib/volumetricFog.glsl b/shaders/lib/volumetricFog.glsl index 535682a..c71cec5 100644 --- a/shaders/lib/volumetricFog.glsl +++ b/shaders/lib/volumetricFog.glsl @@ -280,7 +280,7 @@ vec4 InsideACloudFog( vec3 rainRays = ((Fog_SunCol/5)*Shadows_for_Fog) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1.0) * rainStrength * noPuddleAreas * RainFog_amount; vec3 CaveRays = (Fog_SunCol*Shadows_for_Fog) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.); - vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ; + vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. ; color += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*total_extinction; total_extinction *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));