Cloud fog

cloud fog?
This commit is contained in:
Xonk 2023-06-10 23:30:29 -04:00
parent 2e7d464b14
commit b8799363ed
15 changed files with 263 additions and 64 deletions

View File

@ -813,6 +813,7 @@ void main() {
vec3 AmbientLightColor = avgAmbient; vec3 AmbientLightColor = avgAmbient;
float cloudShadow = 1.0; float cloudShadow = 1.0;
if ( z >= 1.) { //sky if ( z >= 1.) { //sky
@ -945,10 +946,10 @@ void main() {
vec3 Indirect_lighting = vec3(1.0); vec3 Indirect_lighting = vec3(1.0);
// float skylight = clamp(abs(normal.y+1),0.0,1.0); // float cloudOcclusion = GetCloudShadow_occluson(p3 + cameraPosition);
float skylight = clamp(abs(ambientCoefs.y+1.0),0.35,2.0); // AmbientLightColor *= cloudOcclusion*0.5+.5;
// float skylight = clamp(abs(ambientCoefs.y+0.5),0.35,2.0);
float skylight = clamp(abs(ambientCoefs.y + 1.0),0.35,2.0);
#if indirect_effect == 2 || indirect_effect == 3 || indirect_effect == 4 #if indirect_effect == 2 || indirect_effect == 3 || indirect_effect == 4
if (!hand) skylight = 1.0; if (!hand) skylight = 1.0;
@ -959,6 +960,7 @@ void main() {
if((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)) newLightmap.y = min(newLightmap.y+0.1,1.0); if((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)) newLightmap.y = min(newLightmap.y+0.1,1.0);
#ifndef ambientSSS_view #ifndef ambientSSS_view
Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), newLightmap.xy, skylight); Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), newLightmap.xy, skylight);
#endif #endif

View File

@ -212,10 +212,14 @@ void main() {
vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z)); vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
#ifdef Cloud_Fog
vec4 VL_CLOUDFOG = InsideACloudFog(fragpos, vec2(R2_dither(),blueNoise()), lightCol.rgb/80., moonColor/150., (avgAmbient*2.0) * 8./150./3.);
gl_FragData[0] = clamp(VL_CLOUDFOG,0.0,65000.);
#else
vec4 VL_Fog = getVolumetricRays(fragpos,blueNoise(),avgAmbient); vec4 VL_Fog = getVolumetricRays(fragpos,blueNoise(),avgAmbient);
gl_FragData[0] = clamp(VL_Fog,0.0,65000.); gl_FragData[0] = clamp(VL_Fog,0.0,65000.);
#endif
} else { } else {
float dirtAmount = Dirt_Amount; float dirtAmount = Dirt_Amount;

View File

@ -298,7 +298,8 @@ void main() {
#ifdef display_LUT #ifdef display_LUT
vec2 movedTC = texcoord ; vec2 movedTC = texcoord ;
if(texcoord.x < 0.45 ) color.rgb = texture2D(colortex4,movedTC).rgb / 150. * 5.0; vec3 thingy = texture2D(colortex4,movedTC).rgb / 150. * 5.0;
if(texcoord.x < 0.45 && luma(thingy) > 0.0 ) color.rgb = thingy;
#endif #endif

View File

@ -85,6 +85,7 @@ vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.);
float luma(vec3 color) { float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114)); return dot(color,vec3(0.299, 0.587, 0.114));
} }
#include "lib/volumetricFog.glsl" #include "lib/volumetricFog.glsl"
const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0); const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0);
@ -194,7 +195,7 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0);
vec3 viewVector = cartToSphere(p); vec3 viewVector = cartToSphere(p);
vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(blueNoise(),R2_dither()), sunColorCloud, moonColor, ambientUp*5.0); vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), sunColorCloud, moonColor, ambientUp*5.0);
vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), ambientUp); vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), ambientUp);

View File

