From deb49da793819f7c55057a558afa0f0239645758 Mon Sep 17 00:00:00 2001 From: Xonk Date: Mon, 26 Jun 2023 00:33:31 -0400 Subject: [PATCH] add ambient light that takes clouds into account, clean up Deferred programs, clean up unused texture calls for LUT, make sure fog and stuff are all using the right LUT colors. fix clouds not being in reflections thats a good days work --- shaders/composite1.fsh | 34 +++--- shaders/composite1.vsh | 12 ++- shaders/composite2.fsh | 18 ++-- shaders/composite2.vsh | 11 +- shaders/composite3.fsh | 19 +++- shaders/composite3.vsh | 5 +- shaders/deferred.fsh | 101 +++++------------- shaders/deferred.vsh | 172 +++++++++--------------------- shaders/deferred1.fsh | 15 +-- shaders/deferred1.vsh | 39 ++----- shaders/gbuffers_all_solid.fsh | 35 ++++-- shaders/gbuffers_all_solid.vsh | 2 +- shaders/lang/en_us.lang | 6 ++ shaders/lib/ROBOBO_sky.glsl | 2 +- shaders/lib/diffuse_lighting.glsl | 19 +--- shaders/lib/settings.glsl | 4 +- shaders/lib/sky_gradient.glsl | 4 + shaders/lib/volumetricClouds.glsl | 2 +- shaders/lib/volumetricFog.glsl | 24 +++-- shaders/shaders.properties | 4 +- 20 files changed, 219 insertions(+), 309 deletions(-) diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 5342d06..62e4197 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -9,8 +9,11 @@ const bool colortex12MipmapEnabled = true; // const bool colortex4MipmapEnabled = true; const bool shadowHardwareFiltering = true; -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) -flat varying vec3 avgAmbient; + +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; +flat varying vec4 lightCol; + flat varying vec3 WsunVec; flat varying vec2 TAA_Offset; flat varying float tempOffsets; @@ -389,7 +392,7 @@ vec2 tapLocation_alternate( } -void ssAO(inout vec3 lighting, inout float sss, vec3 fragpos,float mulfov, vec2 noise, vec3 normal, vec2 texcoord, vec3 ambientCoefs, vec2 lightmap){ +void ssAO(inout vec3 lighting, inout float sss, vec3 fragpos,float mulfov, vec2 noise, vec3 normal, vec2 texcoord, vec3 ambientCoefs, vec2 lightmap, bool isleaves){ ivec2 pos = ivec2(gl_FragCoord.xy); const float tan70 = tan(70.*3.14/180.); @@ -399,8 +402,12 @@ void ssAO(inout vec3 lighting, inout float sss, vec3 fragpos,float mulfov, vec2 float maxR2 = fragpos.z*fragpos.z*mulfov2*2.*5/50.0; #ifdef Ambient_SSS - float dist3 = clamp(1.0 - exp( fragpos.z*fragpos.z / -50),0,1); - float maxR2_2 = mix(10.0, fragpos.z*fragpos.z*mulfov2*2./50.0, dist3); + // float dist3 = clamp(1.0 - exp( fragpos.z*fragpos.z / -50),0,1); + // float maxR2_2 = mix(10.0, fragpos.z*fragpos.z*mulfov2*2./50.0, dist3); + + float maxR2_2 = fragpos.z*fragpos.z*mulfov2*2./50.0; + float dist3 = clamp(1-exp( fragpos.z*fragpos.z / -50),0,1); + if(isleaves) maxR2_2 = mix(10, maxR2_2, dist3); #endif float rd = mulfov2 * 0.1 ; @@ -846,7 +853,7 @@ void main() { DirectLightColor *= clamp(abs(WsunVec.y)*2,0.,1.); - vec3 AmbientLightColor = avgAmbient; + vec3 AmbientLightColor = averageSkyCol_Clouds; float cloudShadow = 1.0; @@ -1015,7 +1022,7 @@ void main() { // AO *= mix(1.0 - exp2(-5 * pow(1-vanilla_AO,3)),1.0, pow(newLightmap.x,4)); AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) ) ; - if (!hand) ssAO(AO, SkySSS, fragpos, 1.0, blueNoise(gl_FragCoord.xy).rg, FlatNormals , texcoord, ambientCoefs, newLightmap.xy); + if (!hand) ssAO(AO, SkySSS, fragpos, 1.0, blueNoise(gl_FragCoord.xy).rg, FlatNormals , texcoord, ambientCoefs, newLightmap.xy, isLeaf); #endif @@ -1043,11 +1050,13 @@ void main() { Indirect_lighting *= AO; #ifdef Ambient_SSS + if (!hand){ #if indirect_effect != 1 - if (!hand) ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); + ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); #endif Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3) * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1) ; // Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3); + } #endif @@ -1144,18 +1153,13 @@ void main() { LabEmission(FINAL_COLOR, albedo, SpecularTex.a); // #endif - // if(lightningBolt) FINAL_COLOR.rgb += vec3(Lightning_R,Lightning_G,Lightning_B) * 255.0; + if(lightningBolt) FINAL_COLOR.rgb += vec3(Lightning_R,Lightning_G,Lightning_B) * 255.0; gl_FragData[0].rgb = FINAL_COLOR; // if(LabSSS > 0.0) gl_FragData[0].rgb = vec3(0,25,0); } - - ////// ----- Apply Clouds ----- ////// - // gl_FragData[0].rgb = gl_FragData[0].rgb *cloud.a + cloud.rgb; - ////// ----- Under Water Fog ----- ////// - if (iswater){ vec3 fragpos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z0)); float Vdiff = distance(fragpos,fragpos0); @@ -1165,7 +1169,7 @@ void main() { float custom_lightmap_T = pow(texture2D(colortex14, texcoord).a,1.5); - vec3 ambientColVol = (avgAmbient * 8./150./1.5) * max(custom_lightmap_T,MIN_LIGHT_AMOUNT*0.001); + vec3 ambientColVol = (averageSkyCol_Clouds * 8./150./1.5) * max(custom_lightmap_T,MIN_LIGHT_AMOUNT*0.001); vec3 lightColVol = (lightCol.rgb / 80.) ; if (isEyeInWater == 0) waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec)); diff --git a/shaders/composite1.vsh b/shaders/composite1.vsh index a2305be..8d4f67a 100644 --- a/shaders/composite1.vsh +++ b/shaders/composite1.vsh @@ -2,9 +2,12 @@ #extension GL_EXT_gpu_shader4 : enable #include "lib/settings.glsl" -flat varying vec3 WsunVec; -flat varying vec3 avgAmbient; +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + flat varying vec4 lightCol; + +flat varying vec3 WsunVec; flat varying float tempOffsets; flat varying vec2 TAA_Offset; flat varying vec3 zMults; @@ -58,8 +61,11 @@ void main() { #ifndef TAA TAA_Offset = vec2(0.0); #endif - avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; + // sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + // moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; diff --git a/shaders/composite2.fsh b/shaders/composite2.fsh index 4e36a13..302c8a3 100644 --- a/shaders/composite2.fsh +++ b/shaders/composite2.fsh @@ -4,11 +4,14 @@ #include "lib/settings.glsl" +flat varying vec4 lightCol; flat varying vec3 sunColor; flat varying vec3 moonColor; -flat varying vec3 avgAmbient2; -flat varying vec4 lightCol; +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + + flat varying vec3 ambientUp; flat varying vec3 ambientLeft; flat varying vec3 ambientRight; @@ -16,6 +19,7 @@ flat varying vec3 ambientB; flat varying vec3 ambientF; flat varying vec3 ambientDown; flat varying vec3 avgAmbient; + flat varying float tempOffsets; flat varying float fogAmount; flat varying float VFAmount; @@ -274,18 +278,17 @@ void main() { vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z)); #ifdef Cloud_Fog - vec4 VL_CLOUDFOG = InsideACloudFog(fragpos, vec2(R2_dither(),blueNoise()), lightCol.rgb/80., moonColor/150., (avgAmbient*2.0) * 8./150./3.); + vec4 VL_CLOUDFOG = InsideACloudFog(fragpos, vec2(R2_dither(),blueNoise()), lightCol.rgb/80., moonColor/150., (averageSkyCol*2.0) * 8./150./3.); // vec4 rays = vec4(0.0); - // if(rainStrength > 0.0){ // rays = RainRays(vec3(0.0), fragpos, length(fragpos), R2_dither(), (avgAmbient*2.0) * 8./150./3., lightCol.rgb, dot(normalize(fragpos), normalize(sunVec) )); // VL_CLOUDFOG += rays * rainStrength; // } - gl_FragData[0] = clamp(VL_CLOUDFOG ,0.0,65000.); + gl_FragData[0] = clamp(VL_CLOUDFOG, 0.0,65000.); #else - vec4 VL_Fog = getVolumetricRays(fragpos,blueNoise(),avgAmbient); + vec4 VL_Fog = getVolumetricRays(fragpos, blueNoise(), averageSkyCol); gl_FragData[0] = clamp(VL_Fog,0.0,65000.); #endif @@ -311,8 +314,7 @@ void main() { estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0); - - waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, (avgAmbient*8./150./3.*0.5) , lightCol.rgb*8./150./3.0*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)), dot(normalize(fragpos), normalize(sunVec) )); + waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, (averageSkyCol_Clouds*8./150./3.*0.5) , lightCol.rgb*8./150./3.0*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)), dot(normalize(fragpos), normalize(sunVec) )); gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.); } } diff --git a/shaders/composite2.vsh b/shaders/composite2.vsh index 7c3bbbe..bb16a71 100644 --- a/shaders/composite2.vsh +++ b/shaders/composite2.vsh @@ -3,6 +3,9 @@ #include "lib/settings.glsl" +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + flat varying vec4 lightCol; flat varying vec3 ambientUp; flat varying vec3 ambientLeft; @@ -69,10 +72,12 @@ void main() { #endif vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - sunColor = texelFetch2D(colortex4,ivec2(12,37),0).rgb; - moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; - avgAmbient = texelFetch2D(colortex4,ivec2(1,37),0).rgb; + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; + + sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; lightCol.a = float(sunElevation > 1e-5)*2-1.; lightCol.rgb = sc; diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index 73abbdd..f79259d 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -208,7 +208,7 @@ void main() { vec4 TranslucentShader = texture2D(colortex2,texcoord); - float lightleakfix = clamp((eyeBrightnessSmooth.y )/240.0,0.0,1.0); + float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); vec2 tempOffset = TAA_Offset; @@ -261,8 +261,21 @@ void main() { //cave fog #ifdef Cave_fog if (isEyeInWater == 0){ + + // float fogdistfade = clamp( pow(length(fragpos) / far, CaveFogFallOff) ,0.0,1.0); + // float fogfade = clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); + 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); + + // vl.a *= 1-fogdistfade ; + // float fogdistfade = clamp( pow(1.0 - exp((length(fragpos) / far) * -5), 2.0) ,0.0,1.0); + // // float fogfade = clamp( exp(clamp(np3.y * 0.35 + 0.35,0,1) * -5.0) ,0.0,1.0) * 0.1; + + + color.rgb = mix(color.rgb, vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade + (blueNoise()-0.5)*0.01, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor) * clamp( 1.5 - np3.y,0.,1)) ; // color.rgb = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade ; } @@ -300,9 +313,9 @@ void main() { 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); #ifdef display_LUT - vec2 movedTC = texcoord ; + vec2 movedTC = texcoord ; vec3 thingy = texture2D(colortex4,movedTC).rgb / 150. * 5.0; - if(texcoord.x < 0.45 && luma(thingy) > 0.0 ) color.rgb = thingy; + if(luma(thingy) > 0.0 ) color.rgb = thingy; #endif gl_FragData[0].r = vl.a; // pass fog alpha so bloom can do bloomy fog diff --git a/shaders/composite3.vsh b/shaders/composite3.vsh index bd893f8..cdbb4e3 100644 --- a/shaders/composite3.vsh +++ b/shaders/composite3.vsh @@ -39,11 +39,12 @@ void main() { #ifdef TAA_UPSCALING gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; #endif - TAA_Offset = offsets[frameCounter%8]; + #ifndef TAA - TAA_Offset = vec2(0.0); + TAA_Offset = vec2(0.0); #endif + vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; lightCol.a = float(sunElevation > 1e-5)*2-1.; lightCol.rgb = sc; diff --git a/shaders/deferred.fsh b/shaders/deferred.fsh index f5a15fe..98574a8 100644 --- a/shaders/deferred.fsh +++ b/shaders/deferred.fsh @@ -5,27 +5,19 @@ //Prepares sky textures (2 * 256 * 256), computes light values and custom lightmaps #define ReflectedFog -flat varying vec3 ambientUp; -flat varying vec3 ambientLeft; -flat varying vec3 ambientRight; -flat varying vec3 ambientB; -flat varying vec3 ambientF; -flat varying vec3 ambientDown; -flat varying float avgL2; +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + flat varying vec3 lightSourceColor; flat varying vec3 sunColor; -flat varying vec3 sunColorCloud; flat varying vec3 moonColor; -flat varying vec3 moonColorCloud; flat varying vec3 zenithColor; -flat varying vec3 avgSky; + +flat varying float avgL2; flat varying vec2 tempOffsets; flat varying float exposure; flat varying float rodExposure; flat varying float avgBrightness; -flat varying float exposureF; -flat varying float fogAmount; -flat varying float VFAmount; flat varying float centerDepth; // uniform sampler2D colortex4; @@ -116,85 +108,40 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), void main() { /* DRAWBUFFERS:4 */ gl_FragData[0] = vec4(0.0); -float minLight = (MIN_LIGHT_AMOUNT + nightVision*5) * 0.007/ (exposure + rodExposure/(rodExposure+1.0)*exposure*1.); -// vec3 minLight_col = MIN_LIGHT_AMOUNT * 0.007/ (exposure + rodExposure/(rodExposure+1.0)*exposure*1.) * vec3(0.8,0.9,1.0); -//Lightmap for forward shading (contains average integrated sky color across all faces + torch + min ambient) -vec3 avgAmbient = (ambientUp + ambientLeft + ambientRight + ambientB + ambientF + ambientDown)/6.; - -// avgAmbient *= blackbody(ambient_temp); - -if (gl_FragCoord.x < 17. && gl_FragCoord.y < 17.){ - float torchLut = clamp(16.0-gl_FragCoord.x,0.5,15.5); - torchLut = torchLut+0.712; - float torch_lightmap = max(1.0/torchLut/torchLut - 1/17.212/17.212,0.0); - torch_lightmap = pow(torch_lightmap*2.5,1.5)*TORCH_AMOUNT*10.; - float sky_lightmap = (Slightmap[int(gl_FragCoord.y)]-14.0)/235.; - sky_lightmap = pow(sky_lightmap,1.4); - vec3 ambient = (ambientUp * blackbody(ambient_temp))*sky_lightmap+torch_lightmap*vec3(TORCH_R,TORCH_G,TORCH_B)*TORCH_AMOUNT; - - gl_FragData[0] = vec4(max(ambient*Ambient_Mult,minLight/5),1.0); -} - -//Lightmap for deferred shading (contains only torch + min ambient) -if (gl_FragCoord.x < 17. && gl_FragCoord.y > 19. && gl_FragCoord.y < 19.+17. ){ - float torchLut = clamp(16.0-gl_FragCoord.x,0.5,15.5); - torchLut = torchLut+0.712; - float torch_lightmap = max(1.0/torchLut/torchLut - 1/17.212/17.212,0.0); - float ambient = pow(torch_lightmap*2.5,1.5)*TORCH_AMOUNT*10.; - float sky_lightmap = (Slightmap[int(gl_FragCoord.y-19.0)]-14.0)/235./150.; - - gl_FragData[0] = vec4(sky_lightmap,ambient,minLight,1.0)*Ambient_Mult; -} //Save light values if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientUp * blackbody(ambient_temp) ,1.0); +gl_FragData[0] = vec4(averageSkyCol_Clouds * blackbody(ambient_temp),1.0); if (gl_FragCoord.x > 1. && gl_FragCoord.x < 2. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientUp ,1.0); -if (gl_FragCoord.x > 2. && gl_FragCoord.x < 3. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientLeft ,1.0); -if (gl_FragCoord.x > 3. && gl_FragCoord.x < 4. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientRight ,1.0); -if (gl_FragCoord.x > 4. && gl_FragCoord.x < 5. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientB ,1.0); -if (gl_FragCoord.x > 5. && gl_FragCoord.x < 6. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(ambientF ,1.0); +gl_FragData[0] = vec4(averageSkyCol,1.0); + if (gl_FragCoord.x > 6. && gl_FragCoord.x < 7. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) gl_FragData[0] = vec4(lightSourceColor,1.0); -if (gl_FragCoord.x > 7. && gl_FragCoord.x < 8. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(avgAmbient ,1.0); + if (gl_FragCoord.x > 8. && gl_FragCoord.x < 9. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) gl_FragData[0] = vec4(sunColor,1.0); -if (gl_FragCoord.x > 9. && gl_FragCoord.x < 10. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(moonColor,1.0); -if (gl_FragCoord.x > 11. && gl_FragCoord.x < 12. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(avgSky ,1.0); -if (gl_FragCoord.x > 12. && gl_FragCoord.x < 13. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(sunColorCloud,1.0); if (gl_FragCoord.x > 13. && gl_FragCoord.x < 14. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(moonColorCloud,1.0); -//Sky gradient (no clouds) +gl_FragData[0] = vec4(moonColor,1.0); + const float pi = 3.141592653589793238462643383279502884197169; - +//Sky gradient (no clouds) if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){ - vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.,1.))/256.+tempOffsets/256.,0.0,1.0); - vec3 viewVector = cartToSphere(p); + vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.,1.))/256.+tempOffsets/256.,0.0,1.0); + vec3 viewVector = cartToSphere(p); vec2 planetSphere = vec2(0.0); vec3 sky = vec3(0.0); vec3 skyAbsorb = vec3(0.0); - vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; + vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; - sky = calculateAtmosphere(avgSky*4000./2.0, viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise()); + sky = calculateAtmosphere(averageSkyCol*4000./2.0, viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise()); #ifdef AEROCHROME_MODE sky *= vec3(0.0, 0.18, 0.35); #endif - // sky = mix(sky, vec3(0.5,0.5,0.5)*avgSky * 4000., clamp(1 - viewVector.y,0.0,1.0) * rainStrength ); - // sky *= max(abs(viewVector.y+0.05),0.25); gl_FragData[0] = vec4(sky/4000.*Sky_Brightness,1.0); } @@ -203,18 +150,18 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+ vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); vec3 viewVector = cartToSphere(p); - vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; - vec3 skytex = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150. ; + vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; + vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150. ; - if(viewVector.y < -0.025) skytex = skytex * clamp( exp(viewVector.y) - 1.0,0.25,1.0) ; + if(viewVector.y < -0.025) sky = sky * clamp( exp(viewVector.y) - 1.0,0.25,1.0) ; - vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), sunColorCloud, moonColor, ambientUp*5.0); - // skytex = skytex*clouds.a + clouds.rgb/5.0; + vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), sunColor, moonColor, averageSkyCol*5.0); + sky = sky*clouds.a + clouds.rgb/5.0; - vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), ambientUp); - skytex = skytex*VL_Fog.a + VL_Fog.rgb*20; + vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), averageSkyCol); + sky = sky*VL_Fog.a + VL_Fog.rgb*20; - gl_FragData[0] = vec4(skytex,1.0); + gl_FragData[0] = vec4(sky,1.0); } //Temporally accumulate sky and light values diff --git a/shaders/deferred.vsh b/shaders/deferred.vsh index fa27c5d..f334283 100644 --- a/shaders/deferred.vsh +++ b/shaders/deferred.vsh @@ -1,29 +1,22 @@ #version 120 + #extension GL_EXT_gpu_shader4 : enable #include "lib/settings.glsl" - #include "lib/res_params.glsl" -flat varying vec3 ambientUp; -flat varying vec3 ambientLeft; -flat varying vec3 ambientRight; -flat varying vec3 ambientB; -flat varying vec3 ambientF; -flat varying vec3 ambientDown; -flat varying vec3 zenithColor; + +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + flat varying vec3 sunColor; -flat varying vec3 sunColorCloud; flat varying vec3 moonColor; -flat varying vec3 moonColorCloud; flat varying vec3 lightSourceColor; -flat varying vec3 avgSky; +flat varying vec3 zenithColor; + flat varying vec2 tempOffsets; flat varying float exposure; flat varying float avgBrightness; -flat varying float exposureF; flat varying float rodExposure; -flat varying float fogAmount; -flat varying float VFAmount; flat varying float avgL2; flat varying float centerDepth; @@ -31,64 +24,28 @@ uniform sampler2D colortex4; uniform sampler2D colortex6; uniform sampler2D depthtex0; - -flat varying vec3 WsunVec; uniform mat4 gbufferModelViewInverse; uniform vec3 sunPosition; uniform vec2 texelSize; -uniform float rainStrength; uniform float sunElevation; -uniform float nightVision; +uniform float eyeAltitude; uniform float near; uniform float far; uniform float frameTime; -uniform float eyeAltitude; uniform int frameCounter; +uniform float rainStrength; + // uniform int worldTime; vec3 sunVec = normalize(mat3(gbufferModelViewInverse) *sunPosition); - - #include "lib/sky_gradient.glsl" #include "/lib/util.glsl" #include "/lib/ROBOBO_sky.glsl" - -vec3 rodSample(vec2 Xi) -{ - float r = sqrt(1.0f - Xi.x*Xi.y); - float phi = 2 * 3.14159265359 * Xi.y; - - return normalize(vec3(cos(phi) * r, sin(phi) * r, Xi.x)).xzy; -} -vec3 cosineHemisphereSample(vec2 Xi) -{ - float r = sqrt(Xi.x); - float theta = 2.0 * 3.14159265359 * Xi.y; - - float x = r * cos(theta); - float y = r * sin(theta); - - return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.))); -} - float luma(vec3 color) { return dot(color,vec3(0.21, 0.72, 0.07)); } -vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter) -{ - float alpha = float(sampleNumber+jitter)/nb; - float angle = (jitter+alpha) * (nbRot * 6.28); - - float ssR = alpha; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; -} //Low discrepancy 2D sequence, integration error is as low as sobol but easier to compute : http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ vec2 R2_samples(int n){ vec2 alpha = vec2(0.75487765, 0.56984026); @@ -106,42 +63,46 @@ void main() { gl_Position.xy = gl_Position.xy*vec2(18.+258*2,258.)*texelSize; gl_Position.xy = gl_Position.xy*2.-1.0; - tempOffsets = R2_samples(frameCounter%10000); +/////////////////////////////////// +/// --- AMBIENT LIGHT STUFF --- /// +/////////////////////////////////// - ambientUp = vec3(0.0); - ambientDown = vec3(0.0); - ambientLeft = vec3(0.0); - ambientRight = vec3(0.0); - ambientB = vec3(0.0); - ambientF = vec3(0.0); - avgSky = vec3(0.0); - //Integrate sky light for each block side - int maxIT = 20; + averageSkyCol_Clouds = vec3(0.0); + averageSkyCol = vec3(0.0); + + vec2 sample3x3[9] = vec2[]( + + vec2(-1.0, 0.0), + vec2( 0.0, 0.0), + vec2( 1.0, 0.0), + + vec2(-1.0, -0.5), + vec2( 0.0, -0.5), + vec2( 1.0, -0.5), + + vec2(-1.0, -1.0), + vec2( 0.0, -1.0), + vec2( 1.0, -1.0) + ); + + // sample in a 3x3 pattern to get a good area for average color + vec3 pos = normalize(vec3(0,1,0)); + int maxIT = 9; for (int i = 0; i < maxIT; i++) { - vec2 ij = R2_samples((frameCounter%1000)*maxIT+i); - vec3 pos = normalize(rodSample(ij)); + pos.xy += normalize(sample3x3[i] * vec2(1.0,0.5)); + averageSkyCol_Clouds += 2.0*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.; + + pos = normalize(vec3(0,1,0)); + } + + // only need to sample one spot for this + averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.; - vec3 samplee = 1.72*skyFromTex(pos,colortex4).rgb/maxIT/150.; - avgSky += samplee/1.72; - ambientUp += samplee*(pos.y+abs(pos.x)/7.+abs(pos.z)/7.); - ambientLeft += samplee*(clamp(-pos.x,0.0,1.0)+clamp(pos.y/7.,0.0,1.0)+abs(pos.z)/7.); - ambientRight += samplee*(clamp(pos.x,0.0,1.0)+clamp(pos.y/7.,0.0,1.0)+abs(pos.z)/7.); - ambientB += samplee*(clamp(pos.z,0.0,1.0)+abs(pos.x)/7.+clamp(pos.y/7.,0.0,1.0)); - ambientF += samplee*(clamp(-pos.z,0.0,1.0)+abs(pos.x)/7.+clamp(pos.y/7.,0.0,1.0)); - ambientDown += samplee*(clamp(pos.y/6.,0.0,1.0)+abs(pos.x)/7.+abs(pos.z)/7.); - - /* - ambientUp += samplee*(pos.y); - ambientLeft += samplee*(clamp(-pos.x,0.0,1.0)); - ambientRight += samplee*(clamp(pos.x,0.0,1.0)); - ambientB += samplee*(clamp(pos.z,0.0,1.0)); - ambientF += samplee*(clamp(-pos.z,0.0,1.0)); - ambientDown += samplee*(clamp(pos.y/6.,0.0,1.0))*0; - */ - - } +//////////////////////////////////////// +/// --- SUNLIGHT/MOONLIGHT STUFF --- /// +//////////////////////////////////////// vec2 planetSphere = vec2(0.0); vec3 sky = vec3(0.0); @@ -156,56 +117,19 @@ void main() { sunColor = calculateAtmosphere(vec3(0.0), sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.0); sunColor = sunColorBase/4000. * skyAbsorb; - skyAbsorb = vec3(1.0); - float dSun = 0.03; - vec3 modSunVec = sunVec*(1.0-dSun)+vec3(0.0,dSun,0.0); - vec3 modSunVec2 = sunVec*(1.0-dSun)+vec3(0.0,dSun,0.0); - if (modSunVec2.y > modSunVec.y) modSunVec = modSunVec2; - sunColorCloud = calculateAtmosphere(vec3(0.0), modSunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.); - sunColorCloud = sunColorBase/4000. * skyAbsorb ; - skyAbsorb = vec3(1.0); moonColor = calculateAtmosphere(vec3(0.0), -sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5); moonColor = moonColorBase/4000.0*skyAbsorb; - skyAbsorb = vec3(1.0); - modSunVec = -sunVec*(1.0-dSun)+vec3(0.0,dSun,0.0); - modSunVec2 = -sunVec*(1.0-dSun)+vec3(0.0,dSun,0.0); - if (modSunVec2.y > modSunVec.y) modSunVec = modSunVec2; - moonColorCloud = calculateAtmosphere(vec3(0.0), modSunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5); - - moonColorCloud = moonColorBase/4000.0*0.55; - - // #ifndef CLOUDS_SHADOWS - // sunColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94)); - // moonColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94)); - // #endif - lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis; float lightDir = float( sunVis >= 1e-5)*2.0-1.0; - //Fake bounced sunlight - vec3 bouncedSun = lightSourceColor*0.1/5.0*0.5*clamp(lightDir*sunVec.y,0.0,1.0)*clamp(lightDir*sunVec.y,0.0,1.0); - vec3 cloudAmbientSun = (sunColorCloud)*0.007; - vec3 cloudAmbientMoon = (moonColorCloud)*0.007; - ambientUp += bouncedSun*clamp(-lightDir*sunVec.y+4.,0.,4.0) + cloudAmbientSun*clamp(sunVec.y+2.,0.,4.0) + cloudAmbientMoon*clamp(-sunVec.y+2.,0.,4.0); - ambientLeft += bouncedSun*clamp(lightDir*sunVec.x+4.,0.0,4.) + cloudAmbientSun*clamp(-sunVec.x+2.,0.0,4.)*0.7 + cloudAmbientMoon*clamp(sunVec.x+2.,0.0,4.)*0.7; - ambientRight += bouncedSun*clamp(-lightDir*sunVec.x+4.,0.0,4.) + cloudAmbientSun*clamp(sunVec.x+2.,0.0,4.)*0.7 + cloudAmbientMoon*clamp(-sunVec.x+2.,0.0,4.)*0.7; - ambientB += bouncedSun*clamp(-lightDir*sunVec.z+4.,0.0,4.) + cloudAmbientSun*clamp(sunVec.z+2.,0.0,4.)*0.7 + cloudAmbientMoon*clamp(-sunVec.z+2.,0.0,4.)*0.7; - ambientF += bouncedSun*clamp(lightDir*sunVec.z+4.,0.0,4.) + cloudAmbientSun*clamp(-sunVec.z+2.,0.0,4.)*0.7 + cloudAmbientMoon*clamp(sunVec.z+2.,0.0,4.)*0.7; - ambientDown += bouncedSun*clamp(lightDir*sunVec.y+4.,0.0,4.)*0.7 + cloudAmbientSun*clamp(-sunVec.y+2.,0.0,4.)*0.5 + cloudAmbientMoon*clamp(sunVec.y+2.,0.0,4.)*0.5; - avgSky += bouncedSun*5.; - vec3 rainNightBoost = moonColorCloud*0.005; - ambientUp += rainNightBoost; - ambientLeft += rainNightBoost; - ambientRight += rainNightBoost; - ambientB += rainNightBoost; - ambientF += rainNightBoost; - ambientDown += rainNightBoost; - avgSky += rainNightBoost; +////////////////////////////// +/// --- EXPOSURE STUFF --- /// +////////////////////////////// float avgLuma = 0.0; float m2 = 0.0; diff --git a/shaders/deferred1.fsh b/shaders/deferred1.fsh index 4636f1e..e2981f2 100644 --- a/shaders/deferred1.fsh +++ b/shaders/deferred1.fsh @@ -4,14 +4,17 @@ //Computes volumetric clouds at variable resolution (default 1/4 res) -uniform float far; -uniform float near; -flat varying vec4 lightCol; + flat varying vec3 sunColor; flat varying vec3 moonColor; -flat varying vec3 avgAmbient; -flat varying float tempOffsets; +flat varying vec3 averageSkyCol_Clouds; + + + +flat varying float tempOffsets; +uniform float far; +uniform float near; uniform sampler2D depthtex0; // uniform sampler2D colortex4; uniform sampler2D noisetex; @@ -92,7 +95,7 @@ void main() { vec3 fragpos = toScreenSpace(vec3(halfResTC*texelSize,1)); - vec4 currentClouds = renderClouds(fragpos,vec2(R2_dither(),blueNoise2()), lightCol.rgb/80., moonColor/150., (avgAmbient*2.0)* 8./150./3.); + vec4 currentClouds = renderClouds(fragpos,vec2(R2_dither(),blueNoise2()), sunColor/80., moonColor/150., (averageSkyCol_Clouds*2.0)* 8./150./3.); gl_FragData[0] = currentClouds; diff --git a/shaders/deferred1.vsh b/shaders/deferred1.vsh index a6c6771..afb8703 100644 --- a/shaders/deferred1.vsh +++ b/shaders/deferred1.vsh @@ -2,57 +2,38 @@ #extension GL_EXT_gpu_shader4 : enable #include "lib/settings.glsl" - +flat varying vec3 averageSkyCol_Clouds; flat varying vec3 sunColor; flat varying vec3 moonColor; -flat varying vec4 lightCol; -flat varying vec3 avgAmbient; -flat varying float tempOffsets; + +flat varying float tempOffsets; flat varying vec3 WsunVec; -flat varying vec3 ambientUp; -flat varying vec3 ambientLeft; -flat varying vec3 ambientRight; -flat varying vec3 ambientB; -flat varying vec3 ambientF; -flat varying vec3 ambientDown; uniform mat4 gbufferModelViewInverse; uniform vec3 sunPosition; uniform float sunElevation; uniform sampler2D colortex4; uniform int frameCounter; + #include "/lib/util.glsl" #include "/lib/res_params.glsl" + void main() { - // TAA_Offset = offsets[frameCounter%8]; - // #ifndef TAA - // TAA_Offset = vec2(0.0); - // #endif tempOffsets = HaltonSeq2(frameCounter%10000); gl_Position = ftransform(); gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(CLOUDS_QUALITY+0.01,0.0,1.0)*2.0-1.0; + #ifdef TAA_UPSCALING gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; #endif - sunColor = texelFetch2D(colortex4,ivec2(12,37),0).rgb; + + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(1,37),0).rgb; + sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; - // avgAmbient = texelFetch2D(colortex4,ivec2(11,37),0).rgb; - - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); + WsunVec = ( float(sunElevation > 1e-5)*2-1. )*normalize(mat3(gbufferModelViewInverse) *sunPosition); - // ambientUp = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - // ambientDown = texelFetch2D(colortex4,ivec2(1,37),0).rgb; - // ambientLeft = texelFetch2D(colortex4,ivec2(2,37),0).rgb; - // ambientRight = texelFetch2D(colortex4,ivec2(3,37),0).rgb; - // ambientB = texelFetch2D(colortex4,ivec2(4,37),0).rgb; - // ambientF = texelFetch2D(colortex4,ivec2(5,37),0).rgb; - - avgAmbient = texelFetch2D(colortex4,ivec2(1,37),0).rgb; } diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh index dce5ba7..73c9a65 100644 --- a/shaders/gbuffers_all_solid.fsh +++ b/shaders/gbuffers_all_solid.fsh @@ -556,12 +556,33 @@ void main() { gl_FragData[2].rg = SpecularTex.rg; - #ifdef LabPBR_Emissives - gl_FragData[2].a = SpecularTex.a; - #else - gl_FragData[2].a = EMISSIVE; + // #ifdef LabPBR_Emissives + // gl_FragData[2].a = SpecularTex.a; + // if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE; + // #else + // gl_FragData[2].a = SpecularTex.a; + // if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE; + // // gl_FragData[2].a = EMISSIVE; + // #endif + + #if EMISSIVE_TYPE == 0 + gl_FragData[2].a = 0.0; #endif + #if EMISSIVE_TYPE == 1 + gl_FragData[2].a = EMISSIVE + #endif + + #if EMISSIVE_TYPE == 2 + gl_FragData[2].a = SpecularTex.a; + if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE; + #endif + + #if EMISSIVE_TYPE == 3 + gl_FragData[2].a = SpecularTex.a; + #endif + + #if SSS_TYPE == 0 gl_FragData[2].b = 0.0; @@ -584,9 +605,9 @@ void main() { - #ifdef ENTITIES - if(LIGHTNING > 0) gl_FragData[2].a = 0.5; - #endif + // #ifdef ENTITIES + // if(LIGHTNING > 0) gl_FragData[2].a = 0.9; + // #endif //////////////////////////////// //////////////////////////////// ALBEDO diff --git a/shaders/gbuffers_all_solid.vsh b/shaders/gbuffers_all_solid.vsh index 5363bca..ddce639 100644 --- a/shaders/gbuffers_all_solid.vsh +++ b/shaders/gbuffers_all_solid.vsh @@ -248,7 +248,7 @@ void main() { // if(NameTags > 0) EMISSIVE = 0.9; // normal block lightsources - if(mc_Entity.x == 10005) EMISSIVE = 0.3; + if(mc_Entity.x == 10005) EMISSIVE = 0.9; // special cases light lightning and beacon beams... #ifdef ENTITIES diff --git a/shaders/lang/en_us.lang b/shaders/lang/en_us.lang index 886b397..eefd818 100644 --- a/shaders/lang/en_us.lang +++ b/shaders/lang/en_us.lang @@ -21,6 +21,12 @@ value.SSS_TYPE.2 = Hardcoded + LabSSS value.SSS_TYPE.3 = LabSSS only option.SSS_TYPE.comment = Hardcoded means that the shader defines what gets SSS or not. LabSSS means that the resourcepack defines what gets SSS or not. RTX is no SSS at all lmao. i had to steal this formatting, RRe36 +option.EMISSIVE_TYPE = Emission Mode +value.EMISSIVE_TYPE.0 = No emission +value.EMISSIVE_TYPE.1 = Hardcoded only +value.EMISSIVE_TYPE.2 = Hardcoded + Lab Emission +value.EMISSIVE_TYPE.3 = Lab Emission only +option.EMISSIVE_TYPE.comment = Hardcoded means that the shader defines what gets emission or not. Lab emission means that the resourcepack defines what gets emission or not. RTX is no SSS at all lmao. i had to steal this formatting, RRe36 diff --git a/shaders/lib/ROBOBO_sky.glsl b/shaders/lib/ROBOBO_sky.glsl index de561d5..358e4fa 100644 --- a/shaders/lib/ROBOBO_sky.glsl +++ b/shaders/lib/ROBOBO_sky.glsl @@ -124,7 +124,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s // float low_sun = clamp(pow(1.0-sunVector.y,10.0) + 1.0,1.0, 2.0); float high_sun = clamp(pow(sunVector.y+0.6,5),0.0,1.0) * 3.0; // make sunrise less blue, and allow sunset to be bluer - float low_sun = clamp(((1.0-abs(sunVector.y))*3.) - high_sun,1.0,2.5) ; + float low_sun = clamp(((1.0-abs(sunVector.y))*3.) - high_sun,1.0,2.0) ; for (int i = 0; i < iSteps; ++i, position += increment) { vec3 density = sky_density(length(position)); diff --git a/shaders/lib/diffuse_lighting.glsl b/shaders/lib/diffuse_lighting.glsl index b870160..dcc5a37 100644 --- a/shaders/lib/diffuse_lighting.glsl +++ b/shaders/lib/diffuse_lighting.glsl @@ -10,31 +10,18 @@ vec3 DoAmbientLighting (vec3 SkyColor, vec3 TorchColor, vec2 Lightmap, float sky // Lightmap.x = 0.0; // 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; - 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; - // 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 * 2.0 * ambient_brightness) * 8./150./3.; - - SkyColor += vec3(Lightning_R,Lightning_G,Lightning_B) * 25.0 * skyLightDir * lightningFlash ; - // SkyColor += vec3(0.7,0.9,1.0) * skyLightDir * lightningFlash; + + SkyColor += vec3(Lightning_R,Lightning_G,Lightning_B) * 25.0 * skyLightDir * lightningFlash ; float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5; vec3 SkyLight = max(SkyColor * skyLM, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)); - - return SkyLight * skyLightDir + TorchLight; } @@ -53,8 +40,6 @@ vec3 DoAmbientLighting_Nether(vec3 FogColor, vec3 TorchColor, float Lightmap, ve vec3 TorchLight = TorchColor * clamp(pow(Lightmap,3.0),0.0,1.0); - - vec3 LavaGlow = vec3(TORCH_R,TORCH_G,TORCH_B); LavaGlow *= pow(clamp(1.0-max(Normal.y,0.0) + dot(Normal,np3),0.0,1.0),3.0); LavaGlow *= clamp(exp2(-max((WorldPos.y - 50.0) / 5,0.0)),0.0,1.0); diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index b73e2d4..4c0913f 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -145,6 +145,7 @@ //#define SPECULARTEX // #define LabPBR_Emissives +#define EMISSIVE_TYPE 2 // [0 1 2 3] #define Emissive_Brightness 10.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.] #define Emissive_Curve 2.0 // yes i blatantly copied kappa here. [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 ] @@ -159,9 +160,8 @@ #define MAX_DIST 25.0 // [5.0 10.0 15.0 20.0 25.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 125.0 150.0 200.0 400.0] //Increases distance at which POM is calculated // #define Porosity - #define Sub_surface_scattering // (place the flashlight on your hand example here) -#define SSS_TYPE 1 // [0 1 2 3] +#define SSS_TYPE 2 // [0 1 2 3] #define Ambient_SSS // subsurface scattering from the sky's light. If SSAO is enabled, this costs very little performance. #define ambientsss_brightness 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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] #define Strong_SSS_strength 45 // [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2 3 4 5 6 7 8 9 10 15 20 30 35 40 45 50] diff --git a/shaders/lib/sky_gradient.glsl b/shaders/lib/sky_gradient.glsl index 0c468db..af598fd 100644 --- a/shaders/lib/sky_gradient.glsl +++ b/shaders/lib/sky_gradient.glsl @@ -13,6 +13,10 @@ vec3 skyFromTex(vec3 pos,sampler2D sampler){ vec2 p = sphereToCarte(pos); return texture2D(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize).rgb; } +vec3 skyFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ + vec2 p = sphereToCarte(pos); + return texture2DLod(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize,LOD).rgb; +} float w0(float a) { return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0); diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index d18fe49..32f5cc7 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -305,7 +305,7 @@ vec4 renderClouds( float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ; - vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, timing); + vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, 1); S += lightningColor * exp((1.0-cumulus) * -10) * ambientlightshadow; vec3 Sint = (S - S * exp(-mult*muE)) / muE; diff --git a/shaders/lib/volumetricFog.glsl b/shaders/lib/volumetricFog.glsl index 2bc62da..52408e8 100644 --- a/shaders/lib/volumetricFog.glsl +++ b/shaders/lib/volumetricFog.glsl @@ -117,6 +117,7 @@ vec4 getVolumetricRays( vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; + float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); for (int i=0;i PhysicsMod_support @@ -188,7 +188,7 @@ screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds] screen.LabPBR = [Reflections] [Subsurface_Scattering] [Emissives] [POM] [Porosity] screen.Emissives.columns = 1 - screen.Emissives = LabPBR_Emissives Emissive_Brightness Emissive_Curve + screen.Emissives = EMISSIVE_TYPE Emissive_Brightness Emissive_Curve screen.Porosity.columns = 1 screen.Porosity = Puddles Puddle_Size Porosity