diff --git a/shaders/dimensions/deferred.fsh b/shaders/dimensions/deferred.fsh index 4d6f4d2..f38dad4 100644 --- a/shaders/dimensions/deferred.fsh +++ b/shaders/dimensions/deferred.fsh @@ -8,6 +8,7 @@ #define SEASONS_RELATED_SETTINGS #define VOLUMETRIC_CLOUD_RELATED_SETTINGS #define VOLUMETRIC_FOG_RELATED_SETTINGS +#define SCENE_CONTROLLER_RELATED_SETTINGS #include "/lib/settings.glsl" #include "/lib/macro_lod_mod.glsl" @@ -165,6 +166,7 @@ float invLinZ (float lindepth){ #define TIMEOFDAYFOG + #define USE_SCENE_CONTROLLER_SETTINGS #include "/lib/scene_controller.glsl" @@ -227,26 +229,11 @@ gl_FragData[0] = vec4(0.0); vec3 frameHistory = texelFetch(colortex4,ivec2(gl_FragCoord.xy),0).rgb; float mixhistory = 0.06; +if(windowResizeCheck || frameCounter < 2){ + mixhistory = 1.0; +} #ifdef OVERWORLD_SHADER - - ////////////////////////////////////////////// - /// --- STORE DAILY WEATHER PARAMETERS --- /// - ////////////////////////////////////////////// - - // the idea is to store the 8 values, coverage + density of 3 cloud layers and 2 fog density values. - if (gl_FragCoord.x > 1 && gl_FragCoord.x < 4 && gl_FragCoord.y > 1 && gl_FragCoord.y < 4){ - mixhistory = 1.0; // doing custom interpolation on these pixels. turn blending off - - vec3 targetParameterValues = writeSceneControllerParameters(gl_FragCoord.xy, parameters.smallCumulus, parameters.largeCumulus, parameters.altostratus, parameters.fog, parameters.localFog, parameters.localFogColor); - - #if SCENE_CONTROLLER_TRANSITION_RATE > 1000 - gl_FragData[0].rgb = targetParameterValues; - #elif SCENE_CONTROLLER_TRANSITION_RATE <= 1000 - gl_FragData[0].rgb = doPixelTimer(targetParameterValues, frameHistory/150.0); - #endif - } - /////////////////////////////// /// --- STORE COLOR LUT --- /// /////////////////////////////// @@ -421,9 +408,55 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+ } #endif +/// resolve vec3 currentFrame = gl_FragData[0].rgb*150.0; gl_FragData[0].rgb = clamp(mix(frameHistory, currentFrame, clamp(mixhistory,0.0,1.0)),0.0,65000.0); +////////////////////////////////////////////// +/// --- STORE DAILY WEATHER PARAMETERS --- /// +////////////////////////////////////////////// +#if defined OVERWORLD_SHADER +// the idea is to store the 8 values, coverage + density of 3 cloud layers and 2 fog density values. +if (gl_FragCoord.x > 1 && gl_FragCoord.x < 4 && gl_FragCoord.y > 1 && gl_FragCoord.y < 4){ + + struct sceneControlleree { + vec2 smallCumulus_N; + vec2 largeCumulus_N; + vec2 altostratus_N; + vec2 fog_N; + vec2 localFog_N; + vec3 localFogColor_N; + } parameters_new; + + applySceneControllerParameters( + parameters_new.smallCumulus_N.x, parameters_new.smallCumulus_N.y, + parameters_new.largeCumulus_N.x, parameters_new.largeCumulus_N.y, + parameters_new.altostratus_N.x, parameters_new.altostratus_N.y, + parameters_new.fog_N.x, parameters_new.fog_N.y, + parameters_new.localFog_N.x, parameters_new.localFog_N.y, parameters_new.localFogColor_N.rgb + ); + + vec3 targetParameterValues = writeSceneControllerParameters( + gl_FragCoord.xy, + parameters_new.smallCumulus_N, + parameters_new.largeCumulus_N, + parameters_new.altostratus_N, + parameters_new.fog_N, + parameters_new.localFog_N, + parameters_new.localFogColor_N + ); + + #if SCENE_CONTROLLER_TRANSITION_RATE > 1000 + gl_FragData[0].rgb = targetParameterValues; + #elif SCENE_CONTROLLER_TRANSITION_RATE <= 1000 + gl_FragData[0].rgb = doPixelTimer(targetParameterValues, frameHistory); + #endif +} +#endif +////////////////////////////////////////////// +//////////// --- END STUFF --- /////////////// +////////////////////////////////////////////// + #ifdef END_SHADER /* ---------------------- POSITION ---------------------- */ vec2 pixelPos2 = vec2(2,1); diff --git a/shaders/dimensions/deferred.vsh b/shaders/dimensions/deferred.vsh index 47d8620..03417eb 100644 --- a/shaders/dimensions/deferred.vsh +++ b/shaders/dimensions/deferred.vsh @@ -5,7 +5,7 @@ #define SHADOWMAP_CONSTANT_RELATED_SETTINGS #define SEASONS_RELATED_SETTINGS #define VOLUMETRIC_FOG_RELATED_SETTINGS -#define SCENE_CONTROLLER_RELATED_SETTINGS +// #define SCENE_CONTROLLER_RELATED_SETTINGS #define ANTIALIASING_RELATED_SETTINGS #include "/lib/settings.glsl" #include "/lib/res_params.glsl" @@ -79,13 +79,13 @@ float tanh(float x){ float ld(float depth) { return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near } -float hash11(float p) -{ - p = fract(p * .1031); - p *= p + 33.33; - p *= p + p; - return fract(p); -} +// float hash11(float p) +// { +// p = fract(p * .1031); +// p *= p + 33.33; +// p *= p + p; +// return fract(p); +// } #define USE_SCENE_CONTROLLER_SETTINGS #include "/lib/scene_controller.glsl" @@ -182,13 +182,15 @@ void main() { /////////////////////////////////////////// // components are split for readability/user friendliness within this function - applySceneControllerParameters( - parameters.smallCumulus.x, parameters.smallCumulus.y, - parameters.largeCumulus.x, parameters.largeCumulus.y, - parameters.altostratus.x, parameters.altostratus.y, - parameters.fog.x, parameters.fog.y, - parameters.localFog.x, parameters.localFog.y, parameters.localFogColor.rgb - ); + // applySceneControllerParameters( + // parameters.smallCumulus.x, parameters.smallCumulus.y, + // parameters.largeCumulus.x, parameters.largeCumulus.y, + // parameters.altostratus.x, parameters.altostratus.y, + // parameters.fog.x, parameters.fog.y, + // parameters.localFog.x, parameters.localFog.y, parameters.localFogColor.rgb + // ); + #define READ_SCENE_CONTROLLER_PARAMETERS + #include "/lib/scene_controller.glsl" ////////////////////////////// /// --- EXPOSURE STUFF --- /// diff --git a/shaders/lib/overworld_fog.glsl b/shaders/lib/overworld_fog.glsl index b13eaa6..1347116 100644 --- a/shaders/lib/overworld_fog.glsl +++ b/shaders/lib/overworld_fog.glsl @@ -86,7 +86,7 @@ vec3 getShadows( return shadows; } -uniform bool isInSpecialEnviornment; +// uniform bool isInSpecialEnviornment; uniform vec3 exitedBiomePos; // uniform float fadeAwayLocalEffect; diff --git a/shaders/lib/scene_controller.glsl b/shaders/lib/scene_controller.glsl index 8bc8721..42a1860 100644 --- a/shaders/lib/scene_controller.glsl +++ b/shaders/lib/scene_controller.glsl @@ -2,6 +2,7 @@ #if defined USE_SCENE_CONTROLLER_SETTINGS uniform int worldDay; +uniform int worldTime; uniform ivec3 cameraPositionInt; uniform bool isInColdArea; @@ -14,25 +15,27 @@ uniform bool isInSnowFallEnviornment; uniform bool isInRainFallEnviornment; uniform bool isInNoRainFallEnviornment; -uniform int worldTime; #define DECLARE_UNIFORMS_OR_WRITE_FUNCTIONS_FOR_CUSTOM_SCENE_CONTROLLER_PROFILES #include "/CUSTOM_SCENE_PARAMETERS.glsl" // https://www.shadertoy.com/view/llGSzw -float hash11( uint n ) +float hash11(float p) { - // integer hash copied from Hugo Elias - n = (n << 13U) ^ n; - n = n * (n * n * 15731U + 789221U) + 1376312589U; - return float( n & uint(0x7fffffffU))/float(0x7fffffff); + p = fract(p * .1031); + p *= p + 33.33; + p *= p + p; + return fract(p); } + bool playerIsWithinArea(in vec3 positionA, in vec3 positionB){ return cameraPositionInt.x > positionA.x && cameraPositionInt.y > positionA.y && cameraPositionInt.z > positionA.z && cameraPositionInt.x < positionB.x && cameraPositionInt.y < positionB.y && cameraPositionInt.z < positionB.z; } + bool playerIsOutsideArea(in vec3 positionA, in vec3 positionB){ return !(cameraPositionInt.x > positionA.x && cameraPositionInt.y > positionA.y && cameraPositionInt.z > positionA.z && cameraPositionInt.x < positionB.x && cameraPositionInt.y < positionB.y && cameraPositionInt.z < positionB.z); } + vec4 timesOfDay(){ float time = float(worldTime%24000); @@ -45,6 +48,7 @@ vec4 timesOfDay(){ return (float(TOD_FOG_AMOUNT) / 100.0) * vec4(morning, noon, evening, night); } + void applySceneControllerParameters( out float smallCumulusCoverage, out float smallCumulusDensity, out float largeCumulusCoverage, out float largeCumulusDensity, @@ -64,7 +68,7 @@ void applySceneControllerParameters( clumpyFogDensity = 0.0; LocalUniformFogDensity = 0.0; LocalClumpyFogDensity = 0.0; - localFogColor = vec3(1.0); + localFogColor = vec3(0.0); #if TOD_FOG_AMOUNT > 0 vec4 timesOfDay = timesOfDay(); @@ -74,7 +78,8 @@ void applySceneControllerParameters( // the seed is the in-game day counter. // give a random value within the range 0.0-1.0 which is scaled up to the wanted range, and then quantized to choose a profile -float RNG = hash11(worldDay + 0.2); +float midDayReroll = floor(worldTime/24000.0 * 4.0); +float RNG = hash11(float(worldDay + midDayReroll + 0.2)); #if USE_CUSTOM_DAILY_WEATHER_PROFILE == 0 int dailyWeatherProfile = int(RNG * 11.0); @@ -688,14 +693,13 @@ void readSceneControllerParameters( out vec2 localFog, out vec3 localFogColor ){ - // in colortex4, read the data stored within the 3 components of the sampled pixels, and pass it to the fragment stage // 4th compnent/alpha is storing 1/4 res depth so i cant store there lol - vec3 data1 = texelFetch(colortex,ivec2(1,3),0).rgb/150.0; - vec3 data2 = texelFetch(colortex,ivec2(2,3),0).rgb/150.0; - vec3 data3 = texelFetch(colortex,ivec2(3,3),0).rgb/150.0; - float data4 = texelFetch(colortex,ivec2(1,2),0).r/150.0; - vec3 data5 = texelFetch(colortex,ivec2(2,2),0).rgb/150.0; // this samples a color + vec3 data1 = texelFetch(colortex,ivec2(1,3),0).rgb;///150.0; + vec3 data2 = texelFetch(colortex,ivec2(2,3),0).rgb;///150.0; + vec3 data3 = texelFetch(colortex,ivec2(3,3),0).rgb;///150.0; + float data4 = texelFetch(colortex,ivec2(1,2),0).r ;///150.0; + vec3 data5 = texelFetch(colortex,ivec2(2,2),0).rgb;///150.0; // this samples a color smallCumulus = vec2(data1.x,data1.y); largeCumulus = vec2(data1.z,data2.x); diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index f73550a..7421302 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -4,15 +4,15 @@ float curvatureoffset = 0.04; uniform vec2 windDirection; // uniform float animation; -#if CLOUD_ANIMATION_MODE == 0 - uniform int worldDay; - uniform int worldTime; - // uniform float worldTimeAnimation; - float cloud_movement = (worldTime + mod(worldDay,100)*24000.0) / 24.0 * Cloud_Speed; -#elif CLOUD_ANIMATION_MODE == 1 -// uniform float frameTimeCounter; - float cloud_movement = frameTimeCounter * Cloud_Speed; -#endif +// #if CLOUD_ANIMATION_MODE == 0 +// uniform int worldDay; +// uniform int worldTime; +// // uniform float worldTimeAnimation; +// float cloud_movement = (worldTime + mod(worldDay,100)*24000.0) / 24.0 * Cloud_Speed; +// #elif CLOUD_ANIMATION_MODE == 1 +// // uniform float frameTimeCounter; +// float cloud_movement = frameTimeCounter * Cloud_Speed; +// #endif float densityAtPos(in vec3 pos){ pos /= 18.;