@ -175,10 +175,12 @@ void main() {
moonColorCloud = calculateAtmosphere(vec3(0.0), modSunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5); moonColorCloud = calculateAtmosphere(vec3(0.0), modSunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5);
moonColorCloud = moonColorBase/4000.0*0.55; moonColorCloud = moonColorBase/4000.0*0.55;
// #ifndef CLOUDS_SHADOWS // #ifndef CLOUDS_SHADOWS
// sunColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94)); // sunColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94));
// moonColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94)); // moonColor *= (1.0-rainStrength*vec3(0.96,0.95,0.94));
// #endif // #endif
lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis; lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis;
float lightDir = float( sunVis >= 1e-5)*2.0-1.0; float lightDir = float( sunVis >= 1e-5)*2.0-1.0;
@ -196,7 +198,7 @@ void main() {
ambientDown += bouncedSun*clamp(lightDir*sunVec.y+4.,0.0,4.)*0.7 + cloudAmbientSun*clamp(-sunVec.y+2.,0.0,4.)*0.5 + cloudAmbientMoon*clamp(sunVec.y+2.,0.0,4.)*0.5; ambientDown += bouncedSun*clamp(lightDir*sunVec.y+4.,0.0,4.)*0.7 + cloudAmbientSun*clamp(-sunVec.y+2.,0.0,4.)*0.5 + cloudAmbientMoon*clamp(sunVec.y+2.,0.0,4.)*0.5;
avgSky += bouncedSun*5.; avgSky += bouncedSun*5.;
vec3 rainNightBoost = moonColorCloud*rainStrength*0.005; vec3 rainNightBoost = moonColorCloud*0.005;
ambientUp += rainNightBoost; ambientUp += rainNightBoost;
ambientLeft += rainNightBoost; ambientLeft += rainNightBoost;
ambientRight += rainNightBoost; ambientRight += rainNightBoost;

View File

@ -5,10 +5,10 @@
#ifdef TAA_UPSCALING #ifdef TAA_UPSCALING
#define RENDER_SCALE_X 0.7 // X axis render resolution multiplier [0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1. ] #define SCALE_FACTOR 0.75 // render resolution multiplier. below 0.5 not recommended [0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95]
#define RENDER_SCALE_Y 0.7 // Y axis render resolution multiplier [0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1. ]
#define RENDER_SCALE vec2(RENDER_SCALE_X, RENDER_SCALE_Y) #define RENDER_SCALE vec2(SCALE_FACTOR, SCALE_FACTOR)
#define UPSCALING_SHARPNENING 2.0 - RENDER_SCALE_X - RENDER_SCALE_Y #define UPSCALING_SHARPNENING 2.0 - SCALE_FACTOR - SCALE_FACTOR
#else #else
#define RENDER_SCALE vec2(1.0, 1.0) #define RENDER_SCALE vec2(1.0, 1.0)
#define UPSCALING_SHARPNENING 0.0 #define UPSCALING_SHARPNENING 0.0

View File

@ -112,6 +112,7 @@
#define CaveFog_amount 1 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25] #define CaveFog_amount 1 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define Cloud_Fog // render the VL clouds a second time along with VL fog so you can fly through it and stuff. expect a noticeable performance hit.
// ----- TIME OF DAY FOG ----- // // ----- TIME OF DAY FOG ----- //
#define TOD_Fog_mult 1.0 // [0.0 0.25 0.5 0.75 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0] #define TOD_Fog_mult 1.0 // [0.0 0.25 0.5 0.75 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
@ -324,7 +325,6 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] THIS WILL BREAK SUBSURF
#define WeatherDay -1 // [-1 0 1 2 3 4 5 6 7] #define WeatherDay -1 // [-1 0 1 2 3 4 5 6 7]
#define cloudCoverage 0.4 // Cloud coverage [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0] #define cloudCoverage 0.4 // Cloud coverage [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
#define cloud_LevelOfDetail 1 // Number of fbm noise iterations for on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8] #define cloud_LevelOfDetail 1 // Number of fbm noise iterations for on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
#define cloud_ShadowLevelOfDetail 0 // Number of fbm noise iterations for the shadowing of on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8] #define cloud_ShadowLevelOfDetail 0 // Number of fbm noise iterations for the shadowing of on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
#define cloud_LevelOfDetailLQ 1 // Number of fbm noise iterations for reflected clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8] #define cloud_LevelOfDetailLQ 1 // Number of fbm noise iterations for reflected clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]

View File

@ -212,7 +212,7 @@ void MaterialReflections(
f0 = f0.y == 0.0 ? vec3(0.02) : f0; f0 = f0.y == 0.0 ? vec3(0.02) : f0;
// f0 = vec3(0.0); // f0 = vec3(0.9);
// roughness = 0.0; // roughness = 0.0;
mat3 basis = CoordBase(normal); mat3 basis = CoordBase(normal);

View File

@ -16,9 +16,11 @@
uniform float viewHeight; uniform float viewHeight;
uniform float viewWidth; uniform float viewWidth;
uniform sampler2D colortex4;//Skybox uniform sampler2D colortex4;//Skybox
#define WEATHERCLOUDS #define WEATHERCLOUDS
#include "/lib/climate_settings.glsl" #include "/lib/climate_settings.glsl"
float CumulusHeight = Cumulus_height; float CumulusHeight = Cumulus_height;
@ -148,7 +150,7 @@ vec3 Cloud_lighting(
skyLighting += sunContributionMulti * exp(-SunShadowing) * clamp((1.0 - abs(pow(Density*4.0 - 1.1,4.0))) * Coverage,0,1) ; skyLighting += sunContributionMulti * exp(-SunShadowing) * clamp((1.0 - abs(pow(Density*4.0 - 1.1,4.0))) * Coverage,0,1) ;
#endif #endif
skyLighting *= exp(SkyShadowing * AmbientShadow * coeeff/(2.0 - time) ) * lesspowder ; skyLighting *= exp(SkyShadowing * AmbientShadow * coeeff/2.0 ) * lesspowder ;
if(cloudType == 1){ if(cloudType == 1){
@ -259,7 +261,7 @@ vec4 renderClouds(
// IntersecTerrain = length(progress_view - cameraPosition) > lViewPosM; // IntersecTerrain = length(progress_view - cameraPosition) > lViewPosM;
// if(IntersecTerrain) break; // if(IntersecTerrain) break;
float cumulus = GetCumulusDensity(progress_view, cloudLoD); float cumulus = GetCumulusDensity(progress_view, 1);
float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight - 75)) / 9.0 ),0.0,1.0); float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight - 75)) / 9.0 ),0.0,1.0);
@ -287,7 +289,7 @@ vec4 renderClouds(
Sunlight += HighAlt_shadow; Sunlight += HighAlt_shadow;
#endif #endif
float phase = PhaseHG(-SdotV, (1.0-cumulus)); // float phase = PhaseHG(-SdotV, (1.0-cumulus));
float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ; float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ;
@ -369,10 +371,10 @@ float GetCloudShadow_VLFOG(vec3 WorldPos){
float shadow = 0.0; float shadow = 0.0;
// assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud. // assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud.
#ifdef Cumulus // #ifdef Cumulus
vec3 lowShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight - 70) - WorldPos.y,0.0) ; vec3 lowShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight - 60) - WorldPos.y,0.0) ;
shadow += GetCumulusDensity(lowShadowStart,0)*Cumulus_density; shadow += GetCumulusDensity(lowShadowStart,0)*Cumulus_density;
#endif // #endif
#ifdef Altostratus #ifdef Altostratus
vec3 highShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - WorldPos.y,0.0); vec3 highShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - WorldPos.y,0.0);
@ -381,24 +383,23 @@ float GetCloudShadow_VLFOG(vec3 WorldPos){
// shadow = shadow/2.0; // perhaps i should average the 2 shadows being added.... // shadow = shadow/2.0; // perhaps i should average the 2 shadows being added....
shadow = clamp(exp(-shadow*15.0),0.0,1.0); shadow = clamp(exp(-shadow*255.0),0.0,1.0);
// do not allow it to exist above the lowest cloud plane // do not allow it to exist above the lowest cloud plane
shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ; // shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ;
return shadow; return shadow;
} }
float GetAltoOcclusion(vec3 eyePlayerPos){
vec3 playerPos = eyePlayerPos + cameraPosition; float GetCloudShadow_occluson(vec3 WorldPos){
playerPos.y += 0.05;
float shadow = 0.0; float shadow = 0.0;
vec3 lowShadowStart = playerPos + normalize(vec3(0,1,0)) * max((MaxCumulusHeight - 70) - playerPos.y,0.0) ; #ifdef Cumulus
shadow = GetCumulusDensity(lowShadowStart,0) * cloudDensity; vec3 lowShadowStart = WorldPos + vec3(0,0.7,0) * max((MaxCumulusHeight - 60) - WorldPos.y,0.0) ;
shadow += GetCumulusDensity(lowShadowStart,1)*Cumulus_density;
shadow = clamp(exp(-shadow * 5),0.0,1.0);
#endif
shadow = clamp(exp(shadow * -1),0.0,1.0);
return shadow; return shadow;
} }

