mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
add floodfill light propagation in vl fog. fix up nether and end shaders. tweaked shadows some. improved filtering for shadows/ssao, and VL fog. improved the "clouds intersect terrain" setting
This commit is contained in:
@ -1,8 +1,16 @@
|
||||
uniform float far;
|
||||
uniform int dhRenderDistance;
|
||||
|
||||
const float k = 1.8;
|
||||
const float d0 = 0.04 + max(64.0 - shadowDistance, 0.0)/64.0 * 0.26;
|
||||
const float d0 = 0.04 + max(64.0 - shadowDistance, 0.0)/64.0 * 0.26;
|
||||
const float d1 = 0.61;
|
||||
float a = exp(d0);
|
||||
float b = (exp(d1)-a)*150./128.0;
|
||||
// thank you Espen
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
float b = (exp(d1)-a)*min(dhRenderDistance, shadowDistance)/shadowDistance;
|
||||
#else
|
||||
float b = (exp(d1)-a)*min(far+16.0*3.5, shadowDistance)/shadowDistance;
|
||||
#endif
|
||||
|
||||
vec4 BiasShadowProjection(in vec4 projectedShadowSpacePosition) {
|
||||
|
||||
@ -13,67 +21,4 @@ vec4 BiasShadowProjection(in vec4 projectedShadowSpacePosition) {
|
||||
|
||||
float calcDistort(vec2 worldpos){
|
||||
return 1.0/(log(length(worldpos)*b+a)*k);
|
||||
}
|
||||
|
||||
uniform float far;
|
||||
|
||||
/*
|
||||
mat4 BuildOrthoProjectionMatrix(const in float width, const in float height, const in float zNear, const in float zFar) {
|
||||
return mat4(
|
||||
vec4(2.0 / width, 0.0, 0.0, 0.0),
|
||||
vec4(0.0, 2.0 / height, 0.0, 0.0),
|
||||
vec4(0.0, 0.0, -2.0 / (zFar - zNear), 0.0),
|
||||
vec4(0.0, 0.0, -(zFar + zNear)/(zFar - zNear), 1.0));
|
||||
}
|
||||
|
||||
mat4 BuildTranslationMatrix(const in vec3 delta) {
|
||||
return mat4(
|
||||
vec4(1.0, 0.0, 0.0, 0.0),
|
||||
vec4(0.0, 1.0, 0.0, 0.0),
|
||||
vec4(0.0, 0.0, 1.0, 0.0),
|
||||
vec4(delta, 1.0));
|
||||
}
|
||||
|
||||
uniform vec3 CamPos;
|
||||
|
||||
// vec3 LightDir = vec3(1.0, 0.5, 1.0);
|
||||
|
||||
float rate = frameTimeCounter;
|
||||
vec3 LightDir = vec3(sin(rate), 0.3, cos(rate));
|
||||
// vec3 LightDir = vec3(cos(rate),sin(rate),cos(rate));
|
||||
|
||||
const float shadowIntervalSize = 2.0f;
|
||||
vec3 GetShadowIntervalOffset() {
|
||||
return fract(CamPos / shadowIntervalSize) * shadowIntervalSize - vec3(3,0,1);
|
||||
}
|
||||
|
||||
mat4 BuildShadowViewMatrix(const in vec3 localLightDir) {
|
||||
const vec3 worldUp = vec3(1, 0, 0);
|
||||
|
||||
vec3 zaxis = localLightDir;
|
||||
|
||||
// float check = localLightDir.y;
|
||||
// if(check < 0.0) zaxis.y = -zaxis.y;
|
||||
|
||||
vec3 xaxis = normalize(cross(worldUp, zaxis));
|
||||
vec3 yaxis = normalize(cross(zaxis, xaxis));
|
||||
|
||||
mat4 shadowModelViewEx = mat4(1.0);
|
||||
shadowModelViewEx[0].xyz = vec3(xaxis.x, yaxis.x, zaxis.x);
|
||||
shadowModelViewEx[1].xyz = vec3(xaxis.y, yaxis.y, zaxis.y);
|
||||
shadowModelViewEx[2].xyz = vec3(xaxis.z, yaxis.z, zaxis.z);
|
||||
|
||||
vec3 intervalOffset = GetShadowIntervalOffset();
|
||||
mat4 translation = BuildTranslationMatrix(intervalOffset);
|
||||
|
||||
return shadowModelViewEx * translation;
|
||||
}
|
||||
|
||||
mat4 BuildShadowProjectionMatrix() {
|
||||
float maxDist = min(shadowDistance, far);
|
||||
return BuildOrthoProjectionMatrix(maxDist, maxDist, -far, far);
|
||||
}
|
||||
|
||||
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
|
||||
// mat4 Custom_ProjectionMatrix = BuildShadowProjectionMatrix();
|
||||
*/
|
||||
}
|
@ -7,28 +7,20 @@ void GriAndEminShadowFix(
|
||||
float VanillaAO,
|
||||
float SkyLightmap
|
||||
){
|
||||
// #ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
// float minimumValue = 0.3;
|
||||
// #else
|
||||
float minimumValue = 0.05;
|
||||
// #endif
|
||||
|
||||
float minvalue = 0.007;
|
||||
float DistanceOffset = max(length(WorldPos) * 0.005, minimumValue);
|
||||
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
minvalue = 0.035;
|
||||
#endif
|
||||
|
||||
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
|
||||
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
|
||||
float shadowResScale = (2048.0/shadowMapResolution) / 4.0;
|
||||
float DistanceOffset = (length(WorldPos)+4.0) * (minvalue + shadowResScale*0.015);
|
||||
|
||||
|
||||
|
||||
vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away.
|
||||
|
||||
vec3 finalBias = Bias;
|
||||
vec3 Bias = FlatNormal * DistanceOffset;
|
||||
|
||||
// stop lightleaking by zooming up, centered on blocks
|
||||
vec2 scale = vec2(0.5); scale.y *= 0.5;
|
||||
vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y);
|
||||
if(SkyLightmap < 0.1) finalBias = mix(Bias, zoomShadow, clamp(VanillaAO*5,0,1));
|
||||
if(SkyLightmap < 0.1) Bias = zoomShadow;
|
||||
|
||||
WorldPos += finalBias;
|
||||
WorldPos += Bias;
|
||||
}
|
@ -40,8 +40,9 @@ vec3 DoAmbientLightColor(
|
||||
|
||||
// do torch lighting
|
||||
float TorchLM = pow(1.0-sqrt(1.0-clamp(Lightmap.x,0.0,1.0)),2.0) * 2.0;
|
||||
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*Exposure),0.0,1.0)) ;
|
||||
vec3 TorchLight = TorchColor * TorchLM * TORCH_AMOUNT ;
|
||||
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*Exposure),0.0,1.0));
|
||||
|
||||
vec3 TorchLight = TorchColor * TorchLM * TORCH_AMOUNT;
|
||||
|
||||
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
|
||||
vec4 lpvSample = SampleLpvLinear(lpvPos);
|
||||
@ -54,7 +55,7 @@ vec3 DoAmbientLightColor(
|
||||
|
||||
LpvFadeF = 1.0 - pow(1.0-pow(LpvFadeF,1.5),3.0); // make it nice and soft :)
|
||||
|
||||
TorchLight = mix(TorchLight,LpvTorchLight/5.0, LpvFadeF);
|
||||
TorchLight = mix(TorchLight, LpvTorchLight/5.0, LpvFadeF);
|
||||
|
||||
const vec3 normal = vec3(0.0); // TODO
|
||||
|
||||
|
@ -34,7 +34,7 @@ SOFTWARE.*/
|
||||
p *= p + p;
|
||||
return fract(p);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
// Integer Hash - II
|
||||
@ -142,11 +142,11 @@ void VolumeBounds(inout float Volume, vec3 Origin){
|
||||
|
||||
// create the volume shape
|
||||
float fogShape(in vec3 pos){
|
||||
|
||||
float vortexBounds = clamp(vortexBoundRange - length(pos), 0.0,1.0);
|
||||
vec3 samplePos = pos*vec3(1.0,1.0/48.0,1.0);
|
||||
float fogYstart = -60;
|
||||
|
||||
|
||||
// this is below down where you fall to your death.
|
||||
float voidZone = max(exp2(-1.0 * sqrt(max(pos.y - -60,0.0))) ,0.0) ;
|
||||
|
||||
@ -207,7 +207,11 @@ vec3 LightSourceLighting(vec3 startPos, vec3 lightPos, float noise, float densit
|
||||
|
||||
return finalLighting;
|
||||
}
|
||||
|
||||
//Mie phase function
|
||||
float phaseEND(float x, float g){
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14;
|
||||
}
|
||||
vec4 GetVolumetricFog(
|
||||
vec3 viewPosition,
|
||||
float dither,
|
||||
@ -216,82 +220,115 @@ vec4 GetVolumetricFog(
|
||||
#ifndef TOGGLE_VL_FOG
|
||||
return vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
|
||||
/// ------------- RAYMARCHING STUFF ------------- \\\
|
||||
|
||||
int SAMPLES = 16;
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = vec3(0.0);
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = fragposition - start;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
vec3 progressW = vec3(0.0);
|
||||
|
||||
float maxLength = min(length(dVWorld),32.0 * 12.0)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
|
||||
dVWorld *= maxLength;
|
||||
float dL = length(dVWorld);
|
||||
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
float dL = length(dVWorld);
|
||||
float expFactor = 11.0;
|
||||
|
||||
/// ------------- COLOR/LIGHTING STUFF ------------- \\\
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
vec3 absorbance = vec3(1.0);
|
||||
int SAMPLECOUNT = 16;
|
||||
|
||||
vec3 fogcolor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.05)) ;
|
||||
vec3 color = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
float CenterdotV = dot(normalize(vec3(0,100,0)-cameraPosition), normalize(wpos + cameraPosition));
|
||||
|
||||
// float phsething = phaseEND(CenterdotV, 0.35) + phaseEND(CenterdotV, 0.85) ;
|
||||
|
||||
float skyPhase = 0.5 + pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0;
|
||||
|
||||
vec3 hazeColor = normalize(gl_Fog.color.rgb) * 0.1;
|
||||
|
||||
float lightningflash = texelFetch2D(colortex4,ivec2(1,1),0).x/150.0;
|
||||
|
||||
float expFactor = 11.0;
|
||||
for (int i=0;i<SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) / 5.0;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SAMPLECOUNT; i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
|
||||
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
// determine where the vortex area ends and chaotic lightning area begins.
|
||||
float vortexBounds = clamp(vortexBoundRange - length(progressW), 0.0,1.0);
|
||||
|
||||
vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds);
|
||||
vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
|
||||
//------ END STORM EFFECT
|
||||
|
||||
float volumeDensity = fogShape(progressW);
|
||||
|
||||
float clearArea = 1.0-min(max(1.0 - length(progressW - cameraPosition) / 100,0.0),1.0);
|
||||
float stormDensity = min(volumeDensity, clearArea*clearArea * END_STORM_DENSTIY);
|
||||
float volumeCoeff = exp(-stormDensity*dd*dL);
|
||||
|
||||
// determine where the vortex area ends and chaotic lightning area begins.
|
||||
float vortexBounds = clamp(vortexBoundRange - length(progressW), 0.0,1.0);
|
||||
|
||||
vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds);
|
||||
vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
|
||||
|
||||
vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither2, volumeDensity, lightColors, vortexBounds);
|
||||
vec3 indirect = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1);
|
||||
vec3 stormLighting = indirect + lightsources;
|
||||
|
||||
color += (stormLighting - stormLighting*volumeCoeff) * absorbance;
|
||||
absorbance *= volumeCoeff;
|
||||
|
||||
//------ HAZE EFFECT
|
||||
// dont make haze contrube to absorbance.
|
||||
float hazeDensity = 0.001;
|
||||
vec3 hazeLighting = vec3(0.3,0.6,1.0) * skyPhase;
|
||||
color += (hazeLighting - hazeLighting*exp(-hazeDensity*dd*dL)) * absorbance;
|
||||
|
||||
|
||||
// // determine where the vortex area ends and chaotic lightning area begins.
|
||||
// float vortexBounds = clamp(vortexBoundRange - length(progressW), 0.0,1.0);
|
||||
|
||||
// vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds);
|
||||
// vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
|
||||
|
||||
float volumeDensity = fogShape(progressW);
|
||||
// volumeDensity += max(1.0 - length(vec3(lightPosition.x,lightPosition.y*2,lightPosition.z))/50,0.0) * vortexBounds;
|
||||
|
||||
float clearArea = 1.0-min(max(1.0 - length(progressW - cameraPosition) / 100,0.0),1.0);
|
||||
float density = min(volumeDensity * clearArea, END_STORM_DENSTIY);
|
||||
// float clearArea = 1.0-min(max(1.0 - length(progressW - cameraPosition) / 100,0.0),1.0);
|
||||
// float density = min(volumeDensity * clearArea, END_STORM_DENSTIY);
|
||||
|
||||
///// ----- air lighting, the haze
|
||||
float distanceFog = max(1.0 - length(progressW - cameraPosition) / max(far, 32.0 * 13.0),0.0);
|
||||
float hazeDensity = min(exp2(distanceFog * -25)+0.0005,1.0);
|
||||
vec3 hazeColor = vec3(0.3,0.75,1.0) * 0.3;
|
||||
color += (hazeColor - hazeColor*exp(-hazeDensity*dd*dL)) * absorbance;
|
||||
// ///// ----- air lighting, the haze
|
||||
// float distanceFog = max(1.0 - length(progressW - cameraPosition) / max(far, 32.0 * 13.0),0.0);
|
||||
// float hazeDensity = min(exp2(distanceFog * -25)+0.0005,1.0);
|
||||
// vec3 hazeColor = vec3(0.3,0.75,1.0) * 0.3;
|
||||
// color += (hazeColor - hazeColor*exp(-hazeDensity*dd*dL)) * absorbance;
|
||||
|
||||
///// ----- main lighting
|
||||
vec3 voidLighting = vec3(1.0,0.0,0.8) * 0.1 * (1-exp(volumeDensity * -25)) * max(exp2(-1 * sqrt(max(progressW.y - -60,0.0))),0.0) ;
|
||||
// ///// ----- main lighting
|
||||
// vec3 voidLighting = vec3(1.0,0.0,0.8) * 0.1 * (1-exp(volumeDensity * -25)) * max(exp2(-1 * sqrt(max(progressW.y - -60,0.0))),0.0) ;
|
||||
|
||||
vec3 ambient = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1);
|
||||
float shadows = 0;
|
||||
vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither2, volumeDensity, lightColors, vortexBounds);
|
||||
vec3 lighting = lightsources + ambient + voidLighting;
|
||||
// vec3 ambient = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1);
|
||||
// float shadows = 0;
|
||||
// vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither2, volumeDensity, lightColors, vortexBounds);
|
||||
// vec3 lighting = lightsources + ambient + voidLighting;
|
||||
|
||||
#ifdef THE_ORB
|
||||
density += min(50.0*max(1.0 - length(lightPosition)/10,0.0),1.0);
|
||||
// #ifdef THE_ORB
|
||||
// density += min(50.0*max(1.0 - length(lightPosition)/10,0.0),1.0);
|
||||
// #endif
|
||||
|
||||
// ///// ----- blend
|
||||
// color += (lighting - lighting*exp(-(density)*dd*dL)) * absorbance;
|
||||
// absorbance *= exp(-max(density,hazeDensity)*dd*dL);
|
||||
|
||||
//------ LPV FOG EFFECT
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * TorchBrightness_autoAdjust * absorbance;
|
||||
#endif
|
||||
|
||||
///// ----- blend
|
||||
color += (lighting - lighting*exp(-(density)*dd*dL)) * absorbance;
|
||||
absorbance *= exp(-max(density,hazeDensity)*dd*dL);
|
||||
}
|
||||
// return vec4(0.0,0.0,0.0,1.0);
|
||||
return vec4(color, absorbance);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// LPV block brightness scale
|
||||
const float LpvBlockBrightness = 2.0;
|
||||
const float LpvBlockBrightness = 1.0;
|
||||
|
||||
|
||||
float lpvCurve(float values) {
|
||||
|
@ -13,10 +13,8 @@ float densityAtPosFog(in vec3 pos){
|
||||
}
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
float Output = 0.0;
|
||||
vec3 samplePos = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
|
||||
float Wind = pow(max(pos.y-30,0.0) / 15.0,2.1);
|
||||
|
||||
float Plumes = texture2D(noisetex, (samplePos.xz + Wind)/256.0).b;
|
||||
@ -25,83 +23,91 @@ float cloudVol(in vec3 pos){
|
||||
|
||||
float Erosion = densityAtPosFog(samplePos * 400 - frameTimeCounter*10 - Wind*10) *0.7+0.3 ;
|
||||
|
||||
// float maxdist = clamp((12 * 8) - length(pos - cameraPosition),0.0,1.0);
|
||||
|
||||
float RoofToFloorDensityFalloff = exp(max(100-pos.y,0.0) / -15);
|
||||
float FloorDensityFalloff = pow(exp(max(pos.y-31,0.0) / -3.0),2);
|
||||
float RoofDensityFalloff = exp(max(120-pos.y,0.0) / -10);
|
||||
|
||||
Output = max((RoofToFloorDensityFalloff - Plumes * (1.0-Erosion)) * 2.0, clamp((FloorDensityFalloff - floorPlumes*0.5) * Erosion ,0.0,1.0) );
|
||||
float Output = max((RoofToFloorDensityFalloff - Plumes * (1.0-Erosion)) * 2.0, clamp((FloorDensityFalloff - floorPlumes*0.5) * Erosion ,0.0,1.0) );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
vec4 GetVolumetricFog(
|
||||
vec3 viewPos,
|
||||
vec3 viewPosition,
|
||||
float dither,
|
||||
float dither2
|
||||
){
|
||||
|
||||
#ifndef TOGGLE_VL_FOG
|
||||
return vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
int SAMPLES = 16;
|
||||
vec3 vL = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
/// ------------- RAYMARCHING STUFF ------------- \\\
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = toShadowSpaceProjected(vec3(0.));
|
||||
int SAMPLECOUNT = 10;
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = fragposition-start;
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
vec3 progressW = vec3(0.0);
|
||||
|
||||
float maxLength = min(length(dVWorld),far)/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.05)) ;
|
||||
|
||||
float expFactor = 11.0;
|
||||
for (int i=0;i<SAMPLES;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
|
||||
vec3 progress = start.xyz + d*dV;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
/// ------------- COLOR/LIGHTING STUFF ------------- \\\
|
||||
|
||||
// do main lighting
|
||||
float Density = cloudVol(progressW) * pow(exp(max(progressW.y-65,0.0) / -15),2);
|
||||
vec3 color = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
float clearArea = 1.0-min(max(1.0 - length(progressW - cameraPosition) / 100,0.0),1.0);
|
||||
Density = min(Density * clearArea, NETHER_PLUME_DENSITY);
|
||||
vec3 hazeColor = normalize(gl_Fog.color.rgb);
|
||||
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) / 5.0;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SAMPLECOUNT; i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
|
||||
|
||||
float fireLight = cloudVol(progressW - vec3(0,1,0)) * clamp(exp(max(30 - progressW.y,0.0) / -10.0),0,1);
|
||||
progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld;
|
||||
|
||||
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 ;
|
||||
float densityVol = cloudVol(progressW);
|
||||
|
||||
|
||||
// do background fog lighting
|
||||
float AirDensity = 0.01;
|
||||
vec3 vL1 = fogcolor / 20.0;
|
||||
//------ PLUME EFFECT
|
||||
float plumeDensity = min(densityVol * pow(min(max(100.0-progressW.y,0.0)/30.0,1.0),4.0), pow(clamp(1.0 - length(progressW-cameraPosition)/far,0.0,1.0),5.0) * NETHER_PLUME_DENSITY);
|
||||
float plumeVolumeCoeff = exp(-plumeDensity*dd*dL);
|
||||
|
||||
vL += (vL1 - vL1*exp(-AirDensity*dd*dL)) * absorbance;
|
||||
vL += (vL0 - vL0*exp(-Density*dd*dL)) * absorbance;
|
||||
vec3 lighting = vec3(1.0,0.4,0.2) * exp(-15.0*densityVol);
|
||||
|
||||
absorbance *= exp(-(Density+AirDensity)*dd*dL);
|
||||
color += (lighting - lighting * plumeVolumeCoeff) * absorbance;
|
||||
absorbance *= plumeVolumeCoeff;
|
||||
|
||||
//------ HAZE EFFECT
|
||||
// dont make haze contrube to absorbance.
|
||||
float hazeDensity = 0.001;
|
||||
float hazeVolumeCoeff = exp(-hazeDensity*dd*dL);
|
||||
|
||||
vec3 hazeLighting = hazeColor;
|
||||
|
||||
color += (hazeLighting - hazeLighting*hazeVolumeCoeff) * absorbance;
|
||||
|
||||
//------ CEILING SMOKE EFFECT
|
||||
float ceilingSmokeDensity = 0.001 * pow(min(max(progressW.y-40.0,0.0)/50.0,1.0),3.0);
|
||||
float ceilingSmokeVolumeCoeff = exp(-ceilingSmokeDensity*dd*dL);
|
||||
|
||||
vec3 ceilingSmoke = vec3(1.0);
|
||||
|
||||
color += (ceilingSmoke - ceilingSmoke*ceilingSmokeVolumeCoeff) * (absorbance*0.5+0.5);
|
||||
absorbance *= ceilingSmokeVolumeCoeff;
|
||||
|
||||
//------ LPV FOG EFFECT
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * TorchBrightness_autoAdjust * absorbance;
|
||||
#endif
|
||||
|
||||
if (absorbance < 1e-5) break;
|
||||
}
|
||||
// return vec4(0.0,0.0,0.0,1.0);
|
||||
return vec4(vL, absorbance);
|
||||
return vec4(color, absorbance);
|
||||
}
|
@ -14,7 +14,7 @@ float densityAtPosFog(in vec3 pos){
|
||||
|
||||
|
||||
float cloudVol(in vec3 pos, float maxDistance ){
|
||||
|
||||
|
||||
float fogYstart = FOG_START_HEIGHT+3;
|
||||
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
|
||||
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
@ -44,7 +44,6 @@ float cloudVol(in vec3 pos, float maxDistance ){
|
||||
|
||||
FogDensities(medium_gradientFog, cloudyFog, rainyFog, maxDistance, dailyWeatherParams0.a, dailyWeatherParams1.a);
|
||||
|
||||
// return medium_gradientFog;
|
||||
return uniformFog + medium_gradientFog + cloudyFog + rainyFog;
|
||||
}
|
||||
|
||||
@ -63,29 +62,23 @@ float fogPhase(float lightPoint){
|
||||
}
|
||||
|
||||
uniform ivec2 eyeBrightness;
|
||||
uniform int dhRenderDistance;
|
||||
vec4 GetVolumetricFog(
|
||||
vec3 viewPosition,
|
||||
vec2 dither,
|
||||
vec3 LightColor,
|
||||
vec3 AmbientColor,
|
||||
vec3 AveragedAmbientColor
|
||||
vec3 AveragedAmbientColor,
|
||||
inout vec3 cloudDepth
|
||||
){
|
||||
#ifndef TOGGLE_VL_FOG
|
||||
return vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
int SAMPLECOUNT = VL_SAMPLES;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
float lightleakfix = 1.0 - caveDetection;
|
||||
float lightleakfix2 = pow(clamp(eyeBrightnessSmooth.y/240. ,0.0,1.0),3.0);
|
||||
/// ------------- RAYMARCHING STUFF ------------- \\\
|
||||
|
||||
int SAMPLECOUNT = VL_SAMPLES;
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
@ -97,7 +90,7 @@ vec4 GetVolumetricFog(
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = fragposition - start;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
vec3 dVWorld = wpos - gbufferModelViewInverse[3].xyz;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float maxLength = min(length(dVWorld), max(far, dhRenderDistance))/length(dVWorld);
|
||||
@ -108,17 +101,24 @@ vec4 GetVolumetricFog(
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
// why 8.0? i dunno it looked nice
|
||||
float dL = length(dVWorld)/8.0;
|
||||
float dL_alternate = length(dVWorld);
|
||||
float dL = dL_alternate/8.0;
|
||||
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec ;
|
||||
float SdotV = dot(sunVec,normalize(viewPosition))*lightCol.a;
|
||||
vec3 progressW = vec3(0.0);
|
||||
float expFactor = 11.0;
|
||||
|
||||
/// ------------- COLOR/LIGHTING STUFF ------------- \\\
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
float absorbance = 1.0;
|
||||
|
||||
float lightleakfix = 1.0 - caveDetection;
|
||||
float lightleakfix2 = pow(clamp(eyeBrightnessSmooth.y/240. ,0.0,1.0),3.0);
|
||||
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec;
|
||||
float SdotV = dot(sunVec, normalize(viewPosition))*lightCol.a;
|
||||
|
||||
///// ----- fog lighting
|
||||
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
|
||||
float sunPhase = fogPhase(SdotV) * 5.0;
|
||||
@ -137,11 +137,13 @@ vec4 GetVolumetricFog(
|
||||
#ifdef ambientLight_only
|
||||
LightSourcePhased = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
vec3 biomeDirect = LightSourcePhased;
|
||||
vec3 biomeIndirect = skyLightPhased;
|
||||
float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect);
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float atmosphereMult = 1.0;
|
||||
#else
|
||||
@ -165,44 +167,47 @@ vec4 GetVolumetricFog(
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 3.14 * 2.0;
|
||||
#endif
|
||||
|
||||
float expFactor = 11.0;
|
||||
for (int i=0;i<SAMPLECOUNT;i++) {
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) / 5.0;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SAMPLECOUNT; i++) {
|
||||
float d = (pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
|
||||
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
//project into biased shadowmap space
|
||||
#ifdef DISTORT_SHADOWMAP
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
#else
|
||||
float distortFactor = 1.0;
|
||||
#endif
|
||||
vec3 shadowPos = vec3(progress.xy*distortFactor, progress.z);
|
||||
progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld;
|
||||
|
||||
vec3 sh = vec3(1.0);
|
||||
if (abs(shadowPos.x) < 1.0-0.5/2048. && abs(shadowPos.y) < 1.0-0.5/2048){
|
||||
shadowPos = shadowPos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
sh = vec3(shadow2D(shadowtex0, shadowPos).x);
|
||||
|
||||
if(shadow2D(shadowtex1, shadowPos).x > shadowPos.z && sh.x < 1.0){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, shadowPos.xy);
|
||||
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
|
||||
}
|
||||
//------ SAMPLE SHADOWS FOR FOG EFFECTS
|
||||
#ifdef DISTORT_SHADOWMAP
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
#else
|
||||
sh = vec3(shadow2D(shadow, shadowPos).x);
|
||||
float distortFactor = 1.0;
|
||||
#endif
|
||||
}
|
||||
#ifdef RAYMARCH_CLOUDS_WITH_FOG
|
||||
vec3 sh_forClouds = sh;
|
||||
#endif
|
||||
vec3 shadowPos = vec3(progress.xy*distortFactor, progress.z);
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
sh *= GetCloudShadow_VLFOG(progressW, WsunVec * lightCol.a);
|
||||
#endif
|
||||
vec3 sh = vec3(1.0);
|
||||
if (abs(shadowPos.x) < 1.0-0.5/2048. && abs(shadowPos.y) < 1.0-0.5/2048){
|
||||
shadowPos = shadowPos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
sh = vec3(shadow2D(shadowtex0, shadowPos).x);
|
||||
|
||||
if(shadow2D(shadowtex1, shadowPos).x > shadowPos.z && sh.x < 1.0){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, shadowPos.xy);
|
||||
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
|
||||
}
|
||||
#else
|
||||
sh = vec3(shadow2D(shadow, shadowPos).x);
|
||||
#endif
|
||||
}
|
||||
#ifdef RAYMARCH_CLOUDS_WITH_FOG
|
||||
vec3 sh_forClouds = sh;
|
||||
#endif
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
sh *= GetCloudShadow_VLFOG(progressW, WsunVec * lightCol.a);
|
||||
#endif
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
float maxDistance = inBiome * min(max(1.0 - length(d*dVWorld.xz)/(32*8),0.0)*2.0,1.0);
|
||||
@ -211,37 +216,40 @@ vec4 GetVolumetricFog(
|
||||
float densityVol = cloudVol(progressW, 0.0) * lightleakfix;
|
||||
#endif
|
||||
|
||||
//Water droplets(fog)
|
||||
float density = densityVol;
|
||||
//------ MAIN FOG EFFECT
|
||||
float fogDensity = densityVol;
|
||||
float fogVolumeCoeff = exp(-fogDensity*dd*dL); // this is like beer-lambert law or something
|
||||
|
||||
///// ----- main fog lighting
|
||||
//Just air
|
||||
vec2 airCoef = exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * (24.0 * atmosphereMult) * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-100),0),0.0,1.0);
|
||||
// * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-100),0),0.0,1.0);
|
||||
// * exp2(-0.05 * max(progressW.y - (CloudLayer0_height + max(eyeAltitude-(CloudLayer0_height-50.0),0)),0.0));
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
vec3 indirectLight = mix(skyLightPhased, biomeIndirect, maxDistance);
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeDirect, maxDistance) * sh;
|
||||
#else
|
||||
vec3 indirectLight = skyLightPhased;
|
||||
vec3 DirectLight = LightSourcePhased * sh;
|
||||
#endif
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*(airCoef.x);
|
||||
vec3 m = mC*(airCoef.y+densityVol*300.0);
|
||||
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz);
|
||||
vec3 lighting = DirectLight * lightleakfix + indirectLight * lightleakfix2 + Lightning;
|
||||
|
||||
// calculate the atmosphere haze seperately and purely on color, so visibility is not harmed.
|
||||
vec3 Atmosphere = LightSourcePhased * sh * (rayL*rL + sunPhase*m) + (AveragedAmbientColor*0.7) * (rL+m) * lightleakfix2;
|
||||
color += (Atmosphere - Atmosphere*exp(-(rL+m)*dd*dL_alternate)) / (rL+m+1e-6);
|
||||
color += (lighting - lighting * fogVolumeCoeff) * absorbance;
|
||||
absorbance *= fogVolumeCoeff;
|
||||
|
||||
// calculate lighting
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
vec3 indirectLight = mix(skyLightPhased, biomeIndirect, maxDistance);
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeDirect, maxDistance) * sh;
|
||||
#else
|
||||
vec3 indirectLight = skyLightPhased;
|
||||
vec3 DirectLight = LightSourcePhased * sh;
|
||||
#endif
|
||||
//------ ATMOSPHERE HAZE EFFECT
|
||||
// just air
|
||||
vec2 airCoef = exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * (24.0 * atmosphereMult) * Haze_amount * clamp((CloudLayer0_height + max(eyeAltitude-(CloudLayer0_height-100),0)) - progressW.y,0.0,1.0);
|
||||
|
||||
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m);
|
||||
vec3 lighting = DirectLight * lightleakfix + indirectLight * lightleakfix2 + Lightning;
|
||||
// Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = mC*(airCoef.y+densityVol*300.0);
|
||||
|
||||
color += (lighting - lighting * exp(-density*dd*dL))*absorbance;
|
||||
absorbance *= max(exp(-density*dd*dL),0.0);
|
||||
// calculate the atmosphere haze seperately and purely additive to color, do not contribute to absorbtion.
|
||||
vec3 Atmosphere = LightSourcePhased * sh * (rayL*rL + sunPhase*m) + (AveragedAmbientColor*0.7) * (rL+m) * lightleakfix2;
|
||||
color += (Atmosphere - Atmosphere*exp(-(rL+m)*dd*dL_alternate)) / (rL+m+1e-6) * absorbance;
|
||||
|
||||
//------ LPV FOG EFFECT
|
||||
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
|
||||
color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * TorchBrightness_autoAdjust * absorbance;
|
||||
#endif
|
||||
|
||||
#ifdef RAYMARCH_CLOUDS_WITH_FOG
|
||||
float otherlayer = max(progressW.y - (CloudLayer0_height+99.5), 0.0) > 0.0 ? 0.0 : 1.0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define saturate(x) clamp(x,0.0,1.0)
|
||||
#define SHADER_VERSION_LABEL 439 // [439]
|
||||
|
||||
#define BLISS_SHADERS 0 // [0 1 2]
|
||||
#define saturate(x) clamp(x,0.0,1.0)
|
||||
|
||||
////////////////////////////////////////
|
||||
// ----- WATER RELATED SETTINGS ----- //
|
||||
@ -403,7 +403,7 @@ uniform int moonPhase;
|
||||
#define cloud_ShadowLevelOfDetail 0 // [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_LevelOfDetailLQ 1 // [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_ShadowLevelOfDetailLQ 0 // [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define minRayMarchSteps 10 // [20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define minRayMarchSteps 15 // [20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define maxRayMarchSteps 15 // [5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define minRayMarchStepsLQ 10 // [5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
#define maxRayMarchStepsLQ 30 // [ 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
@ -551,9 +551,9 @@ uniform int moonPhase;
|
||||
#define SATURATION 0.00 // [-1.0 -0.98 -0.96 -0.94 -0.92 -0.9 -0.88 -0.86 -0.84 -0.82 -0.8 -0.78 -0.76 -0.74 -0.72 -0.7 -0.68 -0.66 -0.64 -0.62 -0.6 -0.58 -0.56 -0.54 -0.52 -0.5 -0.48 -0.46 -0.44 -0.42 -0.4 -0.38 -0.36 -0.34 -0.32 -0.3 -0.28 -0.26 -0.24 -0.22 -0.2 -0.18 -0.16 -0.14 -0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 ]
|
||||
#define CROSSTALK 0.0 // [-1.0 -0.98 -0.96 -0.94 -0.92 -0.9 -0.88 -0.86 -0.84 -0.82 -0.8 -0.78 -0.76 -0.74 -0.72 -0.7 -0.68 -0.66 -0.64 -0.62 -0.6 -0.58 -0.56 -0.54 -0.52 -0.5 -0.48 -0.46 -0.44 -0.42 -0.4 -0.38 -0.36 -0.34 -0.32 -0.3 -0.28 -0.26 -0.24 -0.22 -0.2 -0.18 -0.16 -0.14 -0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 ]
|
||||
|
||||
// #define TONE_CURVE
|
||||
#define UPPER_CURVE 0.0 // [-1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define LOWER_CURVE 0.0 // [-1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
// #define LUMINANCE_CURVE
|
||||
#define UPPER_CURVE 0.0 // [-2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.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]
|
||||
#define LOWER_CURVE 0.0 // [-2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.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]
|
||||
|
||||
// #define COLOR_GRADING_ENABLED
|
||||
#define SHADOWS_GRADE_R 1.0 // [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]
|
||||
@ -594,11 +594,10 @@ const vec3 HIGHLIGHTS_TARGET = length(vec3(HIGHLIGHTS_GRADE_R, HIGHLIGHTS_GRADE_
|
||||
#define AEROCHROME_PINKNESS 0.3 // How pink it is from red [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
|
||||
|
||||
//#define BICUBIC_UPSCALING
|
||||
// #define CAMERA_GRIDLINES
|
||||
|
||||
// #define MOTION_BLUR
|
||||
#define MOTION_BLUR_STRENGTH 1.0 // [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]
|
||||
#define MOTION_BLUR_STRENGTH 1.0 // [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 3.0 4.0 5.0]
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// ----- GAMEPLAY POST EFFECT RELATED SETTINGS ----- //
|
||||
@ -688,6 +687,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
|
||||
// #define DISABLE_VANILLA_EMISSIVES
|
||||
#define PARTICLE_RENDERING_FIX
|
||||
|
||||
#define LIGHTING_EFFECTS_BLUR_FILTER
|
||||
|
||||
///////////////////////////////////////////
|
||||
// ----- DISTANT HORIZONS SETTINGS ----- //
|
||||
@ -697,7 +697,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
|
||||
#define DISTORT_SHADOWMAP
|
||||
// #define DISTANT_HORIZONS_SHADOWMAP
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
#undef DISTORT_SHADOWMAP
|
||||
// #undef DISTORT_SHADOWMAP
|
||||
|
||||
const float shadowNearPlane = -1.0;
|
||||
const float shadowFarPlane = -1.0;
|
||||
@ -724,6 +724,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
|
||||
#define LPV_ENTITY_LIGHTS
|
||||
#define LPV_REDSTONE_LIGHTS
|
||||
//#define LPV_COLORED_CANDLES
|
||||
//#define LPV_VL_FOG_ILLUMINATION
|
||||
#define LPV_VL_FOG_ILLUMINATION_BRIGHTNESS 100 // [0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]]
|
||||
|
||||
// Fix for making nether/end work until next Iris release to fix shadow matrices
|
||||
//#define LPV_NOSHADOW_HACK
|
||||
@ -780,7 +782,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
|
||||
#endif
|
||||
#ifdef LIGHTNING_FLASH
|
||||
#endif
|
||||
#if BLISS_SHADERS == 0
|
||||
#if SHADER_VERSION_LABEL > 0
|
||||
#endif
|
||||
#if DH_KNOWN_ISSUES == 0
|
||||
#endif
|
||||
@ -788,3 +790,5 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
|
||||
#endif
|
||||
#ifdef RENDER_PLAYER_SHADOWS
|
||||
#endif
|
||||
#ifdef LPV_VL_FOG_ILLUMINATION
|
||||
#endif
|
@ -191,7 +191,7 @@ void DoSpecularReflections(
|
||||
Roughness = 1.0 - Roughness; Roughness *= Roughness;
|
||||
F0 = F0 == 0.0 ? 0.02 : F0;
|
||||
|
||||
// Roughness = 0.1;
|
||||
// Roughness = 0.0;
|
||||
// F0 = 0.9;
|
||||
|
||||
mat3 Basis = CoordBase(Normal);
|
||||
|
@ -256,7 +256,8 @@ vec3 DoCloudLighting(
|
||||
}
|
||||
|
||||
vec4 renderLayer(
|
||||
int layer,
|
||||
int layer,
|
||||
in vec3 POSITION,
|
||||
in vec3 rayProgress,
|
||||
in vec3 dV_view,
|
||||
in float mult,
|
||||
@ -276,7 +277,8 @@ vec4 renderLayer(
|
||||
in vec3 indirectScatter,
|
||||
in float distantfog,
|
||||
bool notVisible,
|
||||
vec3 FragPosition
|
||||
vec3 FragPosition,
|
||||
inout vec3 cloudDepth
|
||||
){
|
||||
vec3 COLOR = vec3(0.0);
|
||||
float TOTAL_EXTINCTION = 1.0;
|
||||
@ -332,20 +334,22 @@ if(layer == 2){
|
||||
|
||||
}else{
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
float upperLayerOcclusion = layer == 0 ? GetCumulusDensity(1, rayProgress + vec3(0.0,1.0,0.0) * max((LAYER1_minHEIGHT+30) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT) : 0.0;
|
||||
float upperLayerOcclusion = layer == 0 ? GetCumulusDensity(1, rayProgress + vec3(0.0,1.0,0.0) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT) : 0.0;
|
||||
float skylightOcclusion = mix(1.0, (1.0 - LAYER1_DENSITY)*0.8 + 0.2, (1.0 - exp2(-5.0 * (upperLayerOcclusion*upperLayerOcclusion))) * distantfog);
|
||||
#else
|
||||
float skylightOcclusion = 1.0;
|
||||
#endif
|
||||
|
||||
float expFactor = 11.0;
|
||||
for(int i = 0; i < QUALITY; i++) {
|
||||
|
||||
#ifdef CLOUDS_INTERSECT_TERRAIN
|
||||
IntersecTerrain = length(rayProgress - cameraPosition) > lViewPosM;
|
||||
#endif
|
||||
|
||||
/// avoid overdraw
|
||||
if(notVisible || IntersecTerrain) break;
|
||||
|
||||
|
||||
// do not sample anything unless within a clouds bounding box
|
||||
if(clamp(rayProgress.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayProgress.y - minHeight,0.0,1.0) > 0.0){
|
||||
|
||||
@ -353,6 +357,7 @@ if(layer == 2){
|
||||
float fadedDensity = cloudDensity * pow(clamp((rayProgress.y - minHeight)/25,0.0,1.0),2.0);
|
||||
float CumulusWithDensity = cloudDensity * cumulus;
|
||||
|
||||
|
||||
if(CumulusWithDensity > 1e-5 ){ // make sure no work is done on pixels with no densities
|
||||
float muE = cumulus * fadedDensity;
|
||||
|
||||
@ -365,7 +370,7 @@ if(layer == 2){
|
||||
/// shadows cast from one layer to another
|
||||
/// large cumulus -> small cumulus
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(layer == 0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, rayProgress + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+35) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
if(layer == 0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, rayProgress + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
@ -379,12 +384,15 @@ if(layer == 2){
|
||||
|
||||
COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION;
|
||||
TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0);
|
||||
|
||||
|
||||
if (TOTAL_EXTINCTION < 1e-5) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rayProgress += dV_view;
|
||||
|
||||
|
||||
}
|
||||
return vec4(COLOR, TOTAL_EXTINCTION);
|
||||
}
|
||||
@ -399,10 +407,10 @@ vec3 layerStartingPosition(
|
||||
float maxHeight
|
||||
){
|
||||
// allow passing through/above/below the plane without limits
|
||||
float flip = mix(max(cameraPos.y - maxHeight,0.0), max(minHeight - cameraPos.y,0), clamp(dV_view.y,0,1));
|
||||
float flip = mix(max(cameraPos.y - maxHeight,0.0), max(minHeight - cameraPos.y,0.0), clamp(dV_view.y,0.0,1.0));
|
||||
|
||||
// orient the ray to be a flat plane facing up/down
|
||||
vec3 position = dV_view*dither + cameraPos + dV_view/abs(dV_view.y) * flip;
|
||||
vec3 position = dV_view*dither + cameraPos + (dV_view/abs(dV_view.y)) * flip;
|
||||
|
||||
return position;
|
||||
}
|
||||
@ -410,7 +418,8 @@ vec4 renderClouds(
|
||||
vec3 FragPosition,
|
||||
vec2 Dither,
|
||||
vec3 LightColor,
|
||||
vec3 SkyColor
|
||||
vec3 SkyColor,
|
||||
inout vec3 cloudDepth
|
||||
){
|
||||
vec3 SignedWsunvec = WsunVec;
|
||||
vec3 WsunVec = WsunVec * (float(sunElevation > 1e-5)*2.0-1.0);
|
||||
@ -427,11 +436,10 @@ vec4 renderClouds(
|
||||
//////////////////////////////////////////
|
||||
////// Raymarching stuff
|
||||
//////////////////////////////////////////
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec4 viewPos = normalize(gbufferModelViewInverse * vec4(FragPosition,1.0) );
|
||||
maxIT_clouds = int(clamp(maxIT_clouds / sqrt(exp2(viewPos.y)),0.0, maxIT));
|
||||
// maxIT_clouds = 15;
|
||||
// maxIT_clouds = 30;
|
||||
|
||||
vec3 dV_view = normalize(viewPos.xyz);
|
||||
|
||||
@ -448,14 +456,18 @@ vec4 renderClouds(
|
||||
vec3 dV_viewTEST = dV_view * (90.0/abs(dV_view.y)/maxIT_clouds);
|
||||
float mult = length(dV_viewTEST);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////// lighting stuff
|
||||
//////////////////////////////////////////
|
||||
|
||||
float shadowStep = 1.0;
|
||||
|
||||
vec3 dV_Sun = WsunVec*shadowStep;
|
||||
float SdotV = dot(mat3(gbufferModelView)*WsunVec, normalize(FragPosition));
|
||||
vec3 dV_Sun = WsunVec;
|
||||
#ifdef EXCLUDE_WRITE_TO_LUT
|
||||
dV_Sun *= lightCol.a;
|
||||
#endif
|
||||
|
||||
float SdotV = dot(mat3(gbufferModelView)*WsunVec, normalize(FragPosition)) ;
|
||||
|
||||
float mieDay = phaseg(SdotV, 0.85) + phaseg(SdotV, 0.75);
|
||||
float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ;
|
||||
@ -509,7 +521,9 @@ vec4 renderClouds(
|
||||
#ifdef CloudLayer0
|
||||
vec3 layer0_dV_view = dV_view * (LAYER0_width/abs(dV_view.y)/maxIT_clouds);
|
||||
vec3 layer0_start = layerStartingPosition(layer0_dV_view, cameraPosition, Dither.y, MinHeight, MaxHeight);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CloudLayer1
|
||||
vec3 layer1_dV_view = dV_view * (LAYER1_width/abs(dV_view.y)/maxIT_clouds);
|
||||
vec3 layer1_start = layerStartingPosition(layer1_dV_view, cameraPosition, Dither.y, MinHeight1, MaxHeight1);
|
||||
@ -519,7 +533,7 @@ vec4 renderClouds(
|
||||
#endif
|
||||
|
||||
#ifdef CloudLayer0
|
||||
vec4 layer0 = renderLayer(0, layer0_start, layer0_dV_view, mult, Dither.x, maxIT_clouds, MinHeight, MaxHeight, dV_Sun, LAYER0_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, false, FragPosition);
|
||||
vec4 layer0 = renderLayer(0,dV_view, layer0_start, layer0_dV_view, mult, Dither.x, maxIT_clouds, MinHeight, MaxHeight, dV_Sun, LAYER0_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, false, FragPosition, cloudDepth);
|
||||
total_extinction *= layer0.a;
|
||||
|
||||
// stop overdraw.
|
||||
@ -531,7 +545,7 @@ vec4 renderClouds(
|
||||
#endif
|
||||
|
||||
#ifdef CloudLayer1
|
||||
vec4 layer1 = renderLayer(1, layer1_start, layer1_dV_view, mult, Dither.x, maxIT_clouds, MinHeight1, MaxHeight1, dV_Sun, LAYER1_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, notVisible, FragPosition);
|
||||
vec4 layer1 = renderLayer(1,dV_view, layer1_start, layer1_dV_view, mult, Dither.x, maxIT_clouds, MinHeight1, MaxHeight1, dV_Sun, LAYER1_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, notVisible, FragPosition, cloudDepth);
|
||||
total_extinction *= layer1.a;
|
||||
|
||||
// stop overdraw.
|
||||
@ -539,7 +553,7 @@ vec4 renderClouds(
|
||||
#endif
|
||||
|
||||
#ifdef CloudLayer2
|
||||
vec4 layer2 = renderLayer(2, layer2_start, dV_view_Alto, mult_alto, Dither.x, maxIT_clouds, Height2, Height2, dV_Sun, LAYER2_DENSITY, SkyColor, directScattering * (1.0 + rainStrength*3), directMultiScattering* (1.0 + rainStrength*3), sunIndirectScattering, distantfog, altoNotVisible, FragPosition);
|
||||
vec4 layer2 = renderLayer(2,dV_view,layer2_start, dV_view_Alto, mult_alto, Dither.x, maxIT_clouds, Height2, Height2, dV_Sun, LAYER2_DENSITY, SkyColor, directScattering * (1.0 + rainStrength*3), directMultiScattering* (1.0 + rainStrength*3), sunIndirectScattering, distantfog, altoNotVisible, FragPosition, cloudDepth);
|
||||
total_extinction *= layer2.a;
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user