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_tween: Tween
|
||||||
var day_time: float = 0.0
|
var day_time: float = 0.0
|
||||||
var pending_environment_nodes: Dictionary = {}
|
var pending_environment_nodes: Dictionary = {}
|
||||||
|
var weather_shader_no_noise: Material
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ func _apply_dynamic_environment_materials(node: Node) -> void:
|
|||||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||||
|
|
||||||
if node.is_in_group("weather_node"):
|
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):
|
if _should_clear_weather_overlay(node):
|
||||||
_clear_weather_overlay_from_node(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():
|
func ApplyWeatherShaderToMaterials():
|
||||||
for node in get_tree().get_nodes_in_group("weather_node"):
|
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"):
|
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
|
||||||
if _should_clear_weather_overlay(node):
|
if _should_clear_weather_overlay(node):
|
||||||
_clear_weather_overlay_from_node(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:
|
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
|
||||||
if _should_clear_weather_overlay(node):
|
if _should_clear_weather_overlay(node):
|
||||||
_clear_weather_overlay_from_node(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
|
return material.shader.code.find("alpha_texture") != -1
|
||||||
|
|
||||||
func _should_clear_weather_overlay(node: Node) -> bool:
|
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:
|
func select_day_time(normalized_time: float) -> void:
|
||||||
#set show_day_time_debug = true to show debug on screen
|
#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_scale = 0.22;
|
||||||
global uniform float global_snow_cap_noise_strength = 0.18;
|
global uniform float global_snow_cap_noise_strength = 0.18;
|
||||||
const float SNOW_VISUAL_RESPONSE = 0.55;
|
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_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_edge_softness : hint_range(0.01, 0.5) = 0.2;
|
||||||
uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15;
|
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) {
|
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 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 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);
|
float combined_noise = mix(detail_noise, broad_noise, 0.35);
|
||||||
@@ -118,7 +123,7 @@ void vertex() {
|
|||||||
world_normal.y
|
world_normal.y
|
||||||
);
|
);
|
||||||
float accumulation_growth = smoothstep(0.02, 0.45, snow_progress);
|
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);
|
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;
|
v_snow_amount = snow_progress;
|
||||||
@@ -133,7 +138,7 @@ void fragment() {
|
|||||||
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
||||||
vec3 geometric_normal = normalize(cross(dFdx(world_pos), dFdy(world_pos)));
|
vec3 geometric_normal = normalize(cross(dFdx(world_pos), dFdy(world_pos)));
|
||||||
float snow_facing_up = max(facing_up, abs(geometric_normal.y));
|
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
|
//Snow
|
||||||
float snow_progress = v_snow_amount;
|
float snow_progress = v_snow_amount;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ shader_parameter/glint_sharpness = 32.0
|
|||||||
shader_parameter/emission_color = Color(0.26628578, 0.030174213, 0.015801903, 1)
|
shader_parameter/emission_color = Color(0.26628578, 0.030174213, 0.015801903, 1)
|
||||||
shader_parameter/emission_energy = 10.000000475
|
shader_parameter/emission_energy = 10.000000475
|
||||||
|
|
||||||
[node name="Treno" unique_id=1182090923 groups=["weather_node"] instance=ExtResource("1_33mei")]
|
[node name="Treno" unique_id=1182090923 groups=["weather_node", "weather_overlay_no_noise"] instance=ExtResource("1_33mei")]
|
||||||
script = ExtResource("9_4qk3b")
|
script = ExtResource("9_4qk3b")
|
||||||
|
|
||||||
[node name="Finestrini" parent="." index="0" unique_id=755457549]
|
[node name="Finestrini" parent="." index="0" unique_id=755457549]
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ shader_parameter/glint_sharpness = 32.0
|
|||||||
shader_parameter/emission_color = Color(0.5882353, 0.06666667, 0.10980392, 1)
|
shader_parameter/emission_color = Color(0.5882353, 0.06666667, 0.10980392, 1)
|
||||||
shader_parameter/emission_energy = 6.50000030875
|
shader_parameter/emission_energy = 6.50000030875
|
||||||
|
|
||||||
[node name="wagon" unique_id=14655460 groups=["weather_node"] instance=ExtResource("1_ud2nc")]
|
[node name="wagon" unique_id=14655460 groups=["weather_node", "weather_overlay_no_noise"] instance=ExtResource("1_ud2nc")]
|
||||||
|
|
||||||
[node name="Finestrini_001" parent="." index="0" unique_id=1279718063]
|
[node name="Finestrini_001" parent="." index="0" unique_id=1279718063]
|
||||||
surface_material_override/0 = ExtResource("2_upuw2")
|
surface_material_override/0 = ExtResource("2_upuw2")
|
||||||
|
|||||||
Reference in New Issue
Block a user