From 74fc47d4e2ffc3435f4035a8312185665d118c47 Mon Sep 17 00:00:00 2001 From: Xonk Date: Sun, 23 Jul 2023 00:07:10 -0400 Subject: [PATCH] redid underwater visuals. more gameplay friendly and looks better. --- shaders/composite1.fsh | 83 +++++++-------- shaders/composite2.fsh | 154 ++++++++++++++++++++------- shaders/composite3.fsh | 22 ++-- shaders/gbuffers_all_translucent.fsh | 12 +-- shaders/world-1/composite2.fsh | 2 +- 5 files changed, 177 insertions(+), 96 deletions(-) diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 8dea77b..132e715 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -254,20 +254,23 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE float maxZ = min(rayLength,12.0)/(1e-8+rayLength); dV *= maxZ; + rayLength *= maxZ; float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; estEndDepth *= maxZ; estSunDepth *= maxZ; - vec3 absorbance = vec3(1.0); - vec3 vL = vec3(0.0); - - float phase = phaseg(VdotL,0.7) * 1.5 + 0.1; - vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz; vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); + // float phase = (phaseg(VdotL,0.5) + phaseg(VdotL,0.8)) ; + float phase = (phaseg(VdotL,0.6) + phaseg(VdotL,0.8)) * 0.5; + // float phase = phaseg(VdotL, 0.7); + + vec3 absorbance = vec3(1.0); + vec3 vL = vec3(0.0); + float expFactor = 11.0; for (int i=0;i 0.0){ #ifdef Glass_Tint @@ -296,11 +296,21 @@ void main() { // underwater fog if (isEyeInWater == 1){ - float fogfade = clamp( exp(length(fragpos) / -10) ,0.0,1.0); - color.rgb = color.rgb * fogfade ; - vl.a *= fogfade ; + 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); + + color.rgb *= fogfade ; + bloomyFogMult *= 0.4; } + // apply VL fog to the scene color *= vl.a; color += vl.rgb; @@ -316,7 +326,7 @@ void main() { /// powdered snow if (isEyeInWater == 3){ color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.)); - vl.a = 0.0; + bloomyFogMult = 0.0; } // blidnesss @@ -331,7 +341,7 @@ void main() { if(luma(thingy) > 0.0 ) color.rgb = thingy; #endif - gl_FragData[0].r = vl.a; // pass fog alpha so bloom can do bloomy fog + 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); diff --git a/shaders/gbuffers_all_translucent.fsh b/shaders/gbuffers_all_translucent.fsh index 622f815..5525ad1 100644 --- a/shaders/gbuffers_all_translucent.fsh +++ b/shaders/gbuffers_all_translucent.fsh @@ -324,7 +324,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize #ifdef PhysicsMod_support if(physics_iterationsNormal < 1.0){ #endif - float bumpmult = 1.; + float bumpmult = 1.0; vec3 bump = vec3(0); vec3 posxz = p3+cameraPosition; @@ -457,15 +457,12 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize vec3 reflectedVector = reflect(normalize(fragpos), normal); float normalDotEye = dot(normal, normalize(fragpos)); float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0); - // float unchangedfresnel = fresnel; - + // snells window looking thing - if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0); - #ifdef PhysicsMod_support if(isEyeInWater == 1 && physics_iterationsNormal > 0.0) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0); #else - if(isEyeInWater == 1) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0); + if(isEyeInWater == 1 ) fresnel = pow(clamp(1.66 + normalDotEye,0.0,1.0), 25.0); #endif fresnel = mix(f0, 1.0, fresnel); @@ -475,8 +472,9 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize // SSR, Sky, and Sun reflections #ifdef WATER_BACKGROUND_SPECULAR SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 30.0; - // SkyReflection = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)/ + if(isEyeInWater == 1) SkyReflection = vec3(0.0); #endif + #ifdef WATER_SUN_SPECULAR SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0)); #endif diff --git a/shaders/world-1/composite2.fsh b/shaders/world-1/composite2.fsh index 4c37c84..cc30efc 100644 --- a/shaders/world-1/composite2.fsh +++ b/shaders/world-1/composite2.fsh @@ -464,7 +464,7 @@ void main() { #ifdef Specular_Reflections - MaterialReflections_N(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand); + MaterialReflections_N(gl_FragData[0].rgb, SpecularTex.r, vec3(SpecularTex.g), albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand); #endif Emission(gl_FragData[0].rgb, albedo, SpecularTex.a);