mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
fix compile error when floodfill gets enabled. fix compile error when TAA is turned off. fix compile error when aerochrome is turned on. re-added "render clouds as fog" setting. fix DOF using wrong depth buffer for CoC. fix cave fog when DH is enabled. fix block breaking effect not having alpha discard. changed "clouds intersect terrain" setting to work better on edges, but work worse everywhere else.
This commit is contained in:
@ -148,6 +148,23 @@ vec4 GetVolumetricFog(
|
||||
float atmosphereMult = 1.5;
|
||||
#endif
|
||||
|
||||
#ifdef RAYMARCH_CLOUDS_WITH_FOG
|
||||
vec3 SkyLightColor = AmbientColor;
|
||||
vec3 LightSourceColor = LightColor;
|
||||
|
||||
#ifdef ambientLight_only
|
||||
LightSourceColor = vec3(0.0);
|
||||
#endif
|
||||
|
||||
vec3 dV_Sun = WsunVec;
|
||||
|
||||
float mieDay = phaseg(SdotV, 0.85) + phaseg(SdotV, 0.75);
|
||||
float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5);
|
||||
|
||||
vec3 directScattering = LightSourceColor * mieDay * 3.14;
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 3.14 * 2.0;
|
||||
#endif
|
||||
|
||||
float expFactor = 11.0;
|
||||
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);
|
||||
@ -179,6 +196,9 @@ vec4 GetVolumetricFog(
|
||||
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);
|
||||
@ -223,9 +243,66 @@ vec4 GetVolumetricFog(
|
||||
color += (lighting - lighting * exp(-density*dd*dL))*absorbance;
|
||||
absorbance *= max(exp(-density*dd*dL),0.0);
|
||||
|
||||
if (absorbance < 1e-5) break;
|
||||
#ifdef RAYMARCH_CLOUDS_WITH_FOG
|
||||
float otherlayer = max(progressW.y - (CloudLayer0_height+99.5), 0.0) > 0.0 ? 0.0 : 1.0;
|
||||
|
||||
float DUAL_MIN_HEIGHT = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height;
|
||||
float DUAL_MAX_HEIGHT = DUAL_MIN_HEIGHT + 100.0;
|
||||
|
||||
float DUAL_DENSITY = otherlayer > 0.0 ? CloudLayer0_density : CloudLayer1_density;
|
||||
|
||||
if(clamp(progressW.y - DUAL_MAX_HEIGHT,0.0,1.0) < 1.0 && clamp(progressW.y - DUAL_MIN_HEIGHT,0.0,1.0) > 0.0){
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
float upperLayerOcclusion = otherlayer > 0.0 ? GetCumulusDensity(1, progressW + vec3(0.0,1.0,0.0) * max((LAYER1_minHEIGHT+30) - progressW.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))));
|
||||
#else
|
||||
float skylightOcclusion = 1.0;
|
||||
#endif
|
||||
|
||||
float DUAL_MIN_HEIGHT_2 = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height;
|
||||
float DUAL_MAX_HEIGHT_2 = DUAL_MIN_HEIGHT + 100.0;
|
||||
|
||||
float cumulus = GetCumulusDensity(-1, progressW, 1, CloudLayer0_height, CloudLayer1_height);
|
||||
float fadedDensity = DUAL_DENSITY * pow(clamp((progressW.y - DUAL_MIN_HEIGHT_2)/25,0.0,1.0),2.0);
|
||||
|
||||
float muE = cumulus*fadedDensity;
|
||||
float directLight = 0.0;
|
||||
|
||||
if(muE > 1e-5){
|
||||
|
||||
for (int j=0; j < 3; j++){
|
||||
// vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05));
|
||||
vec3 shadowSamplePos = progressW + dV_Sun * (20.0 + j * (20.0 + dither.y*20.0));
|
||||
float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * DUAL_DENSITY;
|
||||
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
/// shadows cast from one layer to another
|
||||
/// large cumulus -> small cumulus
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(otherlayer > 0.0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, progressW + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+35) - progressW.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
vec3 HighAlt_shadowPos = progressW + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - progressW.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density * (1.0-abs(WsunVec.y));
|
||||
directLight += HighAlt_shadow;
|
||||
#endif
|
||||
|
||||
float skyScatter = clamp(((DUAL_MAX_HEIGHT - progressW.y) / 100.0),0.0,1.0); // linear gradient from bottom to top of cloud layer
|
||||
float distantfade = 1- exp( -10*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*65),0.0,1.0),2));
|
||||
vec3 cloudlighting = DoCloudLighting(DUAL_DENSITY * cumulus, SkyLightColor*skylightOcclusion, skyScatter, directLight, directScattering*sh_forClouds, directMultiScattering*sh_forClouds, 1);
|
||||
|
||||
color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL_alternate),0.0) * absorbance;
|
||||
absorbance *= max(exp(-muE*dd*dL_alternate),0.0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (absorbance < 1e-5) break;
|
||||
#endif
|
||||
}
|
||||
// return vec4(color, dot(absorbance,vec3(0.21, 0.72, 0.07)));
|
||||
return vec4(color, absorbance);
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.
|
||||
#define Stochastic_Transparent_Shadows
|
||||
|
||||
#define Glass_Tint
|
||||
#define TRANSLUCENT_COLORED_SHADOWS
|
||||
// #define TRANSLUCENT_COLORED_SHADOWS
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
#undef Stochastic_Transparent_Shadows
|
||||
#endif
|
||||
|
@ -84,8 +84,6 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
float Topshape = 0.0;
|
||||
float Baseshape = 0.0;
|
||||
|
||||
// float curvature = 1-exp(-25*pow(clamp(1.0 - length(pos - cameraPosition)/(32*80),0.0,1.0),2));
|
||||
// curvature = clamp(1.0 - length(pos - cameraPosition)/(32*128),0.0,1.0);
|
||||
float LAYER0_minHEIGHT_FOG = CloudLayer0_height;
|
||||
float LAYER0_maxHEIGHT_FOG = 100 + LAYER0_minHEIGHT_FOG;
|
||||
LAYER0_minHEIGHT_FOG = LAYER0_minHEIGHT;
|
||||
@ -115,12 +113,12 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
if(layer == -1){
|
||||
float otherlayer = max(pos.y - (LAYER0_minHEIGHT_FOG+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
if(otherlayer > 0.0){
|
||||
SampleCoords0 = (samplePos.xz + cloud_movement) / 5000;
|
||||
SampleCoords1 = (samplePos.xz - cloud_movement) / 500;
|
||||
SampleCoords0 = (samplePos.xz + cloud_movement) / 5000 ;
|
||||
SampleCoords1 = (samplePos.xz - cloud_movement) / 500 ;
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
}else{
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 15000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 1500);
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 10000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 2500);
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
}
|
||||
}
|
||||
@ -155,20 +153,17 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
|
||||
if(layer == -1){
|
||||
|
||||
|
||||
|
||||
#ifdef CloudLayer0
|
||||
float layer0_coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
float layer0 = min(min(layer0_coverage + LAYER0_COVERAGE, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 50.0;
|
||||
Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 15.0;
|
||||
Baseshape = max(LAYER0_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage += max(layer0 - Topshape - Baseshape,0.0);
|
||||
FinalCloudCoverage = max(layer0 - Topshape - Baseshape * (1.0-rainStrength),0.0);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CloudLayer1
|
||||
float layer1_coverage = abs(CloudLarge-0.8) - CloudSmall;
|
||||
float layer1 = min(min(layer1_coverage + LAYER1_COVERAGE - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
@ -177,7 +172,7 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10 ), 0.0) / 50;
|
||||
Baseshape = max(LAYER1_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage += max(layer1 - Topshape - Baseshape, 0.0);
|
||||
FinalCloudCoverage += max(layer1 - Topshape*Topshape - Baseshape * (1.0-rainStrength), 0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -246,9 +241,7 @@ vec3 DoCloudLighting(
|
||||
float sunShadows,
|
||||
vec3 sunScatter,
|
||||
vec3 sunMultiScatter,
|
||||
float distantfog,
|
||||
|
||||
int layer
|
||||
float distantfog
|
||||
){
|
||||
float powder = 1.0 - exp(-10.0 * density);
|
||||
vec3 directLight = sunMultiScatter * exp(-3.0 * sunShadows) * powder + sunScatter * exp(-10.0 * sunShadows);
|
||||
@ -293,7 +286,7 @@ vec4 renderLayer(
|
||||
#ifdef CLOUDS_INTERSECT_TERRAIN
|
||||
// thank you emin for this world intersection thing
|
||||
#if defined DISTANT_HORIZONS
|
||||
float maxdist = dhRenderDistance + 16 * 64;
|
||||
float maxdist = dhRenderDistance + 16 * 32;
|
||||
#else
|
||||
float maxdist = far + 16*5;
|
||||
#endif
|
||||
@ -328,7 +321,7 @@ if(layer == 2){
|
||||
directLight += GetAltostratusDensity(shadowSamplePos_high) * cloudDensity * (1.0-abs(dV_Sun.y));
|
||||
}
|
||||
|
||||
vec3 lighting = DoCloudLighting(AltoWithDensity, skyLightCol, 0.5, directLight, sunScatter, sunMultiScatter, distantfog, layer);
|
||||
vec3 lighting = DoCloudLighting(AltoWithDensity, skyLightCol, 0.5, directLight, sunScatter, sunMultiScatter, distantfog);
|
||||
|
||||
COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION;
|
||||
TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0);
|
||||
@ -372,7 +365,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+70*dither) - 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+35) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
@ -382,8 +375,7 @@ if(layer == 2){
|
||||
#endif
|
||||
|
||||
float skyScatter = clamp(((maxHeight - rayProgress.y) / 100.0),0.0,1.0); // linear gradient from bottom to top of cloud layer
|
||||
vec3 lighting = DoCloudLighting(CumulusWithDensity, skyLightCol * skylightOcclusion, skyScatter, directLight, sunScatter, sunMultiScatter, distantfog, layer);
|
||||
|
||||
vec3 lighting = DoCloudLighting(CumulusWithDensity, skyLightCol * skylightOcclusion, skyScatter, directLight, sunScatter, sunMultiScatter, distantfog);
|
||||
|
||||
COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION;
|
||||
TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0);
|
||||
|
Reference in New Issue
Block a user