mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-26 18:22:33 +08:00
fix sunlight being too dark on clouds. remove unneeded code from cloud functions. make powder effect more visible
This commit is contained in:
@ -209,14 +209,12 @@ vec3 getCloudLighting(
|
|||||||
vec3 directLightCol_multi,
|
vec3 directLightCol_multi,
|
||||||
|
|
||||||
float indirectShadowMask,
|
float indirectShadowMask,
|
||||||
vec3 indirectLightCol,
|
vec3 indirectLightCol
|
||||||
|
|
||||||
float distanceFade
|
|
||||||
){
|
){
|
||||||
float powderEffect = 1.0 - exp(-3.0*shapeFaded);
|
|
||||||
|
|
||||||
vec3 directScattering = directLightCol * exp(-10.0*sunShadowMask) + directLightCol_multi * exp(-3.0*(sunShadowMask - (1.0-indirectShadowMask*indirectShadowMask)*0.5)) * powderEffect;
|
float powderEffect = 1.0-exp(-10.0*shapeFaded); powderEffect *= powderEffect; powderEffect *= 2.0;
|
||||||
vec3 indirectScattering = indirectLightCol * mix(1.0, exp2(-5.0*shape), (indirectShadowMask*indirectShadowMask) * distanceFade);
|
vec3 directScattering = directLightCol_multi * powderEffect * exp(-3.0*sunShadowMask) + directLightCol * exp(-10.0*sunShadowMask);
|
||||||
|
vec3 indirectScattering = indirectLightCol * mix(1.0, exp2(-5.0*shape), indirectShadowMask*indirectShadowMask);
|
||||||
|
|
||||||
// return indirectScattering;
|
// return indirectScattering;
|
||||||
// return directScattering;
|
// return directScattering;
|
||||||
@ -239,7 +237,6 @@ vec4 raymarchCloud(
|
|||||||
vec3 sunScattering,
|
vec3 sunScattering,
|
||||||
vec3 sunMultiScattering,
|
vec3 sunMultiScattering,
|
||||||
vec3 skyScattering,
|
vec3 skyScattering,
|
||||||
float distanceFade,
|
|
||||||
|
|
||||||
float referenceDistance,
|
float referenceDistance,
|
||||||
vec3 sampledSkyCol,
|
vec3 sampledSkyCol,
|
||||||
@ -291,7 +288,7 @@ vec4 raymarchCloud(
|
|||||||
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;
|
||||||
|
|
||||||
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensity, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering, distanceFade);
|
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensity, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering);
|
||||||
|
|
||||||
vec3 newPos = rayPosition - cameraPosition;
|
vec3 newPos = rayPosition - cameraPosition;
|
||||||
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
|
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
|
||||||
@ -322,8 +319,6 @@ vec4 raymarchCloud(
|
|||||||
float upperLayerOcclusion = getCloudShape(LARGECUMULUS_LAYER, 0, rayPosition + vec3(0.0,1.0,0.0) * max((CloudLayer1_height+20) - rayPosition.y,0.0), CloudLayer1_height, CloudLayer1_height+100.0);
|
float upperLayerOcclusion = getCloudShape(LARGECUMULUS_LAYER, 0, rayPosition + vec3(0.0,1.0,0.0) * max((CloudLayer1_height+20) - rayPosition.y,0.0), CloudLayer1_height, CloudLayer1_height+100.0);
|
||||||
skylightOcclusion = mix(mix(0.0,0.2,parameters.largeCumulus.y), 1.0, pow(1.0 - upperLayerOcclusion*parameters.largeCumulus.y,2));
|
skylightOcclusion = mix(mix(0.0,0.2,parameters.largeCumulus.y), 1.0, pow(1.0 - upperLayerOcclusion*parameters.largeCumulus.y,2));
|
||||||
}
|
}
|
||||||
|
|
||||||
skylightOcclusion = mix(1.0, skylightOcclusion, distanceFade);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -352,6 +347,7 @@ vec4 raymarchCloud(
|
|||||||
|
|
||||||
// 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 indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0);
|
float indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0);
|
||||||
|
|
||||||
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density);
|
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density);
|
||||||
|
|
||||||
// do cloud shadows from one layer to another
|
// do cloud shadows from one layer to another
|
||||||
@ -368,13 +364,13 @@ vec4 raymarchCloud(
|
|||||||
sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * parameters.altostratus.y * (1.0-abs(sunVector.y));
|
sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * parameters.altostratus.y * (1.0-abs(sunVector.y));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion, distanceFade);
|
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion);
|
||||||
|
|
||||||
vec3 newPos = rayPosition - cameraPosition;
|
vec3 newPos = rayPosition - cameraPosition;
|
||||||
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
|
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
|
||||||
newPos.y = min(newPos.y,0.0);
|
newPos.y = min(newPos.y,0.0);
|
||||||
|
|
||||||
float distancefog = exp(-0.00025*length(newPos));
|
float distancefog = exp(-0.00035*length(newPos));
|
||||||
vec3 atmosphereHaze = (sampledSkyCol - sampledSkyCol * distancefog);
|
vec3 atmosphereHaze = (sampledSkyCol - sampledSkyCol * distancefog);
|
||||||
lighting = lighting * distancefog + atmosphereHaze;
|
lighting = lighting * distancefog + atmosphereHaze;
|
||||||
|
|
||||||
@ -505,32 +501,15 @@ vec4 GetVolumetricClouds(
|
|||||||
|
|
||||||
///------- do color stuff outside of the raymarcher loop
|
///------- do color stuff outside of the raymarcher loop
|
||||||
vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14;
|
vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14;
|
||||||
vec3 sunMultiScattering = directLightCol * 0.8;// * (phaseCloud(SdotV, 0.35) + phaseCloud(-SdotV, 0.35) * 0.5) * 6.28;
|
vec3 sunMultiScattering = directLightCol;
|
||||||
vec3 skyScattering = indirectLightCol;
|
vec3 skyScattering = indirectLightCol * 2.0;
|
||||||
|
|
||||||
vec3 distanceEstimation = normalize(NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples));
|
|
||||||
|
|
||||||
// terrible fake rayleigh scattering
|
|
||||||
// vec3 rC = vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5)*3.0;
|
|
||||||
// vec3 rayleighScatter = exp(-10000.0 * rC * exp(abs(distanceEstimation.y) * -5.0));
|
|
||||||
// sunMultiScattering *= rayleighScatter;
|
|
||||||
// sunScattering *= rayleighScatter;
|
|
||||||
|
|
||||||
float distanceFade = 1.0 - clamp(exp2(pow(abs(distanceEstimation.y),1.5) * -100.0),0.0,1.0)*heightRelativeToClouds;
|
|
||||||
distanceFade = 1.0;
|
|
||||||
|
|
||||||
// - pow(1.0-clamp(signedSunVec.y,0.0,1.0),5.0)
|
|
||||||
skyScattering *= 2.0;
|
|
||||||
// sunScattering *= distanceFade;
|
|
||||||
// sunMultiScattering *= distanceFade;
|
|
||||||
|
|
||||||
|
|
||||||
////------- RENDER SMALL CUMULUS CLOUDS
|
////------- RENDER SMALL CUMULUS CLOUDS
|
||||||
vec4 smallCumulusClouds = cloudColor;
|
vec4 smallCumulusClouds = cloudColor;
|
||||||
|
|
||||||
vec2 cloudLayer0_Distance = vec2(startDistance, 1.0);
|
vec2 cloudLayer0_Distance = vec2(startDistance, 1.0);
|
||||||
#ifdef CloudLayer0
|
#ifdef CloudLayer0
|
||||||
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer0_Distance);
|
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer0_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- RENDER LARGE CUMULUS CLOUDS
|
////------- RENDER LARGE CUMULUS CLOUDS
|
||||||
@ -546,7 +525,7 @@ vec4 GetVolumetricClouds(
|
|||||||
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
||||||
|
|
||||||
vec2 cloudLayer1_Distance = vec2(startDistance, 1.0);
|
vec2 cloudLayer1_Distance = vec2(startDistance, 1.0);
|
||||||
if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer1_Distance);
|
if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer1_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- RENDER ALTOSTRATUS CLOUDS
|
////------- RENDER ALTOSTRATUS CLOUDS
|
||||||
@ -562,7 +541,7 @@ vec4 GetVolumetricClouds(
|
|||||||
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
||||||
|
|
||||||
vec2 cloudLayer2_Distance = vec2(startDistance, 1.0);
|
vec2 cloudLayer2_Distance = vec2(startDistance, 1.0);
|
||||||
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer2_Distance);
|
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer2_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- BLEND LAYERS
|
////------- BLEND LAYERS
|
||||||
|
Reference in New Issue
Block a user