- Seeded weather (clear/cloudy/rain/storm, snow and blizzards on cold days and above the snowline), lightning, synthesised rain/wind/thunder sound - Rain/snow particles stopped by roofs; wet ground, settled snow and wind via global shader uniforms - Snap-together wood floor, wall, door, roof and gable with structural support, collapse and X to dismantle - Shelter detection: dry under a roof, warmer and Rested inside with a fire; rain burns an uncovered campfire faster - Bed sets the spawn point and lets you sleep through the night - Trees, boulders and ground pickups regrow; timers saved - Grass cleared under floors; shorter HUD hint - New test_weather_building suite (62 checks) and tests/run_all.sh, which also fails on script errors
40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
// Shared helpers for the world shaders.
|
|
// Declares `noise_tex` (a seamless NoiseTexture2D set from terrain.gd) so every
|
|
// shader samples the same noise, which keeps grass, terrain and rock colour
|
|
// variation lined up with each other.
|
|
|
|
uniform sampler2D noise_tex : filter_linear_mipmap, repeat_enable;
|
|
|
|
// Set every frame by weather_fx.gd (declared in project.godot [shader_globals]).
|
|
global uniform float weather_wet; // 0..1 rain-soaked ground
|
|
global uniform float weather_snow; // 0..1 settled snow
|
|
global uniform float weather_wind; // wind multiplier, ~1 on a calm day
|
|
|
|
// Wet surfaces: darker and glossier.
|
|
vec3 wet_albedo(vec3 c, float wet) {
|
|
return c * (1.0 - 0.35 * wet);
|
|
}
|
|
|
|
// Settled snow on upward-facing surfaces, patchy where it's thin.
|
|
float snow_mask(float up, float patch) {
|
|
float s = weather_snow * 1.25 - (1.0 - patch) * 0.45;
|
|
return clamp(s, 0.0, 1.0) * smoothstep(0.55, 0.85, up);
|
|
}
|
|
|
|
float nz(vec2 p) {
|
|
return texture(noise_tex, p).r;
|
|
}
|
|
|
|
// Triplanar noise: samples along all three axes so steep faces (cliffs, rock
|
|
// sides) don't show the stretched streaks a top-down projection would give.
|
|
float tri_nz(vec3 p, vec3 n, float s) {
|
|
vec3 w = pow(abs(n), vec3(4.0));
|
|
w /= (w.x + w.y + w.z);
|
|
return nz(p.zy * s) * w.x + nz(p.xz * s) * w.y + nz(p.xy * s) * w.z;
|
|
}
|
|
|
|
// Vertex colours are authored as sRGB; lighting needs linear.
|
|
vec3 to_linear(vec3 c) {
|
|
return pow(c, vec3(2.2));
|
|
}
|