View File

@ -36,7 +36,7 @@ float cloudVol(in vec3 pos){
TimeOfDayFog(UniformFog, CloudyFog); TimeOfDayFog(UniformFog, CloudyFog);
return CloudyFog + UniformFog + RainFog; return CloudyFog + UniformFog;
} }
vec4 getVolumetricRays( vec4 getVolumetricRays(
@ -91,6 +91,7 @@ vec4 getVolumetricRays(
float muS = mu; float muS = mu;
float absorbance = 1.0; float absorbance = 1.0;
float expFactor = 11.0; float expFactor = 11.0;
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a; vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
@ -100,16 +101,18 @@ vec4 getVolumetricRays(
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0); float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
progress = start.xyz + d*dV; progress = start.xyz + d*dV;
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld; progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
//project into biased shadowmap space //project into biased shadowmap space
float distortFactor = calcDistort(progress.xy); float distortFactor = calcDistort(progress.xy);
vec3 pos = vec3(progress.xy*distortFactor, progress.z); vec3 pos = vec3(progress.xy*distortFactor, progress.z);
float densityVol = cloudVol(progressW); float densityVol = cloudVol(progressW);
float sh = 1.0; float sh = 1.0;
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5; // if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
sh = shadow2D( shadow, pos).x; // pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
} // sh = shadow2D( shadow, pos).x;
// }
#ifdef VL_CLOUDS_SHADOWS #ifdef VL_CLOUDS_SHADOWS
sh *= GetCloudShadow_VLFOG(progressW); sh *= GetCloudShadow_VLFOG(progressW);
@ -133,10 +136,202 @@ vec4 getVolumetricRays(
vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount; vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount;
vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.); vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ; vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance; vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
absorbance *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333)); absorbance *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
} }
return vec4(vL,absorbance); return vec4(vL,absorbance);
} }
vec4 InsideACloudFog(
vec3 fragpos,
vec2 Dither,
vec3 SunColor,
vec3 MoonColor,
vec3 SkyColor
){
#ifndef VOLUMETRIC_CLOUDS
return vec4(0.0,0.0,0.0,1.0);
#endif
float total_extinction = 1.0;
vec3 color = vec3(0.0);
//project pixel position into projected shadowmap space
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + 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 = toShadowSpaceProjected(vec3(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);
// float maxLength = min(length(dVWorld),16*8)/length(dVWorld);
float maxLength = min(length(dVWorld),far+16)/length(dVWorld);
dV *= maxLength;
dVWorld *= maxLength;
float mult = length(dVWorld)/25;
float dL = length(dVWorld);
vec3 progress = start.xyz;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
vec3 progress_view = vec3(0.0);
float expFactor = 11.0;
////// lighitng stuff
float shadowStep = 200.;
vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
vec3 dV_Sun_small = dV_Sun/shadowStep;
float SdotV = dot(sunVec,normalize(fragpos));
SkyColor *= clamp(abs(dV_Sun.y)/100.,0.75,1.0);
SunColor = SunColor * clamp(dV_Sun.y ,0.0,1.0);
MoonColor *= clamp(-dV_Sun.y,0.0,1.0);
vec3 Fog_SkyCol = SkyColor;
vec3 Fog_SunCol = SunColor;
// if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun;
float mieDay = phaseg(SdotV, 0.75) * 3.14;
float mieDayMulti = phaseg(SdotV, 0.35) * 2;
vec3 sunContribution = SunColor * mieDay;
vec3 sunContributionMulti = SunColor * mieDayMulti ;
float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4);
vec3 moonContribution = MoonColor * mieNight;
float timing = 1.0 - clamp(pow(abs(dV_Sun.y)/150.0,2.0),0.0,1.0);
///////// fog part
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
float mie = phaseg(SdotV,0.7)*5.0 + 1.0;
float rayL = phaseRayleigh(SdotV);
#ifdef Biome_specific_environment
// recolor change sun and sky color to some color, but make sure luminance is preserved.
BiomeFogColor(Fog_SunCol);
BiomeFogColor(Fog_SkyCol);
#endif
vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5);
vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6);
float mu = 1.0;
float muS = mu;
#ifdef Cumulus
for (int i=0;i<VL_SAMPLES;i++) {
float d = (pow(expFactor, float(i+Dither.x)/float(VL_SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+Dither.x)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
progress = start.xyz + d*dV;
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
//project into biased shadowmap space
float distortFactor = calcDistort(progress.xy);
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
float sh = 1.0;
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
sh = shadow2D( shadow, pos).x;
}
#ifdef VL_CLOUDS_SHADOWS
sh *= GetCloudShadow_VLFOG(progressW);
#endif
float densityVol = cloudVol(progressW);
//Water droplets(fog)
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
//Just air
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24 * Haze_amount;
//Pbr for air, yolo mix between mie and rayleigh for water droplets
vec3 rL = rC*airCoef.x;
vec3 m = (airCoef.y+density)*mC;
vec3 DirectLight = (Fog_SunCol*sh) * (rayL*rL+m*mie);
vec3 AmbientLight = Fog_SkyCol * m;
vec3 AtmosphericFog = Fog_SkyCol * (rL+m) ;
// extra fog effects
vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount;
vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
color += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*total_extinction;
total_extinction *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
sh = 1.0; // make sure cloud shadows dont shadow the clouds hurhur
progress_view = progressW;
float cumulus = GetCumulusDensity(progress_view, 1);
float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight - 75)) / 9.0 ),0.0,1.0);
if(cumulus > 1e-5){
float muE = cumulus*alteredDensity;
float Sunlight = 0.0;
float MoonLight = 0.0;
for (int j=0; j < 3; j++){
vec3 shadowSamplePos = progress_view + (dV_Sun * 0.15) * (1 + Dither.y/2 + j);
float shadow = GetCumulusDensity(shadowSamplePos, 0) * Cumulus_density;
Sunlight += shadow / (1 + j);
MoonLight += shadow;
}
Sunlight += 1.0 - sh;
MoonLight += 1.0 - sh;
#ifdef Altostratus
// cast a shadow from higher clouds onto lower clouds
vec3 HighAlt_shadowPos = progress_view + dV_Sun/abs(dV_Sun.y) * max(AltostratusHeight - progress_view.y,0.0);
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos);
Sunlight += HighAlt_shadow;
#endif
float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ;
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, timing);
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
color += max(muE*Sint*total_extinction,0.0);
total_extinction *= max(exp(-mult*muE),0.0);
}
if (total_extinction < 1e-5) break;
}
#endif
return vec4(color, total_extinction);
}

