improved ambient light a little more in the nether. (thanks ambrosia). added auto exposure to the nether.

This commit is contained in:
Xonk 2023-07-30 00:26:44 -04:00
parent 40eca33f91
commit b11b795160
8 changed files with 161 additions and 610 deletions

View File

@ -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));

View File

@ -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<SAMPLES;i++) {
@ -75,7 +75,8 @@ vec4 GetVolumetricFog(
// do main lighting
float Density = cloudVol(progressW) * pow(exp(max(progressW.y-65,0.0) / -15),2);
float fireLight = cloudVol(progressW - vec3(0,1,0));
float fireLight = cloudVol(progressW - vec3(0,1,0)) * clamp(exp(max(30 - progressW.y,0.0) / -10.0),0,1);
vec3 vL0 = vec3(1.0,0.4,0.2) * exp(fireLight * -25) * exp(max(progressW.y-30,0.0) / -10) * 25;
vL0 += vec3(0.8,0.8,1.0) * (1.0 - exp(Density * -1)) / 10 ;
@ -85,8 +86,8 @@ vec4 GetVolumetricFog(
float Air = 0.01;
vec3 vL1 = fogcolor / 20.0;
vL += (vL0 - vL0*exp(-Density*dd*dL)) * absorbance;
vL += (vL1 - vL1*exp(-Air*dd*dL)) * absorbance;
vL += (vL0 - vL0*exp(-Density*dd*dL)) * absorbance;
absorbance *= exp(-(Density+Air)*dd*dL);

View File

@ -4,351 +4,27 @@
#include "/lib/settings.glsl"
#ifdef DOF
//hexagon pattern
const vec2 hex_offsets[60] = vec2[60] ( vec2( 0.2165, 0.1250 ),
vec2( 0.0000, 0.2500 ),
vec2( -0.2165, 0.1250 ),
vec2( -0.2165, -0.1250 ),
vec2( -0.0000, -0.2500 ),
vec2( 0.2165, -0.1250 ),
vec2( 0.4330, 0.2500 ),
vec2( 0.0000, 0.5000 ),
vec2( -0.4330, 0.2500 ),
vec2( -0.4330, -0.2500 ),
vec2( -0.0000, -0.5000 ),
vec2( 0.4330, -0.2500 ),
vec2( 0.6495, 0.3750 ),
vec2( 0.0000, 0.7500 ),
vec2( -0.6495, 0.3750 ),
vec2( -0.6495, -0.3750 ),
vec2( -0.0000, -0.7500 ),
vec2( 0.6495, -0.3750 ),
vec2( 0.8660, 0.5000 ),
vec2( 0.0000, 1.0000 ),
vec2( -0.8660, 0.5000 ),
vec2( -0.8660, -0.5000 ),
vec2( -0.0000, -1.0000 ),
vec2( 0.8660, -0.5000 ),
vec2( 0.2163, 0.3754 ),
vec2( -0.2170, 0.3750 ),
vec2( -0.4333, -0.0004 ),
vec2( -0.2163, -0.3754 ),
vec2( 0.2170, -0.3750 ),
vec2( 0.4333, 0.0004 ),
vec2( 0.4328, 0.5004 ),
vec2( -0.2170, 0.6250 ),
vec2( -0.6498, 0.1246 ),
vec2( -0.4328, -0.5004 ),
vec2( 0.2170, -0.6250 ),
vec2( 0.6498, -0.1246 ),
vec2( 0.6493, 0.6254 ),
vec2( -0.2170, 0.8750 ),
vec2( -0.8663, 0.2496 ),
vec2( -0.6493, -0.6254 ),
vec2( 0.2170, -0.8750 ),
vec2( 0.8663, -0.2496 ),
vec2( 0.2160, 0.6259 ),
vec2( -0.4340, 0.5000 ),
vec2( -0.6500, -0.1259 ),
vec2( -0.2160, -0.6259 ),
vec2( 0.4340, -0.5000 ),
vec2( 0.6500, 0.1259 ),
vec2( 0.4325, 0.7509 ),
vec2( -0.4340, 0.7500 ),
vec2( -0.8665, -0.0009 ),
vec2( -0.4325, -0.7509 ),
vec2( 0.4340, -0.7500 ),
vec2( 0.8665, 0.0009 ),
vec2( 0.2158, 0.8763 ),
vec2( -0.6510, 0.6250 ),
vec2( -0.8668, -0.2513 ),
vec2( -0.2158, -0.8763 ),
vec2( 0.6510, -0.6250 ),
vec2( 0.8668, 0.2513 ));
#include "/lib/res_params.glsl"
const vec2 offsets[60] = vec2[60] ( vec2( 0.0000, 0.2500 ),
vec2( -0.2165, 0.1250 ),
vec2( -0.2165, -0.1250 ),
vec2( -0.0000, -0.2500 ),
vec2( 0.2165, -0.1250 ),
vec2( 0.2165, 0.1250 ),
vec2( 0.0000, 0.5000 ),
vec2( -0.2500, 0.4330 ),
vec2( -0.4330, 0.2500 ),
vec2( -0.5000, 0.0000 ),
vec2( -0.4330, -0.2500 ),
vec2( -0.2500, -0.4330 ),
vec2( -0.0000, -0.5000 ),
vec2( 0.2500, -0.4330 ),
vec2( 0.4330, -0.2500 ),
vec2( 0.5000, -0.0000 ),
vec2( 0.4330, 0.2500 ),
vec2( 0.2500, 0.4330 ),
vec2( 0.0000, 0.7500 ),
vec2( -0.2565, 0.7048 ),
vec2( -0.4821, 0.5745 ),
vec2( -0.6495, 0.3750 ),
vec2( -0.7386, 0.1302 ),
vec2( -0.7386, -0.1302 ),
vec2( -0.6495, -0.3750 ),
vec2( -0.4821, -0.5745 ),
vec2( -0.2565, -0.7048 ),
vec2( -0.0000, -0.7500 ),
vec2( 0.2565, -0.7048 ),
vec2( 0.4821, -0.5745 ),
vec2( 0.6495, -0.3750 ),
vec2( 0.7386, -0.1302 ),
vec2( 0.7386, 0.1302 ),
vec2( 0.6495, 0.3750 ),
vec2( 0.4821, 0.5745 ),
vec2( 0.2565, 0.7048 ),
vec2( 0.0000, 1.0000 ),
vec2( -0.2588, 0.9659 ),
vec2( -0.5000, 0.8660 ),
vec2( -0.7071, 0.7071 ),
vec2( -0.8660, 0.5000 ),
vec2( -0.9659, 0.2588 ),
vec2( -1.0000, 0.0000 ),
vec2( -0.9659, -0.2588 ),
vec2( -0.8660, -0.5000 ),
vec2( -0.7071, -0.7071 ),
vec2( -0.5000, -0.8660 ),
vec2( -0.2588, -0.9659 ),
vec2( -0.0000, -1.0000 ),
vec2( 0.2588, -0.9659 ),
vec2( 0.5000, -0.8660 ),
vec2( 0.7071, -0.7071 ),
vec2( 0.8660, -0.5000 ),
vec2( 0.9659, -0.2588 ),
vec2( 1.0000, -0.0000 ),
vec2( 0.9659, 0.2588 ),
vec2( 0.8660, 0.5000 ),
vec2( 0.7071, 0.7071 ),
vec2( 0.5000, 0.8660 ),
vec2( 0.2588, 0.9659 ));
const vec2 shadow_offsets[209] = vec2[209](vec2(0.8886414f , 0.07936136f),
vec2(0.8190064f , 0.1900164f),
vec2(0.8614115f , -0.06991258f),
vec2(0.7685533f , 0.03792081f),
vec2(0.9970094f , 0.02585129f),
vec2(0.9686818f , 0.1570935f),
vec2(0.9854341f , -0.09172997f),
vec2(0.9330608f , 0.3326486f),
vec2(0.8329557f , -0.2438523f),
vec2(0.664771f , -0.0837701f),
vec2(0.7429124f , -0.1530652f),
vec2(0.9506453f , -0.2174281f),
vec2(0.8192949f , 0.3485171f),
vec2(0.6851269f , 0.2711877f),
vec2(0.7665657f , 0.5014166f),
vec2(0.673241f , 0.3793408f),
vec2(0.6981376f , 0.1465924f),
vec2(0.6521665f , -0.2384985f),
vec2(0.5145761f , -0.05752508f),
vec2(0.5641244f , -0.169443f),
vec2(0.5916035f , 0.06004957f),
vec2(0.57079f , 0.234188f),
vec2(0.509311f , 0.1523665f),
vec2(0.4204576f , 0.05759521f),
vec2(0.8200846f , -0.3601041f),
vec2(0.6893264f , -0.3473432f),
vec2(0.4775535f , -0.3062558f),
vec2(0.438106f , -0.1796866f),
vec2(0.4056528f , -0.08251233f),
vec2(0.5771964f , 0.5502692f),
vec2(0.5094061f , 0.4025192f),
vec2(0.6908483f , 0.572951f),
vec2(0.5379036f , -0.4542191f),
vec2(0.8167359f , -0.4793735f),
vec2(0.6829269f , -0.4557574f),
vec2(0.5725697f , -0.3477072f),
vec2(0.5767449f , -0.5782524f),
vec2(0.3979413f , -0.4172934f),
vec2(0.4282598f , -0.5145645f),
vec2(0.938814f , -0.3239739f),
vec2(0.702452f , -0.5662871f),
vec2(0.2832307f , -0.1285671f),
vec2(0.3230537f , -0.2691054f),
vec2(0.2921676f , -0.3734582f),
vec2(0.2534037f , -0.4906001f),
vec2(0.4343273f , 0.5223463f),
vec2(0.3605334f , 0.3151571f),
vec2(0.3498518f , 0.451428f),
vec2(0.3230703f , 0.00287089f),
vec2(0.1049206f , -0.1476725f),
vec2(0.2063161f , -0.2608192f),
vec2(0.7266634f , 0.6725333f),
vec2(0.4027067f , -0.6185485f),
vec2(0.2655533f , -0.5912259f),
vec2(0.4947965f , 0.3025357f),
vec2(0.5760762f , 0.68844f),
vec2(0.4909205f , -0.6975324f),
vec2(0.8609334f , 0.4559f),
vec2(0.1836646f , 0.03724086f),
vec2(0.2878554f , 0.178938f),
vec2(0.3948484f , 0.1618928f),
vec2(0.3519658f , -0.7628763f),
vec2(0.6338583f , -0.673193f),
vec2(0.5511802f , -0.8283072f),
vec2(0.4090595f , -0.8717521f),
vec2(0.1482169f , -0.374728f),
vec2(0.1050598f , -0.2613987f),
vec2(0.4210334f , 0.6578422f),
vec2(0.2430464f , 0.4383665f),
vec2(0.3329675f , 0.5512741f),
vec2(0.2147711f , 0.3245511f),
vec2(0.1227196f , 0.2529026f),
vec2(-0.03937457f , 0.156439f),
vec2(0.05618772f , 0.06690486f),
vec2(0.06519571f , 0.3974038f),
vec2(0.1360903f , 0.1466078f),
vec2(-0.00170609f , 0.3089452f),
vec2(0.1357622f , -0.5088975f),
vec2(0.1604694f , -0.7453476f),
vec2(0.1245694f , -0.6337074f),
vec2(0.02542936f , -0.3728781f),
vec2(0.02222222f , -0.649554f),
vec2(0.09870815f , 0.5357338f),
vec2(0.2073958f , 0.5452989f),
vec2(0.216654f , -0.8935689f),
vec2(0.2422334f , 0.665805f),
vec2(0.0574713f , 0.6742729f),
vec2(0.2021346f , 0.8144029f),
vec2(0.3086587f , 0.7504997f),
vec2(0.02122174f , -0.7498575f),
vec2(-0.1551729f , 0.1809731f),
vec2(-0.1947583f , 0.06246066f),
vec2(-0.05754202f , -0.03901273f),
vec2(-0.1083095f , 0.2952235f),
vec2(-0.03259534f , -0.492394f),
vec2(-0.02488567f , -0.2081116f),
vec2(-0.1820729f , -0.1829884f),
vec2(-0.1674413f , -0.04529009f),
vec2(0.04342153f , -0.0368562f),
vec2(0.801399f , -0.5845526f),
vec2(0.3158276f , -0.9124843f),
vec2(-0.05945269f , 0.6727523f),
vec2(0.07701834f , 0.8579889f),
vec2(-0.05778154f , 0.5699022f),
vec2(0.1191713f , 0.7542591f),
vec2(-0.2578296f , 0.3630984f),
vec2(-0.1428598f , 0.4557526f),
vec2(-0.3304029f , 0.5055485f),
vec2(-0.3227198f , 0.1847367f),
vec2(-0.4183801f , 0.3412776f),
vec2(0.2538475f , 0.9317476f),
vec2(0.406249f , 0.8423664f),
vec2(0.4718862f , 0.7592828f),
vec2(0.168472f , -0.06605823f),
vec2(0.2632498f , -0.7084918f),
vec2(-0.2816192f , -0.1023492f),
vec2(-0.3161443f , 0.02489911f),
vec2(-0.4677814f , 0.08450397f),
vec2(-0.4156994f , 0.2408664f),
vec2(-0.237449f , 0.2605326f),
vec2(-0.0912179f , 0.06491816f),
vec2(0.01475127f , 0.7670643f),
vec2(0.1216858f , -0.9368939f),
vec2(0.07010741f , -0.841011f),
vec2(-0.1708607f , -0.4152923f),
vec2(-0.1345006f , -0.5842513f),
vec2(-0.09419055f , -0.3213732f),
vec2(-0.2149337f , 0.730642f),
vec2(-0.1102187f , 0.8425013f),
vec2(-0.1808572f , 0.6244397f),
vec2(-0.2414505f , -0.7063725f),
vec2(-0.2410318f , -0.537854f),
vec2(-0.1005938f , -0.7635075f),
vec2(0.1053517f , 0.9678772f),
vec2(-0.3340288f , 0.6926677f),
vec2(-0.2363931f , 0.8464488f),
vec2(-0.4057773f , 0.7786722f),
vec2(-0.5484858f , 0.1686208f),
vec2(-0.64842f , 0.02256887f),
vec2(-0.5544513f , -0.02348978f),
vec2(-0.492855f , -0.1083694f),
vec2(-0.4248196f , 0.4674786f),
vec2(-0.5873146f , 0.4072608f),
vec2(-0.6439911f , 0.3038489f),
vec2(-0.6419188f , 0.1293737f),
vec2(-0.005880734f , 0.4699725f),
vec2(-0.4239455f , 0.6250131f),
vec2(-0.1701273f , 0.9506347f),
vec2(7.665656E-05f , 0.9941212f),
vec2(-0.7070159f , 0.4426281f),
vec2(-0.7481344f , 0.3139496f),
vec2(-0.8330062f , 0.2472693f),
vec2(-0.7271438f , 0.2024286f),
vec2(-0.5179888f , 0.3149576f),
vec2(-0.8258062f , 0.3779382f),
vec2(-0.8063191f , 0.1262931f),
vec2(-0.2690676f , -0.4360798f),
vec2(-0.3714577f , -0.5887412f),
vec2(-0.3736085f , -0.4018324f),
vec2(-0.3228985f , -0.2063406f),
vec2(-0.2414576f , -0.2875458f),
vec2(-0.4720859f , -0.3823904f),
vec2(-0.4937642f , -0.2686005f),
vec2(-0.01500604f , -0.9587054f),
vec2(-0.08535925f , -0.8820614f),
vec2(-0.6436375f , -0.3157263f),
vec2(-0.5736347f , -0.4224878f),
vec2(-0.5026127f , -0.5516239f),
vec2(-0.8200902f , 0.5370023f),
vec2(-0.7196413f , 0.57133f),
vec2(-0.5849072f , 0.5917885f),
vec2(-0.1598758f , -0.9739854f),
vec2(-0.4230629f , -0.01858409f),
vec2(-0.9403627f , 0.2213769f),
vec2(-0.685889f , -0.2192711f),
vec2(-0.6693704f , -0.4884708f),
vec2(-0.7967147f , -0.3078234f),
vec2(-0.596441f , -0.1686891f),
vec2(-0.7366468f , -0.3939891f),
vec2(-0.7963406f , 0.02246814f),
vec2(-0.9177913f , 0.0929693f),
vec2(-0.9284672f , 0.3329005f),
vec2(-0.6497722f , 0.6851863f),
vec2(-0.496019f , 0.7013303f),
vec2(-0.3930301f , -0.6892192f),
vec2(-0.2122009f , -0.8777389f),
vec2(-0.3660335f , -0.801644f),
vec2(-0.386839f , -0.1191898f),
vec2(-0.7020127f , -0.0776734f),
vec2(-0.7760845f , -0.1566844f),
vec2(-0.5444778f , -0.6516482f),
vec2(-0.5331346f , 0.4946506f),
vec2(-0.3288236f , 0.9408244f),
vec2(0.5819826f , 0.8101937f),
vec2(-0.4894184f , -0.8290837f),
vec2(-0.5183194f , 0.8454953f),
vec2(-0.7665774f , -0.5223897f),
vec2(-0.6703191f , -0.6217513f),
vec2(-0.8902924f , -0.2446688f),
vec2(-0.8574848f , -0.09174173f),
vec2(-0.3544409f , -0.9239591f),
vec2(-0.969833f , -0.1172272f),
vec2(-0.8968207f , -0.4079512f),
vec2(-0.5891477f , 0.7724466f),
vec2(-0.2146262f , 0.5286855f),
vec2(-0.3762444f , -0.3014335f),
vec2(-0.9466863f , -0.008970681f),
vec2(-0.596356f , -0.7976127f),
vec2(-0.8877738f , 0.4569088f));
#endif
flat varying vec4 exposure;
flat varying float rodExposure;
flat varying vec2 rodExposureDepth;
varying vec2 texcoord;
uniform sampler2D colortex4;
const bool colortex5MipmapEnabled = true;
// uniform sampler2D colortex4;
uniform sampler2D colortex5;
uniform sampler2D colortex3;
// uniform sampler2D colortex6;
uniform sampler2D colortex7;
// uniform sampler2D colortex8; // specular
// uniform sampler2D colortex9; // specular
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D noisetex;
uniform vec2 texelSize;
uniform ivec2 eyeBrightnessSmooth;
uniform float viewWidth;
uniform float viewHeight;
uniform float frameTimeCounter;
@ -357,12 +33,28 @@ uniform int isEyeInWater;
uniform float near;
uniform float aspectRatio;
uniform float far;
uniform float rainStrength;
uniform float screenBrightness;
uniform vec4 Moon_Weather_properties; // R = cloud coverage G = fog density
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.);
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferProjectionInverse;
vec4 Weather_properties = Moon_Weather_properties;
#include "/lib/color_transforms.glsl"
#include "/lib/color_dither.glsl"
// #include "/lib/biome_specifics.glsl"
#include "/lib/bokeh.glsl"
float cdist(vec2 coord) {
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
@ -373,111 +65,43 @@ float blueNoise(){
float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
}
vec3 closestToCamera3x3()
{
vec2 du = vec2(texelSize.x, 0.0);
vec2 dv = vec2(0.0, texelSize.y);
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depthtex0, texcoord - dv - du).x);
vec3 dtc = vec3(texcoord,0.) + vec3( 0.0, -texelSize.y, texture2D(depthtex0, texcoord - dv).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depthtex0, texcoord - dv + du).x);
vec3 dml = vec3(texcoord,0.) + vec3(-texelSize.x, 0.0, texture2D(depthtex0, texcoord - du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depthtex0, texcoord).x);
vec3 dmr = vec3(texcoord,0.) + vec3( texelSize.x, 0.0, texture2D(depthtex0, texcoord + du).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv - du).x);
vec3 dbc = vec3(texcoord,0.) + vec3( 0.0, texelSize.y, texture2D(depthtex0, texcoord + dv).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv + du).x);
vec3 dmin = dmc;
dmin = dmin.z > 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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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
}

View File

@ -1,6 +1,5 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
#include "/lib/settings.glsl"
varying vec2 texcoord;