2023-01-12 15:00:14 -05:00
|
|
|
// this file contains all things for seasons, weather, and biome specific settings.
|
|
|
|
// i gotta start centralizing shit someday.
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////// SEASONS /////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// VERTEX SHADER
|
|
|
|
#ifdef Seasons
|
|
|
|
#ifdef SEASONS_VSH
|
2023-04-16 16:18:26 -04:00
|
|
|
|
2023-06-11 19:26:12 -04:00
|
|
|
uniform int worldDay;
|
2023-06-28 18:59:21 -04:00
|
|
|
uniform float noPuddleAreas;
|
2023-04-16 16:18:26 -04:00
|
|
|
|
2023-01-12 15:00:14 -05:00
|
|
|
void YearCycleColor (
|
|
|
|
inout vec3 FinalColor,
|
2023-06-15 17:25:01 -04:00
|
|
|
vec3 glcolor,
|
|
|
|
inout float SnowySeason
|
2023-01-12 15:00:14 -05:00
|
|
|
){
|
|
|
|
// colors for things that arent leaves and using the tint index.
|
2023-04-16 16:18:26 -04:00
|
|
|
vec3 SummerCol = vec3(Summer_R, Summer_G, Summer_B);
|
|
|
|
vec3 AutumnCol = vec3(Fall_R, Fall_G, Fall_B);
|
2023-01-12 15:00:14 -05:00
|
|
|
vec3 WinterCol = vec3(Winter_R, Winter_G, Winter_B) ;
|
2023-04-16 16:18:26 -04:00
|
|
|
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B);
|
|
|
|
|
|
|
|
// decide if you want to replace biome colors or tint them.
|
|
|
|
SummerCol *= glcolor;
|
|
|
|
AutumnCol *= glcolor;
|
|
|
|
WinterCol *= glcolor;
|
|
|
|
SpringCol *= glcolor;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
// do leaf colors different because thats cool and i like it
|
|
|
|
if(mc_Entity.x == 10003){
|
2023-04-16 16:18:26 -04:00
|
|
|
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B);
|
|
|
|
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B);
|
|
|
|
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B);
|
|
|
|
SpringCol = vec3(Spring_Leaf_R, Spring_Leaf_G, Spring_Leaf_B);
|
|
|
|
|
|
|
|
SummerCol *= glcolor;
|
|
|
|
AutumnCol *= glcolor;
|
|
|
|
WinterCol *= glcolor;
|
|
|
|
SpringCol *= glcolor;
|
2023-01-12 15:00:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// length of each season in minecraft days
|
|
|
|
int SeasonLength = Season_Length;
|
|
|
|
|
|
|
|
// loop the year. multiply the season length by the 4 seasons to create a years time.
|
2023-07-08 16:29:46 +01:00
|
|
|
float YearLoop = mod(worldDay + Start_Season * SeasonLength, SeasonLength * 4);
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
// the time schedule for each season
|
|
|
|
float SummerTime = clamp(YearLoop ,0, SeasonLength) / SeasonLength;
|
|
|
|
float AutumnTime = clamp(YearLoop - SeasonLength ,0, SeasonLength) / SeasonLength;
|
|
|
|
float WinterTime = clamp(YearLoop - SeasonLength*2 ,0, SeasonLength) / SeasonLength;
|
|
|
|
float SpringTime = clamp(YearLoop - SeasonLength*3 ,0, SeasonLength) / SeasonLength;
|
|
|
|
|
|
|
|
// lerp all season colors together
|
|
|
|
vec3 SummerToFall = mix(SummerCol, AutumnCol, SummerTime);
|
|
|
|
vec3 FallToWinter = mix(SummerToFall, WinterCol, AutumnTime);
|
|
|
|
vec3 WinterToSpring = mix(FallToWinter, SpringCol, WinterTime);
|
|
|
|
vec3 SpringToSummer = mix(WinterToSpring, SummerCol, SpringTime);
|
|
|
|
|
|
|
|
// make it so that you only have access to parts of the texture that use the tint index
|
|
|
|
bool IsTintIndex = floor(dot(glcolor,vec3(0.5))) < 1.0;
|
|
|
|
|
|
|
|
// multiply final color by the final lerped color, because it contains all the other colors.
|
2023-06-11 19:26:12 -04:00
|
|
|
if(IsTintIndex) FinalColor = SpringToSummer;
|
2023-06-15 17:25:01 -04:00
|
|
|
|
|
|
|
#ifdef Snowy_Winter
|
|
|
|
// this is to make snow only exist in winter
|
|
|
|
float FallToWinter_snowfall = mix(0.0, 1.0, AutumnTime);
|
|
|
|
float WinterToSpring_snowfall = mix(FallToWinter_snowfall, 0.0, WinterTime);
|
2023-06-28 18:59:21 -04:00
|
|
|
SnowySeason = clamp(pow(sin(WinterToSpring_snowfall*SeasonLength)*0.5+0.5,5),0,1) * WinterToSpring_snowfall * noPuddleAreas;
|
2023-06-15 17:25:01 -04:00
|
|
|
#else
|
|
|
|
SnowySeason = 0.0;
|
|
|
|
#endif
|
2023-01-12 15:00:14 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////// DAILY WEATHER //////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-01-12 15:28:19 -05:00
|
|
|
|
|
|
|
|
2023-01-12 15:00:14 -05:00
|
|
|
#ifdef WEATHERCLOUDS
|
2023-05-09 19:08:34 -04:00
|
|
|
|
2023-06-11 17:28:54 -04:00
|
|
|
uniform float Cumulus_Cov;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
2023-05-09 19:08:34 -04:00
|
|
|
float DailyWeather_Cumulus(
|
2023-01-12 15:00:14 -05:00
|
|
|
float Coverage
|
|
|
|
){
|
|
|
|
|
2023-01-12 15:28:19 -05:00
|
|
|
#ifdef Daily_Weather
|
2023-06-01 17:41:06 -04:00
|
|
|
Coverage += mix(Cumulus_Cov, Rain_coverage, rainStrength);
|
2023-01-12 15:00:14 -05:00
|
|
|
#else
|
2023-04-16 16:18:26 -04:00
|
|
|
Coverage += mix(Cumulus_coverage, Rain_coverage, rainStrength);
|
2023-01-12 15:00:14 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return Coverage;
|
|
|
|
}
|
|
|
|
|
2023-06-11 17:28:54 -04:00
|
|
|
uniform float Alto_Cov;
|
|
|
|
uniform float Alto_Den;
|
|
|
|
|
2023-05-09 19:08:34 -04:00
|
|
|
void DailyWeather_Alto(
|
2023-01-12 15:00:14 -05:00
|
|
|
inout float Coverage,
|
2023-05-09 19:08:34 -04:00
|
|
|
inout float Density
|
2023-01-12 15:00:14 -05:00
|
|
|
){
|
|
|
|
#ifdef Daily_Weather
|
2023-05-09 19:08:34 -04:00
|
|
|
Coverage = Alto_Cov;
|
|
|
|
Density = Alto_Den;
|
2023-01-12 15:00:14 -05:00
|
|
|
#else
|
2023-05-09 19:08:34 -04:00
|
|
|
Coverage = Alto_coverage;
|
|
|
|
Density = Alto_density;
|
2023-01-12 15:00:14 -05:00
|
|
|
#endif
|
|
|
|
}
|
2023-05-09 19:08:34 -04:00
|
|
|
|
2023-01-12 15:00:14 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Daily_Weather
|
2023-06-11 19:16:05 -04:00
|
|
|
uniform float Uniform_Den;
|
|
|
|
uniform float Cloudy_Den;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
void DailyWeather_FogDensity(
|
|
|
|
inout vec4 UniformDensity,
|
|
|
|
inout vec4 CloudyDensity
|
|
|
|
){
|
|
|
|
|
|
|
|
// set fog Profiles for each of the 8 days in the cycle.
|
|
|
|
// U = uniform fog || C = cloudy fog
|
2023-06-11 19:16:05 -04:00
|
|
|
// vec4( morning, noon, evening, night )
|
2023-01-12 15:00:14 -05:00
|
|
|
|
2023-06-11 19:16:05 -04:00
|
|
|
UniformDensity.rgb += vec3(Uniform_Den);
|
|
|
|
CloudyDensity.rgb += vec3(Cloudy_Den);
|
2023-01-12 15:00:14 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////// BIOME SPECIFICS /////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef Biome_specific_environment
|
|
|
|
uniform float isJungles;
|
|
|
|
uniform float isSwamps;
|
2023-06-28 18:59:21 -04:00
|
|
|
// uniform float isLush;
|
|
|
|
// uniform float isDeserts;
|
|
|
|
|
|
|
|
uniform float sandStorm;
|
|
|
|
uniform float snowStorm;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
void BiomeFogColor(
|
|
|
|
inout vec3 FinalFogColor
|
|
|
|
){
|
|
|
|
// this is a little complicated? lmao
|
|
|
|
vec3 BiomeColors;
|
2023-06-28 18:59:21 -04:00
|
|
|
BiomeColors.r = isSwamps*0.7 + isJungles*0.5 + sandStorm*1.0 + snowStorm*0.5;
|
|
|
|
BiomeColors.g = isSwamps*1.0 + isJungles*1.0 + sandStorm*0.5 + snowStorm*0.6;
|
|
|
|
BiomeColors.b = isSwamps*0.35 + isJungles*0.8 + sandStorm*0.3 + snowStorm*1.0;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
// insure the biome colors are locked to the fog shape and lighting, but not its orignal color.
|
2023-06-28 20:05:44 -04:00
|
|
|
BiomeColors *= dot(FinalFogColor,vec3(0.33333));
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
// these range 0.0-1.0. they will never overlap.
|
2023-06-28 18:59:21 -04:00
|
|
|
float Inbiome = isJungles+isSwamps+sandStorm;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
// interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms.
|
|
|
|
FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BiomeFogDensity(
|
|
|
|
inout vec4 UniformDensity,
|
|
|
|
inout vec4 CloudyDensity
|
|
|
|
){
|
|
|
|
// these range 0.0-1.0. they will never overlap.
|
2023-06-28 18:59:21 -04:00
|
|
|
float Inbiome = isJungles+isSwamps+sandStorm+snowStorm;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
vec2 BiomeFogDensity; // x = uniform || y = cloudy
|
2023-06-28 18:59:21 -04:00
|
|
|
BiomeFogDensity.x = isSwamps*1 + isJungles*5 + sandStorm*15 + snowStorm*15;
|
|
|
|
BiomeFogDensity.y = isSwamps*5 + isJungles*2 + sandStorm*255 + snowStorm*100;
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome);
|
|
|
|
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////// FOG CONTROLLER /////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef TIMEOFDAYFOG
|
2023-06-18 19:10:13 -04:00
|
|
|
// uniform int worldTime;
|
2023-01-12 15:00:14 -05:00
|
|
|
void TimeOfDayFog(inout float Uniform, inout float Cloudy) {
|
|
|
|
|
|
|
|
float Time = (worldTime%24000)*1.0;
|
|
|
|
|
|
|
|
// set schedules for fog to appear at specific ranges of time in the day.
|
|
|
|
float Morning = clamp((Time-22000)/2000,0,1) + clamp((2000-Time)/2000,0,1);
|
|
|
|
float Noon = clamp(Time/2000,0,1) * clamp((12000-Time)/2000,0,1);
|
|
|
|
float Evening = clamp((Time-10000)/2000,0,1) * clamp((14000-Time)/2000,0,1) ;
|
|
|
|
float Night = clamp((Time-13000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
|
|
|
|
|
|
|
|
// set densities. morn, noon, even, night
|
2023-04-16 16:18:26 -04:00
|
|
|
vec4 UniformDensity = TOD_Fog_mult * vec4(Morning_Uniform_Fog, Noon_Uniform_Fog, Evening_Uniform_Fog, Night_Uniform_Fog);
|
|
|
|
vec4 CloudyDensity = TOD_Fog_mult * vec4(Morning_Cloudy_Fog, Noon_Cloudy_Fog, Evening_Cloudy_Fog, Night_Cloudy_Fog);
|
|
|
|
|
2023-01-12 15:00:14 -05:00
|
|
|
|
|
|
|
#ifdef Daily_Weather
|
|
|
|
DailyWeather_FogDensity(UniformDensity, CloudyDensity); // let daily weather influence fog densities.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Biome_specific_environment
|
|
|
|
BiomeFogDensity(UniformDensity, CloudyDensity); // let biome fog hijack to control densities, and overrride any other density controller...
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a;
|
|
|
|
Cloudy *= Morning*CloudyDensity.r + Noon*CloudyDensity.g + Evening*CloudyDensity.b + Night*CloudyDensity.a;
|
|
|
|
}
|
|
|
|
#endif
|