- 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
46 lines
1.5 KiB
Plaintext
46 lines
1.5 KiB
Plaintext
shader_type spatial;
|
|
render_mode cull_back, diffuse_burley;
|
|
|
|
// Faceted low-poly rocks: triplanar grain, per-rock tint, moss on upward faces
|
|
// (on some rocks more than others), snow on top at altitude.
|
|
|
|
#include "res://shaders/common.gdshaderinc"
|
|
|
|
uniform vec3 moss_col : source_color = vec3(0.27, 0.38, 0.15);
|
|
uniform vec3 snow_col : source_color = vec3(0.93, 0.95, 0.98);
|
|
uniform float snow_height = 40.0;
|
|
|
|
varying vec3 w_pos;
|
|
varying vec3 w_nrm;
|
|
varying vec3 inst_pos;
|
|
|
|
void vertex() {
|
|
w_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
|
w_nrm = normalize((MODEL_MATRIX * vec4(NORMAL, 0.0)).xyz);
|
|
inst_pos = MODEL_MATRIX[3].xyz;
|
|
}
|
|
|
|
void fragment() {
|
|
float a = tri_nz(w_pos, w_nrm, 0.3);
|
|
float b = tri_nz(w_pos, w_nrm, 1.4);
|
|
vec3 base = to_linear(COLOR.rgb) * (0.7 + 0.6 * a) * (0.88 + 0.24 * b);
|
|
base *= mix(vec3(1.04, 1.0, 0.94), vec3(0.94, 0.97, 1.03), nz(inst_pos.xz * 0.07));
|
|
|
|
float mossy = smoothstep(0.3, 0.7, nz(inst_pos.xz * 0.021 + 0.5));
|
|
float moss = smoothstep(0.45, 0.8, w_nrm.y + (a - 0.5) * 0.7) * mossy;
|
|
vec3 col = mix(base, moss_col * (0.75 + 0.5 * b), moss);
|
|
|
|
float snow = smoothstep(snow_height - 3.0, snow_height + 3.0, w_pos.y + (a - 0.5) * 10.0);
|
|
snow *= smoothstep(0.35, 0.7, w_nrm.y);
|
|
col = mix(col, snow_col, snow);
|
|
float wsnow = snow_mask(w_nrm.y, a);
|
|
col = mix(col, snow_col, wsnow);
|
|
snow = max(snow, wsnow);
|
|
float wet = weather_wet * (1.0 - snow);
|
|
col = wet_albedo(col, wet);
|
|
|
|
ALBEDO = col;
|
|
ROUGHNESS = mix(mix(mix(0.8, 0.95, moss), 0.6, snow), 0.3, wet * 0.8);
|
|
SPECULAR = 0.35;
|
|
}
|