mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
FIX stochastic shadows on IRIS. add filter option for SSAO and all SSS types. imrpove fog upsampling (even when DH is being used). ambient light is more consistent across all types of weather. tweak cloud lighting.
This commit is contained in:
@ -20,13 +20,14 @@ vec3 TangentToWorld(vec3 N, vec3 H, float roughness){
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
}
|
||||
|
||||
vec2 SpiralSample(
|
||||
int samples, int totalSamples, float rotation, float Xi
|
||||
){
|
||||
Xi = max(Xi,0.0015);
|
||||
|
||||
float alpha = float(samples + Xi) * (1.0 / float(totalSamples));
|
||||
|
||||
float theta = 3.14159265359 * alpha * rotation ;
|
||||
float theta = (2.0 *3.14159265359) * alpha * rotation;
|
||||
|
||||
float r = sqrt(Xi);
|
||||
float x = r * sin(theta);
|
||||
@ -39,6 +40,42 @@ vec2 SpiralSample(
|
||||
///////////////////////////// SSAO ////////////////////////
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
vec4 BilateralUpscale_SSAO(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){
|
||||
const ivec2 scaling = ivec2(1.0);
|
||||
ivec2 posDepth = ivec2(coord)*scaling;
|
||||
ivec2 posColor = ivec2(coord);
|
||||
|
||||
ivec2 pos = ivec2(coord*texelSize);
|
||||
|
||||
ivec2 getRadius[4] = ivec2[](
|
||||
ivec2(-2,-2),
|
||||
ivec2(-2, 0),
|
||||
ivec2( 0, 0),
|
||||
ivec2( 0,-2)
|
||||
);
|
||||
|
||||
float diffThreshold = 0.005;
|
||||
|
||||
vec4 RESULT = vec4(0.0);
|
||||
float SUM = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
ivec2 radius = getRadius[i];
|
||||
|
||||
float offsetDepth = ld(texelFetch2D(depth, (posDepth + radius * scaling + pos * scaling),0).r);
|
||||
|
||||
float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5;
|
||||
|
||||
RESULT += texelFetch2D(tex, (posColor + radius + pos),0) * EDGES;
|
||||
|
||||
SUM += EDGES;
|
||||
}
|
||||
|
||||
return RESULT / SUM;
|
||||
|
||||
}
|
||||
|
||||
vec2 SSAO(
|
||||
vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise
|
||||
){
|
||||
@ -64,7 +101,9 @@ vec2 SSAO(
|
||||
int n = 0;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
|
||||
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2;
|
||||
// vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2;
|
||||
|
||||
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * clamp(0.05 + i*0.095, 0.0,0.3) * mulfov2;
|
||||
|
||||
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE);
|
||||
|
||||
|
@ -165,13 +165,16 @@ vec4 GetVolumetricFog(
|
||||
float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ;
|
||||
|
||||
vec3 directScattering = LightSourceColor * mieDay * 3.14;
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 4.0;
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 3.14;
|
||||
|
||||
vec3 sunIndirectScattering = LightSourceColor * phaseg(dot(mat3(gbufferModelView)*vec3(0,1,0),normalize(viewPosition)), 0.5) * 3.14;
|
||||
#endif
|
||||
float RLmult = 3.0;
|
||||
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
RLmult = 1.0;
|
||||
float atmosphereMult = 1.0;
|
||||
#else
|
||||
float atmosphereMult = 2.0;
|
||||
#endif
|
||||
|
||||
float expFactor = 11.0;
|
||||
@ -181,6 +184,8 @@ vec4 GetVolumetricFog(
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
// float curvature = 1-exp(-25*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*80),0.0,1.0),2));
|
||||
|
||||
//project into biased shadowmap space
|
||||
#ifdef DISTORT_SHADOWMAP
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
@ -198,6 +203,7 @@ vec4 GetVolumetricFog(
|
||||
float sh2 = sh;
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
// if(clamp(progressW.y - CloudLayer1_height,0.0,1.0) < 1.0 && clamp(progressW.y-50,0.0,1.0) > 0.0)
|
||||
sh *= GetCloudShadow_VLFOG(progressW, WsunVec);
|
||||
#endif
|
||||
|
||||
@ -214,18 +220,18 @@ vec4 GetVolumetricFog(
|
||||
///// ----- main fog lighting
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y - SEA_LEVEL, 0.0) / vec2(8.0e3, 1.2e3) * vec2(6.,7.0)) * 24.0 * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-50),0),0.0,1.0);
|
||||
vec2 airCoef = exp(-max(progressW.y - SEA_LEVEL, 0.0) / vec2(8.0e3, 1.2e3) * vec2(6.,7.0)) * (atmosphereMult * 24.0) * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-50),0),0.0,1.0);
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density) * mC;
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * ((rL*RLmult)*rayL + m);
|
||||
vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * (rL*rayL + m);
|
||||
#else
|
||||
vec3 Atmosphere = skyLightPhased * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = LightSourcePhased * sh * ((rL*RLmult)*rayL + m);
|
||||
vec3 Atmosphere = skyLightPhased * (rL + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = LightSourcePhased * sh * (rL*rayL + m);
|
||||
#endif
|
||||
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m);
|
||||
|
||||
@ -240,51 +246,57 @@ vec4 GetVolumetricFog(
|
||||
//////////////////////////////////////////
|
||||
///// ----- cloud part
|
||||
//////////////////////////////////////////
|
||||
// curvature = clamp(1.0 - length(progressW - cameraPosition)/(32*128),0.0,1.0);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
float Density = otherlayer > 0.0 ? CloudLayer0_density : CloudLayer1_density;
|
||||
|
||||
float cumulus = GetCumulusDensity(-1, progressW, 1, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT);
|
||||
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){
|
||||
|
||||
float BASE_FADE = Density * clamp(exp( (progressW.y - (DUAL_MAX_HEIGHT - 75)) / 9.0 ),0.0,1.0);
|
||||
float DUAL_MIN_HEIGHT_2 = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height;
|
||||
float DUAL_MAX_HEIGHT_2 = DUAL_MIN_HEIGHT + 100.0;
|
||||
|
||||
if(cumulus > 1e-5){
|
||||
float muE = cumulus * BASE_FADE ;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
float cumulus = GetCumulusDensity(-1, progressW, 1, CloudLayer0_height, CloudLayer1_height);
|
||||
float fadedDensity = DUAL_DENSITY * clamp(exp( (progressW.y - (DUAL_MAX_HEIGHT - 75)) / 9.0 ),0.0,1.0);
|
||||
|
||||
vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05));
|
||||
float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * Density;
|
||||
float muE = cumulus*fadedDensity;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05));
|
||||
float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * DUAL_DENSITY;
|
||||
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(otherlayer > 0) directLight += CloudLayer1_density * 2.0 * GetCumulusDensity(1, progressW + dV_Sun/abs(dV_Sun.y) * max(((CloudLayer1_height+100)-70) - progressW.y,0.0), 0, CloudLayer1_height, CloudLayer1_height+100);
|
||||
#endif
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
float upperLayerOcclusion = otherlayer < 1 ? CloudLayer1_density * 2.0 * GetCumulusDensity(1, progressW + vec3(0.0,1.0,0.0) * max(((CloudLayer1_height+100)-70) - progressW.y,0.0), 0, CloudLayer1_height, CloudLayer1_height+100) : 0.0;
|
||||
float skylightOcclusion = max(exp2((upperLayerOcclusion*upperLayerOcclusion) * -5), 0.75);
|
||||
#else
|
||||
float skylightOcclusion = 1.0;
|
||||
#endif
|
||||
|
||||
float skyScatter = clamp((DUAL_MAX_HEIGHT - 20 - progressW.y) / 275.0,0.0,1.0);
|
||||
vec3 cloudlighting = DoCloudLighting(muE, cumulus, AmbientColor*skylightOcclusion, skyScatter, directLight, directScattering*sh2, directMultiScattering*sh2, 1.0);
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
// a horrible approximation of direct light indirectly hitting the lower layer of clouds after scattering through/bouncing off the upper layer.
|
||||
cloudlighting += sunIndirectScattering * exp((skyScatter*skyScatter) * cumulus * -35.0) * upperLayerOcclusion * exp(-20.0 * pow(abs(upperLayerOcclusion - 0.3),2));
|
||||
#endif
|
||||
|
||||
color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL),0.0) * absorbance;
|
||||
absorbance *= max(exp(-muE*dd*dL),0.0);
|
||||
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+70*dither.y) - progressW.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// // altostratus -> cumulus
|
||||
// #ifdef CloudLayer2
|
||||
// vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
// float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
// directLight += HighAlt_shadow;
|
||||
// #endif
|
||||
|
||||
|
||||
float skyScatter = clamp(((DUAL_MAX_HEIGHT - 20 - progressW.y) / 275.0) * (0.5+DUAL_DENSITY),0.0,1.0);
|
||||
float distantfade = 1- exp( -10*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*65),0.0,1.0),2));
|
||||
vec3 cloudlighting = DoCloudLighting(muE, cumulus, SkyLightColor, skyScatter, directLight, directScattering*sh2, directMultiScattering*sh2, 1);
|
||||
|
||||
color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL),0.0) * absorbance;
|
||||
absorbance *= max(exp(-muE*dd*dL),0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (min(dot(absorbance,vec3(0.335)),1.0) < 1e-5) break;
|
||||
}
|
||||
return vec4(color, min(dot(absorbance,vec3(0.335)),1.0));
|
||||
}
|
@ -492,7 +492,7 @@ uniform int moonPhase;
|
||||
#define TAA
|
||||
// #define SCREENSHOT_MODE
|
||||
// #define TAA_UPSCALING
|
||||
#define BLEND_FACTOR 0.05 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16]
|
||||
#define BLEND_FACTOR 0.16 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00]
|
||||
#define CLOSEST_VELOCITY
|
||||
//#define NO_CLIP
|
||||
|
||||
@ -595,9 +595,9 @@ uniform int moonPhase;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// ----- MISC/DEBUG RELATED SETTINGS ----- //
|
||||
/////////////////////////////////////////////
|
||||
///////////////////////////////
|
||||
// ----- MISC SETTINGS ----- //
|
||||
///////////////////////////////
|
||||
|
||||
// #define Glass_Tint // multiply the background through glass by the color of the glass for a strong tint.
|
||||
// #define ambientLight_only // THIS IS A DEBUG VIEW. turn the sunlight off. DOES NOT increase performance, the shadows are still working in the background
|
||||
@ -628,6 +628,13 @@ uniform int moonPhase;
|
||||
|
||||
#define TRANSLUCENT_ENTITIES
|
||||
|
||||
#define DENOISE_SSS_AND_SSAO
|
||||
|
||||
///////////////////////////////////////////
|
||||
// ----- DISTANT HORIZONS SETTINGS ----- //
|
||||
///////////////////////////////////////////
|
||||
|
||||
/// distant horizons stuff
|
||||
#define DISTORT_SHADOWMAP
|
||||
// #define DISTANT_HORIZONS_SHADOWMAP
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
@ -640,6 +647,15 @@ uniform int moonPhase;
|
||||
|
||||
// #define DH_SHADOWPROJECTIONTWEAK
|
||||
|
||||
#define DH_OVERDRAW_PREVENTION
|
||||
#define DH_KNOWN_ISSUES 0 // [0 1 2 3 4 5]
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// ----- DEBUG SETTINGS ----- //
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
#define debug_OFF 0
|
||||
#define debug_SHADOWMAP 1
|
||||
#define debug_NORMALS 2
|
||||
@ -650,13 +666,14 @@ uniform int moonPhase;
|
||||
#define debug_DH_WATER_BLENDING 7
|
||||
#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING]
|
||||
|
||||
/////////////////////////////////
|
||||
// ----- RANDOM SETTINGS ----- //
|
||||
/////////////////////////////////
|
||||
|
||||
// #define BLOOMY_PARTICLES
|
||||
// #define ORIGINAL_CHOCAPIC_SKY
|
||||
// #define CLOUDS_INFRONT_OF_WORLD
|
||||
|
||||
#define DH_OVERDRAW_PREVENTION
|
||||
#define DH_KNOWN_ISSUES 0 // [0 1 2 3 4 5]
|
||||
|
||||
// fix settings
|
||||
#if RESOURCEPACK_SKY == 0
|
||||
#endif
|
||||
|
@ -49,7 +49,6 @@ float LAYER0_DENSITY = dailyWeatherParams1.x;
|
||||
float LAYER1_DENSITY = dailyWeatherParams1.y;
|
||||
float LAYER2_DENSITY = dailyWeatherParams1.z;
|
||||
|
||||
|
||||
float rainCloudwetness = rainStrength;
|
||||
// float cloud_movement = frameTimeCounter * Cloud_Speed ;
|
||||
// float cloud_movement = abs((12000 - worldTime) * Cloud_Speed ) * 0.05;
|
||||
@ -97,84 +96,82 @@ float GetAltostratusDensity(vec3 pos){
|
||||
|
||||
float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float maxHeight){
|
||||
float FinalCloudCoverage = 0.0;
|
||||
|
||||
float coverage = 0.0;
|
||||
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;
|
||||
float LAYER1_minHEIGHT_FOG = max(CloudLayer1_height, LAYER0_maxHEIGHT);
|
||||
float LAYER1_maxHEIGHT_FOG = 100 + LAYER1_minHEIGHT_FOG;
|
||||
|
||||
|
||||
vec2 SampleCoords0 = vec2(0.0); vec2 SampleCoords1 = vec2(0.0);
|
||||
|
||||
float CloudSmall = 0.0;
|
||||
if(layer == 0){
|
||||
SampleCoords0 = (samplePos.xz + cloud_movement) / 5000;
|
||||
SampleCoords1 = (samplePos.xz - cloud_movement) / 500;
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
}
|
||||
|
||||
if(layer == 1){
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 15000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 2500);
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
}
|
||||
|
||||
if(layer == -1){
|
||||
float otherlayer = max(pos.y - (CloudLayer0_height+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
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;
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
}else{
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 15000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 1500);
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
}
|
||||
}
|
||||
float CloudSmall = 0;
|
||||
if(layer == 0) CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
if(layer == 1) CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
|
||||
float CloudLarge = texture2D(noisetex, SampleCoords0 ).b;
|
||||
|
||||
float coverage = 0.0;// abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
|
||||
float Topshape = 0.0;
|
||||
float Baseshape = 0.0;
|
||||
|
||||
if(layer == 0){
|
||||
coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
// coverage = 1.0 - pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 4.0);
|
||||
|
||||
float layer0 = min(min(coverage + dailyWeatherParams0.x, clamp(maxHeight - pos.y,0,1)), 1.0 - clamp(minHeight - pos.y,0,1));
|
||||
float layer0 = min(min(coverage + dailyWeatherParams0.x, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (maxHeight - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (maxHeight - 10),0.0) / 50.0;
|
||||
Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.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;
|
||||
|
||||
Baseshape = max(minHeight + 12.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage = max(layer0 - Topshape - Baseshape,0.0);
|
||||
FinalCloudCoverage = max(layer0 - Topshape - Baseshape * rainStrength,0.0);
|
||||
}
|
||||
|
||||
if(layer == 1){
|
||||
|
||||
coverage = (1.0-abs(CloudLarge-0.3)) * abs(CloudSmall-0.8);
|
||||
// coverage = ((1.0-abs(CloudLarge-0.3)) + abs(CloudSmall-0.8))/2;
|
||||
|
||||
// coverage = pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 2.0);
|
||||
// coverage = 1- ((1.0 - pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 4.0)) - (pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 2.0)));
|
||||
|
||||
|
||||
coverage *= coverage;
|
||||
|
||||
float layer1 = min(min(coverage + dailyWeatherParams0.y - 0.5,clamp(maxHeight - pos.y,0,1)), 1.0 - clamp(minHeight - pos.y,0,1));
|
||||
float layer1 = min(min(coverage + dailyWeatherParams0.y - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (maxHeight - 75), 0.0) / 200;
|
||||
Topshape += max(pos.y - (maxHeight - 10 ), 0.0) / 50;
|
||||
Baseshape = max(minHeight + 12.5 - pos.y, 0.0) / 50.0;
|
||||
Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10), 0.0) / 15.0;
|
||||
Baseshape = max(LAYER1_minHEIGHT_FOG + 15.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage = max(layer1 - Topshape - Baseshape, 0.0);
|
||||
FinalCloudCoverage = max(layer1 - Topshape - Baseshape * rainStrength, 0.0);
|
||||
}
|
||||
|
||||
|
||||
if(layer == -1){
|
||||
float LAYER0_minHEIGHT_FOG = CloudLayer0_height;
|
||||
float LAYER0_maxHEIGHT_FOG = 100 + LAYER0_minHEIGHT_FOG;
|
||||
|
||||
|
||||
float LAYER1_minHEIGHT_FOG = max(CloudLayer1_height,LAYER0_maxHEIGHT);
|
||||
float LAYER1_maxHEIGHT_FOG = 100 + LAYER1_minHEIGHT_FOG;
|
||||
|
||||
#ifdef CloudLayer0
|
||||
float layer0 = min(min(coverage + LAYER0_COVERAGE, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
float layer0_coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
float layer0 = min(min(layer0_coverage + dailyWeatherParams0.x, 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;
|
||||
@ -183,8 +180,10 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
FinalCloudCoverage += max(layer0 - Topshape - Baseshape,0.0);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CloudLayer1
|
||||
float layer1 = min(min(coverage + LAYER1_COVERAGE, clamp(LAYER1_maxHEIGHT - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
float layer1_coverage = (1.0-abs(CloudLarge-0.3)) * abs(CloudSmall-0.8);
|
||||
float layer1 = min(min(layer1_coverage + dailyWeatherParams0.y - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75), 0.0) / 200;
|
||||
Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10 ), 0.0) / 50;
|
||||
@ -199,6 +198,11 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
|
||||
//Erode cloud with 3d Perlin-worley noise, actual cloud value
|
||||
float cloudVol(int layer, in vec3 pos, in vec3 samplePos, in float cov, in int LoD, float minHeight, float maxHeight){
|
||||
|
||||
// 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 otherlayer = max(pos.y - (CloudLayer0_height+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
float upperPlane = otherlayer;
|
||||
|
||||
@ -209,9 +213,10 @@ float cloudVol(int layer, in vec3 pos, in vec3 samplePos, in float cov, in int L
|
||||
|
||||
samplePos.xz -= cloud_movement/4;
|
||||
|
||||
if(layer == 0 || layer == 1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50);
|
||||
// if(layer == 0 || layer == 1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50);
|
||||
// if(layer == -1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
|
||||
if(layer == -1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
|
||||
noise += (1.0-densityAtPos(samplePos * mix(100.0,200.0,upperPlane)) ) * mix(2.0,1.0,upperPlane);
|
||||
|
||||
@ -271,7 +276,7 @@ vec3 DoCloudLighting(
|
||||
float powder = 1.0 - exp(-10.0 * densityFaded);
|
||||
float lesspowder = powder*0.4+0.6;
|
||||
|
||||
float indirectScatter = exp( -10 * sqrt((skyScatter*skyScatter*skyScatter) * densityFaded)) * lesspowder;
|
||||
float indirectScatter = exp2( -15 * sqrt((skyScatter*skyScatter*skyScatter) * densityFaded)) * lesspowder;
|
||||
|
||||
vec3 indirectLight = skyLightCol * mix(1.0, indirectScatter, distantfog);
|
||||
|
||||
@ -371,42 +376,45 @@ if(layer == 2){
|
||||
|
||||
/// avoid overdraw
|
||||
if(notVisible) 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){
|
||||
float cumulus = GetCumulusDensity(layer, rayProgress, 1, minHeight, maxHeight);
|
||||
|
||||
float cumulus = GetCumulusDensity(layer, rayProgress, 1, minHeight, maxHeight);
|
||||
|
||||
float fadedDensity = cloudDensity * clamp(exp( (rayProgress.y - (maxHeight - 75)) / 9.0 ),0.0,1.0);
|
||||
float fadedDensity = cloudDensity * clamp(exp( (rayProgress.y - (maxHeight - 75)) / 9.0 ),0.0,1.0);
|
||||
|
||||
if(cumulus > 1e-5 && clamp(rayProgress.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayProgress.y - minHeight,0.0,1.0) > 0.0){ // make sure no work is done on pixels with no densities
|
||||
float muE = cumulus * fadedDensity;
|
||||
if(cumulus > 1e-5 ){ // make sure no work is done on pixels with no densities
|
||||
float muE = cumulus * fadedDensity;
|
||||
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = rayProgress + dV_Sun * (0.1 + j * (0.1 + dither*0.05));
|
||||
float shadow = GetCumulusDensity(layer, shadowSamplePos, 0, minHeight, maxHeight) * cloudDensity;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = rayProgress + dV_Sun * (0.1 + j * (0.1 + dither*0.05));
|
||||
float shadow = GetCumulusDensity(layer, shadowSamplePos, 0, minHeight, maxHeight) * cloudDensity;
|
||||
|
||||
directLight += shadow;
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
/// 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);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
directLight += HighAlt_shadow;
|
||||
#endif
|
||||
float skyScatter = clamp(((maxHeight - 20 - rayProgress.y) / 275.0) * (0.5+cloudDensity),0.0,1.0);
|
||||
vec3 lighting = DoCloudLighting(muE, cumulus, 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);
|
||||
|
||||
if (TOTAL_EXTINCTION < 1e-5) break;
|
||||
}
|
||||
|
||||
/// 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);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
directLight += HighAlt_shadow;
|
||||
#endif
|
||||
float skyScatter = clamp(((maxHeight - 20 - rayProgress.y) / 275.0) * (0.5+cloudDensity),0.0,1.0);
|
||||
vec3 lighting = DoCloudLighting(muE, cumulus, 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);
|
||||
|
||||
if (TOTAL_EXTINCTION < 1e-5) break;
|
||||
}
|
||||
rayProgress += dV_view;
|
||||
}
|
||||
@ -458,11 +466,13 @@ vec4 renderClouds(
|
||||
// maxIT_clouds = 15;
|
||||
|
||||
vec3 dV_view = normalize(viewPos.xyz);
|
||||
vec3 dV_viewTEST = viewPos.xyz;
|
||||
|
||||
// this is the cloud curvature.
|
||||
dV_view.y += 0.025 * heightRelativeToClouds;
|
||||
|
||||
vec3 dV_view_Alto = dV_view;
|
||||
|
||||
dV_view_Alto *= 100/abs(dV_view_Alto.y)/15;
|
||||
float mult_alto = length(dV_view_Alto);
|
||||
|
||||
@ -529,6 +539,7 @@ vec4 renderClouds(
|
||||
|
||||
bool altoNotVisible = false;
|
||||
|
||||
|
||||
#ifdef CloudLayer0
|
||||
vec3 layer0_start = layerStartingPosition(dV_view, cameraPosition, Dither.y, MinHeight, MaxHeight);
|
||||
#endif
|
||||
@ -635,7 +646,7 @@ float GetCloudShadow(vec3 feetPlayerPos){
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp2((shadow*shadow) * -150.0);
|
||||
shadow = exp2((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
@ -652,7 +663,44 @@ float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){
|
||||
|
||||
#ifdef CloudLayer0
|
||||
vec3 lowShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer0_height + 30) - WorldPos.y,0.0) ;
|
||||
shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
shadow += max(GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100),0.0)*LAYER0_DENSITY;
|
||||
#endif
|
||||
#ifdef CloudLayer1
|
||||
vec3 higherShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer1_height + 30) - WorldPos.y,0.0) ;
|
||||
shadow += max(GetCumulusDensity(1,higherShadowStart, 0, CloudLayer1_height,CloudLayer1_height+100) ,0.0)*LAYER1_DENSITY;
|
||||
#endif
|
||||
#ifdef CloudLayer2
|
||||
vec3 highShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max(CloudLayer2_height - WorldPos.y,0.0);
|
||||
shadow += GetAltostratusDensity(highShadowStart)*LAYER2_DENSITY * 0.5;
|
||||
#endif
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float GetCloudShadow_VLFOG_DITHER(vec3 WorldPos, vec3 WorldSpace_sunVec, float dither){
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
#ifdef CloudLayer0
|
||||
// vec3 lowShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer0_height + 30) - WorldPos.y,0.0) ;
|
||||
// shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
|
||||
for (int j=0; j < 8; j++){
|
||||
vec3 lowShadowStart = WorldPos + WorldSpace_sunVec * ( j * 50 + dither*50);
|
||||
shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height, CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef CloudLayer1
|
||||
vec3 higherShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer1_height + 50) - WorldPos.y,0.0) ;
|
||||
@ -665,7 +713,7 @@ float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp((shadow*shadow) * -150.0);
|
||||
shadow = exp((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
|
Reference in New Issue
Block a user