slight improvements to cloud/fog intersections

This commit is contained in:
Xonk
2025-03-17 23:39:48 -04:00
parent fa255a138d
commit faeb60f2af
2 changed files with 27 additions and 9 deletions

View File

@ -171,8 +171,10 @@ vec4 GetVolumetricFog(
float d = (pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); 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.y)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); float dd = pow(expFactor, float(i+dither.y)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
#ifdef VOLUMETRIC_CLOUDS
// check if the fog intersects clouds // check if the fog intersects clouds
if(length(d*dVWorld) > cloudPlaneDistance) break; if(length(d*dVWorld) > cloudPlaneDistance) break;
#endif
progress = start.xyz + d*dV; progress = start.xyz + d*dV;
progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld; progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld;

View File

@ -256,6 +256,13 @@ vec4 raymarchCloud(
float distanceFactor = length(rayDirection); float distanceFactor = length(rayDirection);
float densityTresholdCheck = 0.0;
if(LayerIndex == SMALLCUMULUS_LAYER) densityTresholdCheck = 0.06;
if(LayerIndex == LARGECUMULUS_LAYER) densityTresholdCheck = 0.02;
if(LayerIndex == ALTOSTRATUS_LAYER) densityTresholdCheck = 0.01;
densityTresholdCheck = mix(1e-5, densityTresholdCheck, dither);
if(LayerIndex == ALTOSTRATUS_LAYER){ if(LayerIndex == ALTOSTRATUS_LAYER){
float density = dailyWeatherParams1.z; float density = dailyWeatherParams1.z;
@ -273,11 +280,13 @@ vec4 raymarchCloud(
float shape = getCloudShape(LayerIndex, 1, rayPosition, minHeight, maxHeight); float shape = getCloudShape(LayerIndex, 1, rayPosition, minHeight, maxHeight);
float shapeWithDensity = shape*density; float shapeWithDensity = shape*density;
if(shapeWithDensity > mix(1e-5, 0.06, dither)){
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
}
// check if the pixel has visible clouds before doing work. // check if the pixel has visible clouds before doing work.
if(shapeWithDensity > 1e-5){ if(shapeWithDensity > 1e-5){
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
// can add the initial cloud shape sample for a free shadow starting step :D // can add the initial cloud shape sample for a free shadow starting step :D
float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y)); float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y));
float indirectShadowMask = 0.5; float indirectShadowMask = 0.5;
@ -333,8 +342,7 @@ vec4 raymarchCloud(
float shapeWithDensity = shape*density; float shapeWithDensity = shape*density;
float shapeWithDensityFaded = shape*density * pow(clamp((rayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0); float shapeWithDensityFaded = shape*density * pow(clamp((rayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0);
if(shapeWithDensityFaded > densityTresholdCheck){
if(shapeWithDensityFaded > mix(0.06, 1e-5, dither)){
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0; cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
} }
@ -561,6 +569,16 @@ vec4 GetVolumetricClouds(
cloudPlaneDistance = mix(cloudLayer0_Distance.x, cloudPlaneDistance, cloudLayer0_Distance.y); cloudPlaneDistance = mix(cloudLayer0_Distance.x, cloudPlaneDistance, cloudLayer0_Distance.y);
#endif #endif
#if defined CloudLayer0 && !defined CloudLayer1 && !defined CloudLayer2
cloudPlaneDistance = cloudLayer0_Distance.x;
#endif
#if !defined CloudLayer0 && defined CloudLayer1 && !defined CloudLayer2
cloudPlaneDistance = cloudLayer1_Distance.x;
#endif
#if !defined CloudLayer0 && !defined CloudLayer1 && defined CloudLayer2
cloudPlaneDistance = cloudLayer2_Distance.x;
#endif
#ifdef CloudLayer2 #ifdef CloudLayer2
cloudColor = altoStratusClouds; cloudColor = altoStratusClouds;
#endif #endif
@ -568,8 +586,6 @@ vec4 GetVolumetricClouds(
cloudColor.rgb *= largeCumulusClouds.a; cloudColor.rgb *= largeCumulusClouds.a;
cloudColor.rgb += largeCumulusClouds.rgb; cloudColor.rgb += largeCumulusClouds.rgb;
cloudColor.a *= largeCumulusClouds.a; cloudColor.a *= largeCumulusClouds.a;
#endif #endif
#ifdef CloudLayer0 #ifdef CloudLayer0
cloudColor.rgb *= smallCumulusClouds.a; cloudColor.rgb *= smallCumulusClouds.a;