fix snow for train and wagons
This commit is contained in:
@@ -39,6 +39,7 @@ var weather_controller: WeatherController
|
||||
var day_tween: Tween
|
||||
var day_time: float = 0.0
|
||||
var pending_environment_nodes: Dictionary = {}
|
||||
var weather_shader_no_noise: Material
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
@@ -139,7 +140,7 @@ func _apply_dynamic_environment_materials(node: Node) -> void:
|
||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||
|
||||
if node.is_in_group("weather_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
|
||||
_apply_weather_overlay_to_node(node, _get_weather_overlay_material(node))
|
||||
|
||||
if _should_clear_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
@@ -165,12 +166,24 @@ func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
|
||||
|
||||
func ApplyWeatherShaderToMaterials():
|
||||
for node in get_tree().get_nodes_in_group("weather_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
|
||||
_apply_weather_overlay_to_node(node, _get_weather_overlay_material(node))
|
||||
|
||||
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
|
||||
if _should_clear_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
|
||||
func _get_weather_overlay_material(node: Node) -> Material:
|
||||
if not node.is_in_group("weather_overlay_no_noise"):
|
||||
return WEATHER_SHADER
|
||||
|
||||
if weather_shader_no_noise == null:
|
||||
weather_shader_no_noise = WEATHER_SHADER.duplicate() as Material
|
||||
var shader_material := weather_shader_no_noise as ShaderMaterial
|
||||
if shader_material:
|
||||
shader_material.set_shader_parameter("snow_noise_enabled", false)
|
||||
|
||||
return weather_shader_no_noise
|
||||
|
||||
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
|
||||
if _should_clear_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
@@ -218,7 +231,7 @@ func _shader_material_uses_alpha_texture(material: ShaderMaterial) -> bool:
|
||||
return material.shader.code.find("alpha_texture") != -1
|
||||
|
||||
func _should_clear_weather_overlay(node: Node) -> bool:
|
||||
return node.is_in_group("weather_vegetables_node")
|
||||
return node.is_in_group("weather_vegetables_node") or node.is_in_group("weather_overlay_ignore")
|
||||
|
||||
func select_day_time(normalized_time: float) -> void:
|
||||
#set show_day_time_debug = true to show debug on screen
|
||||
|
||||
@@ -17,6 +17,7 @@ global uniform float global_snow_cap_flatness_end = 0.96;
|
||||
global uniform float global_snow_cap_noise_scale = 0.22;
|
||||
global uniform float global_snow_cap_noise_strength = 0.18;
|
||||
const float SNOW_VISUAL_RESPONSE = 0.55;
|
||||
uniform bool snow_noise_enabled = true;
|
||||
uniform float snow_noise_scale : hint_range(0.01, 1.0) = 0.15;
|
||||
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.2;
|
||||
uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15;
|
||||
@@ -92,6 +93,10 @@ float get_visual_snow_progress(float snow_progress) {
|
||||
}
|
||||
|
||||
float get_snow_noise_mask(vec3 world_pos, float snow_progress) {
|
||||
if (!snow_noise_enabled) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
float detail_noise = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||
float broad_noise = texture(noise_texture, world_pos.xz * snow_noise_scale * 0.35 + vec2(19.1, 7.4)).r;
|
||||
float combined_noise = mix(detail_noise, broad_noise, 0.35);
|
||||
@@ -118,7 +123,7 @@ void vertex() {
|
||||
world_normal.y
|
||||
);
|
||||
float accumulation_growth = smoothstep(0.02, 0.45, snow_progress);
|
||||
float cap_noise = fbm(world_pos.xz * global_snow_cap_noise_scale + vec2(11.3, 4.7));
|
||||
float cap_noise = snow_noise_enabled ? fbm(world_pos.xz * global_snow_cap_noise_scale + vec2(11.3, 4.7)) : 0.5;
|
||||
float cap_variation = mix(1.0 - global_snow_cap_noise_strength, 1.0 + global_snow_cap_noise_strength, cap_noise);
|
||||
|
||||
v_snow_amount = snow_progress;
|
||||
@@ -133,7 +138,7 @@ void fragment() {
|
||||
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
||||
vec3 geometric_normal = normalize(cross(dFdx(world_pos), dFdy(world_pos)));
|
||||
float snow_facing_up = max(facing_up, abs(geometric_normal.y));
|
||||
float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||
float noise_val = snow_noise_enabled ? texture(noise_texture, world_pos.xz * snow_noise_scale).r : 0.5;
|
||||
|
||||
//Snow
|
||||
float snow_progress = v_snow_amount;
|
||||
|
||||
Reference in New Issue
Block a user