add wind system (affects clouds, fog, foliage)

This commit is contained in:
Xonk
2026-06-30 18:07:54 -04:00
parent b6c5c8ed51
commit e5f76e1bde
8 changed files with 95 additions and 36 deletions
+13 -13
View File
@@ -59,7 +59,7 @@ uniform float screenBrightness;
uniform int isEyeInWater;
uniform float frameTimeCounter;
uniform sampler2D noisetex;//depth
// uniform sampler2D noisetex;//depth
#include "/lib/vertex_displacement.glsl"
@@ -86,19 +86,19 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
}
float densityAtPos(in vec3 pos){
pos /= 18.;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
vec2 coord = uv / 512.0;
// float densityAtPos(in vec3 pos){
// pos /= 18.;
// pos.xz *= 0.5;
// vec3 p = floor(pos);
// vec3 f = fract(pos);
// vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
// vec2 coord = uv / 512.0;
//The y channel has an offset to avoid using two textures fetches
vec2 xy = texture2D(noisetex, coord).yx;
// //The y channel has an offset to avoid using two textures fetches
// vec2 xy = texture2D(noisetex, coord).yx;
return mix(xy.r,xy.g, f.y);
}
// return mix(xy.r,xy.g, f.y);
// }
float luma(vec3 color) {
return dot(color,vec3(0.21, 0.72, 0.07));
@@ -286,7 +286,7 @@ void main() {
// these wave off of the air. they wave uniformly
|| (mc_Entity.x == BLOCK_GRASS_TALL_UPPER || mc_Entity.x == BLOCK_AIR_WAVING)
) && abs(position.z) < 64.0
) && abs(position.z) < 64.0 && (lmcoord.y > 0.8)
){
vec3 UnalteredWorldpos = worldpos;
+1 -1
View File
@@ -27,7 +27,7 @@ varying vec4 lmtexcoord;
varying vec4 color;
uniform sampler2D colortex4;
uniform sampler2D noisetex;
// uniform sampler2D noisetex;
#ifdef OVERWORLD_SHADER
flat varying vec3 averageSkyCol_Clouds;
+4
View File
@@ -717,6 +717,10 @@ screen.VOLUMETRICS = Volumetrics
###################################################### ↓↓↓ THIS SUBMENU'S LABELS
screen.ATMOSPHERICS = Atmospherics
option.WIND_SYSTEM_MODE = Wind System
value.WIND_SYSTEM_MODE.-1 = §cOFF§r
value.WIND_SYSTEM_MODE.0 = §bⓘ ON + Exclude Foliage
value.WIND_SYSTEM_MODE.1 = §bⓘ ON
screen.DAILY_WEATHER = Daily Weather Presets
option.USE_CUSTOM_DAILY_WEATHER_PROFILE = Daily Weather Mode
+10 -5
View File
@@ -100,7 +100,10 @@ float getLocalEffectDensity(
if(parameters.localFog.y > 0.0){
vec3 pos = playerPos;
vec3 samplePos = playerPos * vec3(1.0,1.0/48.0,1.0) * 24.0 * 7.0;
samplePos += vec3(1.0, -0.01, 1.0)*frameTimeCounter*1500.0;
// samplePos += vec3(1.0, -0.01, 1.0)*frameTimeCounter*1500.0;
samplePos.y += -0.01*frameTimeCounter*1500.0;
samplePos.xz += windDirection*1000.0;
float clumpyFog = min(max(densityAtPosFog(samplePos) - 0.2,0.0)/0.8,1.0);
@@ -120,11 +123,13 @@ float getFogDensities(
fogResult = pow(parameters.fog.x,3);
if(parameters.fog.y > 0.0){
vec3 movement = vec3(1.0, -0.01, 1.0)*frameTimeCounter;
vec3 pos = playerPos;
vec3 samplePos = playerPos * vec3(1.0,1.0/24.0,1.0) + movement;
vec3 samplePos2 = playerPos * vec3(1.0,1.0/48.0,1.0) + movement;
vec3 samplePos = playerPos * vec3(1.0,1.0/24.0,1.0);
vec3 samplePos2 = playerPos * vec3(1.0,1.0/48.0,1.0);
samplePos.xz += windDirection;
samplePos2.xz += windDirection;
float shape = 1.0 - densityAtPosFog(samplePos * 24.0);
float shape2 = 1.0 - densityAtPosFog(samplePos2 * 200.0 - vec3(min(max(shape - 0.6 ,0.0) * 2.0 ,1.0)*200.0));
float finalShape = max(min(max(shape - 0.6 ,0.0) * 2.0 ,1.0) - shape2 * 0.4, 0.0) * exp(-0.05 * max(pos.y - 60,0.0));
+2
View File
@@ -814,6 +814,8 @@
// #define VANILLA_LIGHTMAP_MASK
#define TORCH_LIGHTMAP_EMISSION_WORKAROUND
#define WIND_SYSTEM_MODE 0 // [-1 0 1]
////////////////////////////////
// ----- DEBUG SETTINGS ----- //
+30 -3
View File
@@ -1,18 +1,35 @@
const float PI48 = 150.796447372*WAVY_SPEED;
float pi2wt = PI48*frameTimeCounter;
uniform vec2 windDirection_foliage;
uniform vec2 windDirection;
uniform float rainStrength;
uniform sampler2D noisetex;
vec2 calcWave(in vec3 pos) {
float magnitude = abs(sin(dot(vec4(frameTimeCounter, pos),vec4(1.0,0.005,0.005,0.005)))*0.5+0.72)*0.013;
vec2 ret = (sin(pi2wt*vec2(0.0063,0.0015)*4. - pos.xz + pos.y*0.05)+0.1)*magnitude;
vec2 ret = (sin(pi2wt*vec2(0.0063,0.0015)*4. - pos.xz + pos.y*0.05)+0.1)*magnitude ;
return ret;
}
vec3 calcMovePlants(in vec3 pos) {
vec2 move1 = calcWave(pos );
float move1y = -length(move1);
return vec3(move1.x,move1y,move1.y)*5.*WAVY_STRENGTH;
vec3 result = vec3(move1.x,move1y,move1.y)*5.*WAVY_STRENGTH * (1.0+rainStrength);
#if WIND_SYSTEM_MODE > 0
// result.xz += windDirection_foliage/200.0*-move1y * (1.0+rainStrength);
vec2 windMaps = vec2(texture(noisetex, (pos.xz + windDirection*5.0)/128.0).r,0.0);
if(rainStrength > 0.001) windMaps.y = texture(noisetex, (pos.xz + windDirection*5.0)/128.0).b;
float windForce = mix(0.0,1.0,pow(1.0-pow(1.0-mix(windMaps.x,1-windMaps.y,rainStrength),2.0),2.0));
result.xz += windDirection_foliage*windForce/4000.0;
#endif
return result;
}
vec3 calcWaveLeaves(in vec3 pos, in float fm, in float mm, in float ma, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5) {
@@ -25,7 +42,17 @@ vec3 calcWaveLeaves(in vec3 pos, in float fm, in float mm, in float ma, in float
vec3 calcMoveLeaves(in vec3 pos, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5, in vec3 amp1, in vec3 amp2) {
vec3 move1 = calcWaveLeaves(pos , 0.0054, 0.0400, 0.0400, 0.0127, 0.0089, 0.0114, 0.0063, 0.0224, 0.0015) * amp1;
return move1*5.*WAVY_STRENGTH;
vec3 result = move1*5.*WAVY_STRENGTH * (1.0+rainStrength);
#if WIND_SYSTEM_MODE > 0
// result.xz += windDirection_foliage * length(move1.z) * (sin((windDirection_foliage.x+pos.x)*(windDirection_foliage.y+pos.z)*0.00008+frameTimeCounter)*0.5+0.5)/100.0 * (1.0+2*rainStrength);
vec2 windMaps = vec2(texture(noisetex, (pos.xz + windDirection*5.0)/128.0).r,0.0);
if(rainStrength > 0.001) windMaps.y = texture(noisetex, (pos.xz + windDirection*5.0)/128.0).b;
float windForce = mix(0.0,1.0,pow(1.0-pow(1.0-mix(windMaps.x,windMaps.y,rainStrength),2.0),2.0));
result.xz += windDirection_foliage*windForce/4000.0 * 0.5;
#endif
return result;
}
void applyWorldCurvature(inout vec3 worldPos){
+22 -11
View File
@@ -2,10 +2,12 @@
#define LARGECUMULUS_LAYER 1
#define SMALLCUMULUS_LAYER 0
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;
@@ -55,8 +57,10 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
case SMALLCUMULUS_LAYER: {
coverage = parameters.smallCumulus.x;
largeCloud = texture(noisetex, (samplePos.xz + cloud_movement)/5000.0 * CloudLayer0_scale).b;
smallCloud = 1.0-texture(noisetex, (samplePos.xz - cloud_movement)/500.0 * CloudLayer0_scale).r;
vec2 animatedPos = samplePos.xz + windDirection/4.0 * Cloud_Speed;
largeCloud = texture(noisetex, animatedPos/5000.0 * CloudLayer0_scale).b;
smallCloud = 1.0-texture(noisetex,animatedPos/500.0 * CloudLayer0_scale).r;
smallCloud = abs(largeCloud-0.6) + smallCloud*smallCloud;
shape = min(max(coverage - smallCloud,0.0)/(1e-6+sqrt(coverage)),1.0) ;
@@ -64,9 +68,10 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
case LARGECUMULUS_LAYER: {
coverage = parameters.largeCumulus.x;
largeCloud = texture(noisetex, (samplePos.zx + cloud_movement*3.0)/10000.0 * CloudLayer1_scale).b;
smallCloud = texture(noisetex, (samplePos.zx - cloud_movement*3.0)/2500.0 * CloudLayer1_scale).b;
vec2 animatedPos = samplePos.zx + windDirection* Cloud_Speed;
largeCloud = texture(noisetex, animatedPos/10000.0 * CloudLayer1_scale).b;
smallCloud = texture(noisetex, animatedPos/2500.0 * CloudLayer1_scale).b;
smallCloud = abs(largeCloud* -0.7) + smallCloud;
shape = min(max(coverage - smallCloud,0.0)/(1e-6+sqrt(coverage)),1.0) ;
@@ -75,8 +80,9 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
case ALTOSTRATUS_LAYER: {
coverage = parameters.altostratus.x;
largeCloud = texture(noisetex, (position.xz + cloud_movement*20.0)/100000. * CloudLayer2_scale).b;
smallCloud = 1.0 - texture(noisetex, ((position.xz + vec2(-cloud_movement,cloud_movement)*20.0)/7500. - vec2(1.0-largeCloud, -largeCloud)/5.0) * CloudLayer2_scale).b;
vec2 animatedPos = samplePos.xz + windDirection * 10.0 * Cloud_Speed;
largeCloud = texture(noisetex, animatedPos/100000. * CloudLayer2_scale).b;
smallCloud = 1.0 - texture(noisetex, (animatedPos/7500. - vec2(1.0-largeCloud, -largeCloud)/5.0) * CloudLayer2_scale).b;
smallCloud = largeCloud + smallCloud * 0.4 * clamp(1.5-largeCloud,0.0,1.0);
shape = min(max(coverage - smallCloud,0.0) / (1e-6+sqrt(coverage)),1.0);
@@ -104,15 +110,16 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
// shrink the coverage slightly so it is a similar shape to clouds with erosion. this helps cloud lighting and cloud shadows.
if (LOD < 1) return max(shape - 0.27*erodeAmount,0.0);
samplePos.xz += cloud_movement/4.0;
samplePos.xz += pow( max(position.y - (minHeight+20.0), 0.0) / (max(maxHeight-minHeight,1.0)*0.20), 1.5);
float erosion = 0.0;
switch (LayerIndex){
default : { break; }
case SMALLCUMULUS_LAYER: {
samplePos.xz += windDirection/2.0* Cloud_Speed;
samplePos.xz += (-vec2(-windDirection.y, windDirection.x)/1500.0)*pow( max(position.y - (minHeight+20.0), 0.0) / (max(maxHeight-minHeight,1.0)*0.20), 1.5);
erosion += (1.0-densityAtPos(samplePos * 200.0 * CloudLayer0_scale)) * sqrt(1.0-shape);
float falloff = 1.0 - clamp((maxHeight - position.y)/100.0,0.0,1.0);
@@ -122,6 +129,10 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
break; }
case LARGECUMULUS_LAYER: {
samplePos.zx += windDirection*1.74* Cloud_Speed;
samplePos.zx += (-vec2(-windDirection.y, windDirection.x)/1500.0)*pow( abs(position.y - (minHeight+20.0)) / (max(maxHeight-minHeight,1.0)*0.20), 1.75);
erosion += (1.0 - densityAtPos(samplePos * 70.0 * CloudLayer1_scale)) * sqrt(1.0-shape);
float falloff = 1.0 - clamp((maxHeight - position.y)/200.0,0.0,1.0);
File diff suppressed because one or more lines are too long