From b11b79516057b038a1ef6d6d184eec526a30e514 Mon Sep 17 00:00:00 2001 From: Xonk Date: Sun, 30 Jul 2023 00:26:44 -0400 Subject: [PATCH] improved ambient light a little more in the nether. (thanks ambrosia). added auto exposure to the nether. --- shaders/composite11.fsh | 2 +- shaders/lib/nether_fog.glsl | 9 +- shaders/world-1/composite15.fsh | 472 ++++---------------------------- shaders/world-1/composite15.vsh | 21 +- shaders/world-1/composite2.fsh | 23 +- shaders/world-1/deferred.fsh | 29 +- shaders/world-1/deferred.vsh | 214 +++++---------- shaders/world-1/final.vsh | 1 - 8 files changed, 161 insertions(+), 610 deletions(-) diff --git a/shaders/composite11.fsh b/shaders/composite11.fsh index 763c216..dd736cb 100644 --- a/shaders/composite11.fsh +++ b/shaders/composite11.fsh @@ -115,7 +115,7 @@ void main() { float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0); - col = (mix(col,bloom,VL_abs)+bloom * lightScat)* mix(exposure.rgb,min(exposure.rgb,0.01), 0); + col = (mix(col,bloom,VL_abs)+bloom * lightScat) * mix(exposure.rgb,min(exposure.rgb,0.01), 0); //Purkinje Effect float lum = dot(col,vec3(0.15,0.3,0.55)); diff --git a/shaders/lib/nether_fog.glsl b/shaders/lib/nether_fog.glsl index f3c0f38..0dc7b53 100644 --- a/shaders/lib/nether_fog.glsl +++ b/shaders/lib/nether_fog.glsl @@ -58,13 +58,13 @@ vec4 GetVolumetricFog( vec3 dV = fragposition-start; vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); - float maxLength = min(length(dVWorld),far*25)/length(dVWorld); + float maxLength = min(length(dVWorld),far)/length(dVWorld); dV *= maxLength; dVWorld *= maxLength; float dL = length(dVWorld); - vec3 fogcolor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.01)) ; + vec3 fogcolor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.05)) ; float expFactor = 11.0; for (int i=0;i dtc.z? dtc : dmin; - dmin = dmin.z > dtr.z? dtr : dmin; - - dmin = dmin.z > dml.z? dml : dmin; - dmin = dmin.z > dtl.z? dtl : dmin; - dmin = dmin.z > dmr.z? dmr : dmin; - - dmin = dmin.z > dbl.z? dbl : dmin; - dmin = dmin.z > dbc.z? dbc : dmin; - dmin = dmin.z > dbr.z? dbr : dmin; - - return dmin; -} void main() { /* DRAWBUFFERS:7 */ - float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.5); + float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.); vec3 col = texture2D(colortex5,texcoord).rgb; - #ifdef DOF - /*--------------------------------*/ - float z = ld(texture2D(depthtex0, texcoord.st).r)*far; - #ifdef AUTOFOCUS - float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far; - #else - float focus = MANUAL_FOCUS; - #endif - float pcoc = min(abs(aperture * (focal/100.0 * (z - focus)) / (z * (focus - focal/100.0))),texelSize.x*15.0); - #ifdef FAR_BLUR_ONLY - pcoc *= float(z > focus); - #endif - float noise = blueNoise()*6.28318530718; - mat2 noiseM = mat2( cos( noise ), -sin( noise ), - sin( noise ), cos( noise ) - ); - vec3 bcolor = vec3(0.); - float nb = 0.0; - vec2 bcoord = vec2(0.0); - /*--------------------------------*/ - #ifndef HQ_DOF - bcolor = col; - #ifdef HEXAGONAL_BOKEH - for ( int i = 0; i < 60; i++) { - bcolor += texture2D(colortex5, texcoord.xy + hex_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - col = bcolor/61.0; - #else - for ( int i = 0; i < 60; i++) { - bcolor += texture2D(colortex5, texcoord.xy + offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - /*--------------------------------*/ - col = bcolor/61.0; - #endif - #endif - #ifdef HQ_DOF - for ( int i = 0; i < 209; i++) { - bcolor += texture2D(colortex5, texcoord.xy + noiseM*shadow_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - col = bcolor/209.0; - #endif -#endif + vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); vec3 bloom = texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5).rgb/2./7.0; float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette; - float VL_abs = texture2D(colortex7,texcoord).r; - VL_abs = clamp((1.0-VL_abs*1.05)*BLOOMY_FOG*0.5,0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0); + float VL_abs = texture2D(colortex7,texcoord).r; + float purkinje = rodExposureDepth.x/(1.0+rodExposureDepth.x)*Purkinje_strength; + + VL_abs = clamp( (1.0-VL_abs)*BLOOMY_FOG*0.75*(1.0-purkinje),0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0); + + float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0); + + col = (mix(col,bloom,VL_abs)+bloom * lightScat) * exposure.rgb; - col = ( mix(col, bloom, VL_abs) + bloom*lightScat) * exposure.rgb; -/* //Purkinje Effect - float lum = dot(col,vec3(0.15,0.3,0.55)); + float lum = dot(col,vec3(0.15,0.3,0.55)); float lum2 = dot(col,vec3(0.85,0.7,0.45))/2; - float rodLum = lum2*300.0; - float rodCurve = mix(1.0, rodLum/(2.5+rodLum), rodExposure/2.0*Purkinje_strength); - col = mix(lum*Purkinje_Multiplier*vec3(Purkinje_R, Purkinje_G, Purkinje_B)+0.001, col, rodCurve); -*/ + float rodLum = lum2*400.; + float rodCurve = mix(1.0, rodLum/(2.5+rodLum), purkinje); + col = mix(clamp(lum,0.0,0.05)*Purkinje_Multiplier*vec3(Purkinje_R, Purkinje_G, Purkinje_B)+1.5e-3, col, rodCurve); + #ifndef USE_ACES_COLORSPACE_APPROXIMATION - col = LinearTosRGB(TONEMAP(col)); + col = LinearTosRGB(TONEMAP(col)); #else col = col * ACESInputMat; col = TONEMAP(col); + col = LinearTosRGB(clamp(col * ACESOutputMat, 0.0, 1.0)); #endif - //col = ACESFitted(texture2D(colortex4,texcoord/3.).rgb/500.); - gl_FragData[0].rgb = clamp(int8Dither(col,texcoord),0.0,1.0); - //if (nightMode < 0.99 && texcoord.x < 0.5) gl_FragData[0].rgb =vec3(0.0,1.0,0.0); -} + + gl_FragData[0].rgb = clamp(int8Dither(col,texcoord),0.0,1.0); +} \ No newline at end of file diff --git a/shaders/world-1/composite15.vsh b/shaders/world-1/composite15.vsh index 3275077..e5dec68 100644 --- a/shaders/world-1/composite15.vsh +++ b/shaders/world-1/composite15.vsh @@ -1,13 +1,24 @@ #version 120 //#extension GL_EXT_gpu_shader4 : disable - #include "/lib/settings.glsl" + varying vec2 texcoord; flat varying vec4 exposure; -flat varying float rodExposure; +flat varying vec2 rodExposureDepth; uniform sampler2D colortex4; +uniform vec2 texelSize; +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.); + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -16,8 +27,12 @@ uniform sampler2D colortex4; void main() { + gl_Position = ftransform(); + + texcoord = gl_MultiTexCoord0.xy; exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r); - rodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r; + rodExposureDepth = texelFetch2D(colortex4,ivec2(14,37),0).rg; + rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0); } diff --git a/shaders/world-1/composite2.fsh b/shaders/world-1/composite2.fsh index 0d8fa72..711834a 100644 --- a/shaders/world-1/composite2.fsh +++ b/shaders/world-1/composite2.fsh @@ -469,8 +469,25 @@ void main() { // vec3 fogColor = (gl_Fog.color.rgb / max(pow(dot(gl_Fog.color.rgb,vec3(0.3333)),1.1),0.01) ) ; // vec3 FogColor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.01) ); - vec3 AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 30.0; + // vec3 AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 10.0; + vec3 up = skyCloudsFromTexLOD2( vec3(0,1,0), colortex4, 6).rgb/10; + vec3 down = skyCloudsFromTexLOD2(-vec3(0,1,0), colortex4, 6).rgb/10; + vec3 left = skyCloudsFromTexLOD2( vec3(1,0,0), colortex4, 6).rgb/10; + vec3 right = skyCloudsFromTexLOD2(-vec3(1,0,0), colortex4, 6).rgb/10; + vec3 front = skyCloudsFromTexLOD2( vec3(0,0,1), colortex4, 6).rgb/10; + vec3 back = skyCloudsFromTexLOD2(-vec3(0,0,1), colortex4, 6).rgb/10; + vec3 zero = vec3(0.0); + + up = mix(zero, up, pow(max( normal.y,0),2)); + down = mix(zero, down, pow(max(-normal.y,0),2)); + left = mix(zero, left, pow(max( normal.x,0),4)); + right = mix(zero, right, pow(max(-normal.x,0),4)); + front = mix(zero, front, pow(max( normal.z,0),4)); + back = mix(zero, back, pow(max(-normal.z,0),4)); + + vec3 AmbientLightColor = up + down + left + right + front + back; + // do all ambient lighting stuff vec3 Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3, p3 ); @@ -491,8 +508,8 @@ void main() { Emission(gl_FragData[0].rgb, albedo, SpecularTex.a); if(lightningBolt) gl_FragData[0].rgb += vec3(77.0, 153.0, 255.0); - - // gl_FragData[0].rgb = skyCloudsFromTexLOD2(np3, colortex4, 6).rgb / 30.0; + + // gl_FragData[0].rgb = AmbientLightColor; } diff --git a/shaders/world-1/deferred.fsh b/shaders/world-1/deferred.fsh index edb2e2b..7a39f29 100644 --- a/shaders/world-1/deferred.fsh +++ b/shaders/world-1/deferred.fsh @@ -4,28 +4,13 @@ #include "/lib/settings.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 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 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 rodExposure; +flat varying float avgL2; +flat varying float centerDepth; uniform sampler2D colortex4; uniform sampler2D noisetex; @@ -67,8 +52,6 @@ float interleaved_gradientNoise(){ float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } -vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.); -const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0); #include "/lib/nether_fog.glsl" @@ -102,8 +85,8 @@ gl_FragData[0].rgb = clamp(mix(temp,curr,0.05),0.0,65000.); //Exposure values if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(exposure,avgBrightness,exposureF,1.0); +gl_FragData[0] = vec4(exposure,avgBrightness,avgL2,1.0); if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(rodExposure,0.0,0.0,1.0); +gl_FragData[0] = vec4(rodExposure,centerDepth,0.0, 1.0); } diff --git a/shaders/world-1/deferred.vsh b/shaders/world-1/deferred.vsh index 7110679..92ced44 100644 --- a/shaders/world-1/deferred.vsh +++ b/shaders/world-1/deferred.vsh @@ -1,196 +1,108 @@ #version 120 + //#extension GL_EXT_gpu_shader4 : disable #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 sunColor; -flat varying vec3 sunColorCloud; -flat varying vec3 moonColor; -flat varying vec3 moonColorCloud; -flat varying vec3 lightSourceColor; -flat varying vec3 avgSky; 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; uniform sampler2D colortex4; uniform sampler2D colortex6; +uniform sampler2D depthtex0; uniform mat4 gbufferModelViewInverse; uniform vec3 sunPosition; uniform vec2 texelSize; -uniform float rainStrength; uniform float sunElevation; -uniform float nightVision; -uniform float frameTime; uniform float eyeAltitude; +uniform float near; +uniform float far; +uniform float frameTime; uniform int frameCounter; -uniform int worldTime; -vec3 sunVec = vec3(0.0,1.0,0.0); - +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)); } -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -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); return fract(alpha * n); } +float tanh(float x){ + return (exp(x) - exp(-x))/(exp(x) + exp(-x)); +} +float ld(float depth) { + return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near +} + +uniform float nightVision; + + void main() { gl_Position = ftransform()*0.5+0.5; 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); +////////////////////////////// +/// --- EXPOSURE 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); + float avgLuma = 0.0; + float m2 = 0.0; + int n=100; + vec2 clampedRes = max(1.0/texelSize,vec2(1920.0,1080.)); + float avgExp = 0.0; + float avgB = 0.0; + vec2 resScale = vec2(1920.,1080.)/clampedRes; + const int maxITexp = 50; + float w = 0.0; + for (int i = 0; i < maxITexp; i++){ + vec2 ij = R2_samples((frameCounter%2000)*maxITexp+i); + vec2 tc = 0.5 + (ij-0.5) * 0.7; + vec3 sp = texture2D(colortex6,tc/16. * resScale+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; + avgExp += log(luma(sp)); + avgB += log(min(dot(sp,vec3(0.07,0.22,0.71)),8e-2)); + } + + avgExp = exp(avgExp/maxITexp); + avgB = exp(avgB/maxITexp); + + avgBrightness = clamp(mix(avgExp,texelFetch2D(colortex4,ivec2(10,37),0).g,0.95),0.00003051757,65000.0); + + float L = max(avgBrightness,1e-8); + float keyVal = 1.03-2.0/(log(L*4000/150.*8./3.0+1.0)/log(10.0)+2.0); + float expFunc = 0.5+0.5*tanh(log(L)); + float targetExposure = 0.18/log2(L*2.5+1.045)*0.62; + + avgL2 = clamp(mix(avgB,texelFetch2D(colortex4,ivec2(10,37),0).b,0.985),0.00003051757,65000.0); + float targetrodExposure = max(0.012/log2(avgL2+1.002)-0.1,0.0)*1.2; + exposure = max(targetExposure*EXPOSURE_MULTIPLIER, 0); + float currCenterDepth = ld(texture2D(depthtex0, vec2(0.5)).r); + centerDepth = mix(sqrt(texelFetch2D(colortex4,ivec2(14,37),0).g/65000.0), currCenterDepth, clamp(DoF_Adaptation_Speed*exp(-0.016/frameTime+1.0)/(6.0+currCenterDepth*far),0.0,1.0)); + centerDepth = centerDepth * centerDepth * 65000.0; -// //Fake bounced sunlight -// vec3 bouncedSun = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)/4000.*0.08; -// ambientUp += bouncedSun*clamp(-sunVec.y+5.,0.,6.0); -// ambientLeft += bouncedSun*clamp(sunVec.x+5.,0.0,6.); -// ambientRight += bouncedSun*clamp(-sunVec.x+5.,0.0,6.); -// ambientB += bouncedSun*clamp(-sunVec.z+5.,0.0,6.); -// ambientF += bouncedSun*clamp(sunVec.z+5.,0.0,6.); -// ambientDown += bouncedSun*clamp(sunVec.y+5.,0.0,6.); + rodExposure = targetrodExposure; - -// float avgLuma = 0.0; -// float m2 = 0.0; -// int n=100; -// vec2 clampedRes = max(1.0/texelSize,vec2(1920.0,1080.)); -// float avgExp = 0.0; -// vec2 resScale = vec2(1920.,1080.)/clampedRes; -// float v[25]; -// float temp; -// // 5x5 Median filter by morgan mcguire -// // We take the median value of the most blurred bloom buffer -// #define s2(a, b) temp = a; a = min(a, b); b = max(temp, b); -// #define t2(a, b) s2(v[a], v[b]); -// #define t24(a, b, c, d, e, f, g, h) t2(a, b); t2(c, d); t2(e, f); t2(g, h); -// #define t25(a, b, c, d, e, f, g, h, i, j) t24(a, b, c, d, e, f, g, h); t2(i, j); -// for (int i = 0; i < 5; i++){ -// for (int j = 0; j < 5; j++){ -// vec2 tc = 0.5 + vec2(i-2,j-2)/2.0 * 0.35; -// v[i+j*5] = luma(texture2D(colortex6,tc/128. * resScale+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb); -// } -// } -// t25(0, 1, 3, 4, 2, 4, 2, 3, 6, 7); -// t25(5, 7, 5, 6, 9, 7, 1, 7, 1, 4); -// t25(12, 13, 11, 13, 11, 12, 15, 16, 14, 16); -// t25(14, 15, 18, 19, 17, 19, 17, 18, 21, 22); -// t25(20, 22, 20, 21, 23, 24, 2, 5, 3, 6); -// t25(0, 6, 0, 3, 4, 7, 1, 7, 1, 4); -// t25(11, 14, 8, 14, 8, 11, 12, 15, 9, 15); -// t25(9, 12, 13, 16, 10, 16, 10, 13, 20, 23); -// t25(17, 23, 17, 20, 21, 24, 18, 24, 18, 21); -// t25(19, 22, 8, 17, 9, 18, 0, 18, 0, 9); -// t25(10, 19, 1, 19, 1, 10, 11, 20, 2, 20); -// t25(2, 11, 12, 21, 3, 21, 3, 12, 13, 22); -// t25(4, 22, 4, 13, 14, 23, 5, 23, 5, 14); -// t25(15, 24, 6, 24, 6, 15, 7, 16, 7, 19); -// t25(3, 11, 5, 17, 11, 17, 9, 17, 4, 10); -// t25(6, 12, 7, 14, 4, 6, 4, 7, 12, 14); -// t25(10, 14, 6, 7, 10, 12, 6, 10, 6, 17); -// t25(12, 17, 7, 17, 7, 10, 12, 18, 7, 12); -// t24(10, 18, 12, 20, 10, 20, 10, 12); -// avgExp = v[12]; // Median value - - -// avgBrightness = clamp(mix(avgExp,texelFetch2D(colortex4,ivec2(10,37),0).g,0.95),0.00003051757,65000.0); - -// float currentExposure = texelFetch2D(colortex4,ivec2(10,37),0).b; -// float L = max(avgBrightness,1e-8); -// float keyVal = 1.03-2.0/(log(L+1.0)/log(10.0)+2.0); -// float targetExposure = 1.0*keyVal/L; - -// float targetrodExposure = clamp(log(targetExposure*2.0+1.0)-0.1,0.0,2.0); -// float currentrodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r; - -// targetExposure = clamp(targetExposure,2.0,3.0); -// float rad = sqrt(currentExposure); -// float rtarget = sqrt(targetExposure); -// float dir = sign(rtarget-rad); -// float dist = abs(rtarget-rad); -// float maxApertureChange = 0.0032*frameTime/0.016666*Exposure_Speed * exp2(max(rad,rtarget)*0.5); - -// maxApertureChange *= 1.0+nightVision*4.; -// rad = rad+dir*min(dist,maxApertureChange); - -// exposureF = rad*rad; -// exposure=exposureF*EXPOSURE_MULTIPLIER; - - -// dir = sign(targetrodExposure-currentrodExposure); -// dist = abs(targetrodExposure-currentrodExposure); -// maxApertureChange = 0.0032*frameTime/0.016666*Exposure_Speed * exp2(max(rad,rtarget)*0.5); - -// rodExposure = currentrodExposure + dir * min(dist,maxApertureChange); - - exposure = 1.0; - rodExposure = clamp(log(1.0*2.0+1.0)-0.1,0.0,2.0); - -} + #ifndef AUTO_EXPOSURE + exposure = Manual_exposure_value; + rodExposure = clamp(log(Manual_exposure_value*2.0+1.0)-0.1,0.0,2.0); + #endif +} \ No newline at end of file diff --git a/shaders/world-1/final.vsh b/shaders/world-1/final.vsh index 7b1c8e7..822a7b0 100644 --- a/shaders/world-1/final.vsh +++ b/shaders/world-1/final.vsh @@ -1,6 +1,5 @@ #version 120 //#extension GL_EXT_gpu_shader4 : disable - #include "/lib/settings.glsl" varying vec2 texcoord;