View File

@ -43,7 +43,7 @@ alphaTest.gbuffers_skytextured=false
alphaTest.gbuffers_hand=true alphaTest.gbuffers_hand=true
sliders =CompSky_R CompSky_G CompSky_B ambientsss_brightness SSS_TYPE Cloud_Speed Cumulus_height Cumulus_coverage Cumulus_density Alto_coverage Alto_density ORB_ColMult ORB_X ORB_Y ORB_Z ORB_R ORB_G ORB_B TOD_Fog_mult Morning_Uniform_Fog Noon_Uniform_Fog Evening_Uniform_Fog Night_Uniform_Fog Morning_Cloudy_Fog Noon_Cloudy_Fog Evening_Cloudy_Fog Night_Cloudy_Fog NetherFog_brightness WeatherDay Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength Cloud_Height Dynamic_sky_day ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B cloud_speed Rain_coverage override_R override_G override_B override_Cloudy_Fog_Density override_cloudyfog_fade override_fog override_Uniform_Fog_Density override_uniformfog_fade override_Bloomy_Fog override_Sun_Strength Moon_temp Haze_amount UniformFog_amount CloudyFog_amount TimeOfDayFog_multiplier RainFog_amount CaveFog_amount uniformfog_fade cloudyfog_fade cloudray_amount Swamp_cloudyfog_height Jungle_cloudyfog_fade Swamp_uniformfog_height Jungle_uniformfog_fade noise_mode Distant_shadow_quality ambient_temp Sun_temp Puddle_Size Cloud_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength Swamp_Sun_Strength Jungle_Sun_Strength Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_cloudyfog_Density Jungle_Cloudy_Fog_Density Swamp_UniformFog_Density Jungle_Uniform_Fog_Density Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_R Swamp_G Swamp_B Jungle_R Jungle_G Jungle_B Jungle_fog_strength Swamp_fog_strength Lush_fog_strength Snells_Window_Width self_shadow_samples Shadow_brightness Cloud_top_cutoff Cloud_base_cutoff Cloud_fade_amount BLOOMY_FOG FOG_RAIN_MULTIPLIER FOG_TOD_MULTIPLIER CLOUDY_FOG_AMOUNT BASE_FOG_AMOUNT WAVY_SPEED WAVY_STRENGTH ANTI_GHOSTING BLOOM_STRENGTH shadowDistance shadowDistanceRenderMul FinalR FinalG FinalB Ambient_Mult Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation SKY_BRIGHTNESS_DAY SKY_BRIGHTNESS_NIGHT BLEND_FACTOR FLICKER_REDUCTION MOTION_REJECTION VL_SAMPLES Exposure_Speed POM_MAP_RES POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL ATMOSPHERIC_DENSITY CLOUDS_SHADOWS_STRENGTH moon_illuminance moonColorR moonColorG moonColorB fog_mieg1 fog_mieg2 fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius SSAO_SAMPLES Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Mie_Phase Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK RENDER_SCALE_X RENDER_SCALE_Y VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ cloudDensity cloudCoverage fbmAmount fbmPower1 fbmPower2 cloudMieG cloudMieG2 cloudMie2Multiplier Strong_SSS_strength Medium_SSS_strength Weak_SSS_strength Shadow_brightness Roughness_Threshold Sun_specular_Strength reflection_quality Roughness_Strength SSS_mode DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS sliders = SCALE_FACTOR CompSky_R CompSky_G CompSky_B ambientsss_brightness SSS_TYPE Cloud_Speed Cumulus_height Cumulus_coverage Cumulus_density Alto_coverage Alto_density ORB_ColMult ORB_X ORB_Y ORB_Z ORB_R ORB_G ORB_B TOD_Fog_mult Morning_Uniform_Fog Noon_Uniform_Fog Evening_Uniform_Fog Night_Uniform_Fog Morning_Cloudy_Fog Noon_Cloudy_Fog Evening_Cloudy_Fog Night_Cloudy_Fog NetherFog_brightness WeatherDay Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength Cloud_Height Dynamic_sky_day ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B cloud_speed Rain_coverage override_R override_G override_B override_Cloudy_Fog_Density override_cloudyfog_fade override_fog override_Uniform_Fog_Density override_uniformfog_fade override_Bloomy_Fog override_Sun_Strength Moon_temp Haze_amount UniformFog_amount CloudyFog_amount TimeOfDayFog_multiplier RainFog_amount CaveFog_amount uniformfog_fade cloudyfog_fade cloudray_amount Swamp_cloudyfog_height Jungle_cloudyfog_fade Swamp_uniformfog_height Jungle_uniformfog_fade noise_mode Distant_shadow_quality ambient_temp Sun_temp Puddle_Size Cloud_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength Swamp_Sun_Strength Jungle_Sun_Strength Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_cloudyfog_Density Jungle_Cloudy_Fog_Density Swamp_UniformFog_Density Jungle_Uniform_Fog_Density Swamp_Bloomy_Fog Jungle_Bloomy_Fog Swamp_Mie Jungle_Mie Swamp_R Swamp_G Swamp_B Jungle_R Jungle_G Jungle_B Jungle_fog_strength Swamp_fog_strength Lush_fog_strength Snells_Window_Width self_shadow_samples Shadow_brightness Cloud_top_cutoff Cloud_base_cutoff Cloud_fade_amount BLOOMY_FOG FOG_RAIN_MULTIPLIER FOG_TOD_MULTIPLIER CLOUDY_FOG_AMOUNT BASE_FOG_AMOUNT WAVY_SPEED WAVY_STRENGTH ANTI_GHOSTING BLOOM_STRENGTH shadowDistance shadowDistanceRenderMul FinalR FinalG FinalB Ambient_Mult Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation SKY_BRIGHTNESS_DAY SKY_BRIGHTNESS_NIGHT BLEND_FACTOR FLICKER_REDUCTION MOTION_REJECTION VL_SAMPLES Exposure_Speed POM_MAP_RES POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL ATMOSPHERIC_DENSITY CLOUDS_SHADOWS_STRENGTH moon_illuminance moonColorR moonColorG moonColorB fog_mieg1 fog_mieg2 fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius SSAO_SAMPLES Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Mie_Phase Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK RENDER_SCALE_X RENDER_SCALE_Y VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ cloudDensity cloudCoverage fbmAmount fbmPower1 fbmPower2 cloudMieG cloudMieG2 cloudMie2Multiplier Strong_SSS_strength Medium_SSS_strength Weak_SSS_strength Shadow_brightness Roughness_Threshold Sun_specular_Strength reflection_quality Roughness_Strength SSS_mode DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS
screen.columns=2 screen.columns=2
screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds] [Misc_Settings] [Climate] screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds] [Misc_Settings] [Climate]
@ -138,11 +138,11 @@ screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds]
### CLOUDS ### CLOUDS
screen.Clouds.columns=2 screen.Clouds.columns=2
# screen.Clouds = VOLUMETRIC_CLOUDS Altostratus cloud_LevelOfDetail cloud_ShadowLevelOfDetail CLOUDS_QUALITY cloudDensity cloudCoverage Rain_coverage fbmAmount fbmPower1 fbmPower2 Cloud_top_cutoff Cloud_base_cutoff Shadow_brightness self_shadow_samples CLOUDS_SHADOWS VL_CLOUDS_SHADOWS # screen.Clouds = VOLUMETRIC_CLOUDS Altostratus cloud_LevelOfDetail cloud_ShadowLevelOfDetail CLOUDS_QUALITY cloudDensity cloudCoverage Rain_coverage fbmAmount fbmPower1 fbmPower2 Cloud_top_cutoff Cloud_base_cutoff Shadow_brightness self_shadow_samples CLOUDS_SHADOWS VL_CLOUDS_SHADOWS
screen.Clouds = VOLUMETRIC_CLOUDS CLOUDS_QUALITY Cumulus Altostratus Cumulus_coverage Alto_coverage Cumulus_density Alto_density Cumulus_height CLOUDS_SHADOWS Cloud_Speed Rain_coverage screen.Clouds = VOLUMETRIC_CLOUDS CLOUDS_QUALITY Cumulus Altostratus Cumulus_coverage Alto_coverage Cumulus_density Alto_density Cumulus_height CLOUDS_SHADOWS Cloud_Speed Rain_coverage Cloud_Fog
### FOG ### FOG
screen.Fog.columns=1 screen.Fog.columns=1
screen.Fog = VL_RENDER_RESOLUTION VL_SAMPLES BLOOMY_FOG Haze_amount RainFog_amount [TOD_fog] [Biome_Fog] [Cave_Fog] BorderFog screen.Fog = VL_RENDER_RESOLUTION VL_SAMPLES BLOOMY_FOG Haze_amount RainFog_amount [TOD_fog] [Biome_Fog] [Cave_Fog] BorderFog Cloud_Fog
screen.TOD_fog.columns=2 screen.TOD_fog.columns=2
screen.TOD_fog = TOD_Fog_mult <skip> Morning_Uniform_Fog Morning_Cloudy_Fog Noon_Uniform_Fog Noon_Cloudy_Fog Evening_Uniform_Fog Evening_Cloudy_Fog Night_Uniform_Fog Night_Cloudy_Fog screen.TOD_fog = TOD_Fog_mult <skip> Morning_Uniform_Fog Morning_Cloudy_Fog Noon_Uniform_Fog Noon_Cloudy_Fog Evening_Uniform_Fog Evening_Cloudy_Fog Night_Uniform_Fog Night_Cloudy_Fog
@ -165,7 +165,7 @@ screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds]
screen.Post_Processing = [TAA_OPTIONS] [Purkinje_effect] [Tonemapping] [Exposure] [DepthOfField] [Editing] <skip> SHARPENING BLOOM_STRENGTH BLOOM_QUALITY screen.Post_Processing = [TAA_OPTIONS] [Purkinje_effect] [Tonemapping] [Exposure] [DepthOfField] [Editing] <skip> SHARPENING BLOOM_STRENGTH BLOOM_QUALITY
### TAA ### TAA
screen.TAA_OPTIONS.columns = 1 screen.TAA_OPTIONS.columns = 1
screen.TAA_OPTIONS= SCREENSHOT_MODE SPLIT_RENDER TAA BLEND_FACTOR <skip> TAA_UPSCALING RENDER_SCALE_X RENDER_SCALE_Y screen.TAA_OPTIONS= SCREENSHOT_MODE SPLIT_RENDER TAA BLEND_FACTOR <skip> TAA_UPSCALING SCALE_FACTOR
### DOF ### DOF
screen.DepthOfField.columns = 1 screen.DepthOfField.columns = 1
screen.DepthOfField = DOF_QUALITY DOF_ANAMORPHIC_RATIO AUTOFOCUS focal aperture MANUAL_FOCUS DoF_Adaptation_Speed FAR_BLUR_ONLY screen.DepthOfField = DOF_QUALITY DOF_ANAMORPHIC_RATIO AUTOFOCUS focal aperture MANUAL_FOCUS DoF_Adaptation_Speed FAR_BLUR_ONLY

View File

@ -88,8 +88,8 @@ void main() {
vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1); abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
float contrast = 1.0 - luma(std)/5.0; float contrast = 1.0 - luma(std)/5.0;
col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast) col = col*(1.0+(SHARPENING)*contrast)
- (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col); - (SHARPENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col);
#endif #endif
float lum = luma(col); float lum = luma(col);

View File

@ -248,9 +248,7 @@ vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
dmin = dmin.z > dtl.z? dtl : dmin; dmin = dmin.z > dtl.z? dtl : dmin;
dmin = dmin.z > dbl.z? dbl : dmin; dmin = dmin.z > dbl.z? dbl : dmin;
dmin = dmin.z > dbr.z? dbr : dmin; dmin = dmin.z > dbr.z? dbr : dmin;
#ifdef TAA_UPSCALING
dmin.xy = dmin.xy/RENDER_SCALE;
#endif
return dmin; return dmin;
} }
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
@ -288,12 +286,7 @@ vec3 TAA_hq(){
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0)
return smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz; return smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
#ifdef TAA_UPSCALING
vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz;
// Interpolating neighboorhood clampling boundaries between pixels
vec3 cMax = texture2D(colortex0, adjTC).rgb;
vec3 cMin = texture2D(colortex6, adjTC).rgb;
#else
vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb; vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb;
vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb; vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb; vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb;
@ -307,7 +300,7 @@ vec3 TAA_hq(){
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8)))))); vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8)))))); vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb; albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb;
#endif
#ifndef NO_CLIP #ifndef NO_CLIP
vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0); vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0);

View File

@ -88,8 +88,8 @@ void main() {
vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1); abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
float contrast = 1.0 - luma(std)/5.0; float contrast = 1.0 - luma(std)/5.0;
col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast) col = col*(1.0+(SHARPENING)*contrast)
- (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col); - (SHARPENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col);
#endif #endif
float lum = luma(col); float lum = luma(col);

View File

@ -54,9 +54,9 @@ void main() {
#endif #endif
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0); normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
#ifdef TAA_UPSCALING // #ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; // gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif // #endif
#ifdef TAA #ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif #endif