restore full world effects outside portmaster
This commit is contained in:
parent
4fda6e97f6
commit
41b4f86ddf
15 changed files with 398 additions and 122 deletions
|
|
@ -138,6 +138,7 @@ var _biome_assignments: Dictionary[Vector2i, StringName] = {}
|
|||
var _water_recovery_triangles_by_coordinate: Dictionary[Vector2i, Array] = {}
|
||||
var _home_accessible_elevations_by_coordinate: Dictionary[Vector2i, Array] = {}
|
||||
var _foliage_wind_enabled: bool = false
|
||||
var _foliage_wind_strength_multiplier: float = 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -218,6 +219,24 @@ func set_light_performance_profile(enabled: bool) -> void:
|
|||
_light_performance_profile = enabled
|
||||
_set_foliage_wind_enabled(not enabled)
|
||||
_apply_water_materials()
|
||||
var surface_motion := _get_ocean_surface_motion()
|
||||
if surface_motion != null:
|
||||
surface_motion.set_motion_enabled(not enabled)
|
||||
|
||||
|
||||
func set_foliage_wind_strength_multiplier(multiplier: float) -> void:
|
||||
_foliage_wind_strength_multiplier = maxf(multiplier, 0.0)
|
||||
_set_foliage_wind_enabled(_foliage_wind_enabled)
|
||||
|
||||
|
||||
func set_water_motion_strength_multiplier(multiplier: float) -> void:
|
||||
var surface_motion := _get_ocean_surface_motion()
|
||||
if surface_motion != null:
|
||||
surface_motion.set_motion_strength_multiplier(multiplier)
|
||||
|
||||
|
||||
func _get_ocean_surface_motion() -> WaterSurfaceMotion:
|
||||
return _ocean.get_node_or_null(^"VisualWater") as WaterSurfaceMotion
|
||||
|
||||
|
||||
func get_spawn_surface_triangles(
|
||||
|
|
@ -611,13 +630,29 @@ func _apply_foliage_wind_to_mesh(mesh_instance: MeshInstance3D) -> void:
|
|||
(mesh_global_scale.x + mesh_global_scale.z) * 0.5,
|
||||
0.001,
|
||||
)
|
||||
var local_strength: float = foliage_wind_strength / horizontal_scale
|
||||
var local_strength: float = (
|
||||
foliage_wind_strength * _foliage_wind_strength_multiplier
|
||||
/ horizontal_scale
|
||||
)
|
||||
var phase: float = fposmod(
|
||||
mesh_instance.global_position.x * 0.73
|
||||
+ mesh_instance.global_position.z * 0.41,
|
||||
TAU,
|
||||
)
|
||||
for surface_index: int in mesh_instance.mesh.get_surface_count():
|
||||
var override_material: Material = (
|
||||
mesh_instance.get_surface_override_material(surface_index)
|
||||
)
|
||||
var existing_wind := override_material as ShaderMaterial
|
||||
if (
|
||||
existing_wind != null
|
||||
and existing_wind.shader == FOLIAGE_WIND_SHADER
|
||||
):
|
||||
existing_wind.set_shader_parameter(
|
||||
"local_wind_strength",
|
||||
local_strength,
|
||||
)
|
||||
continue
|
||||
var source_material: Material = mesh_instance.get_active_material(
|
||||
surface_index
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3]
|
||||
[gd_scene load_steps=17 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://world/generation/generated_world_region.gd" id="1_region"]
|
||||
[ext_resource type="Script" path="res://world/generation/terrain_chunk_generator.gd" id="2_generator"]
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
[ext_resource type="Resource" path="res://world/generation/biomes/terrain_biome_catalog.tres" id="13_biome_catalog"]
|
||||
[ext_resource type="PackedScene" path="res://world/interactables/decor_shop_world.tscn" id="14_decor_shop"]
|
||||
[ext_resource type="PackedScene" path="res://world/interactables/rv_upgrade_shop_world.tscn" id="15_rv_upgrade"]
|
||||
[ext_resource type="Script" path="res://world/water_surface_motion.gd" id="16_water_motion"]
|
||||
|
||||
[node name="GeneratedWorldRegion" type="Node3D"]
|
||||
script = ExtResource("1_region")
|
||||
|
|
@ -60,6 +61,9 @@ fish_pool = ExtResource("10_ocean_pool")
|
|||
water_type = 1
|
||||
location_tags = Array[StringName]([&"coast", &"ocean", &"generated_ocean"])
|
||||
|
||||
[node name="VisualWater" parent="WaterBodies/OceanWater" index="0"]
|
||||
script = ExtResource("16_water_motion")
|
||||
|
||||
[node name="FreshWaterBodies" type="Node3D" parent="WaterBodies"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ var rv_upgrade_shop_path: NodePath = (
|
|||
@export_range(0.0, 4.0, 0.05) var foliage_wind_speed: float = 0.9
|
||||
|
||||
var _foliage_wind_enabled: bool = false
|
||||
var _foliage_wind_strength_multiplier: float = 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -141,6 +142,19 @@ func set_light_performance_profile(enabled: bool) -> void:
|
|||
surface_motion.set_motion_enabled(not enabled)
|
||||
|
||||
|
||||
func set_foliage_wind_strength_multiplier(multiplier: float) -> void:
|
||||
_foliage_wind_strength_multiplier = maxf(multiplier, 0.0)
|
||||
_set_foliage_wind_enabled(_foliage_wind_enabled)
|
||||
|
||||
|
||||
func set_water_motion_strength_multiplier(multiplier: float) -> void:
|
||||
var ocean := get_node_or_null(
|
||||
^"WaterBodies/Ocean/VisualWater"
|
||||
) as WaterSurfaceMotion
|
||||
if ocean != null:
|
||||
ocean.set_motion_strength_multiplier(multiplier)
|
||||
|
||||
|
||||
func is_foliage_wind_enabled() -> bool:
|
||||
return _foliage_wind_enabled
|
||||
|
||||
|
|
@ -342,13 +356,29 @@ func _apply_foliage_wind_to_mesh(mesh_instance: MeshInstance3D) -> void:
|
|||
(mesh_global_scale.x + mesh_global_scale.z) * 0.5,
|
||||
0.001,
|
||||
)
|
||||
var local_strength: float = foliage_wind_strength / horizontal_scale
|
||||
var local_strength: float = (
|
||||
foliage_wind_strength * _foliage_wind_strength_multiplier
|
||||
/ horizontal_scale
|
||||
)
|
||||
var phase: float = fposmod(
|
||||
mesh_instance.global_position.x * 0.73
|
||||
+ mesh_instance.global_position.z * 0.41,
|
||||
TAU,
|
||||
)
|
||||
for surface_index: int in mesh_instance.mesh.get_surface_count():
|
||||
var override_material: Material = (
|
||||
mesh_instance.get_surface_override_material(surface_index)
|
||||
)
|
||||
var existing_wind := override_material as ShaderMaterial
|
||||
if (
|
||||
existing_wind != null
|
||||
and existing_wind.shader == FOLIAGE_WIND_SHADER
|
||||
):
|
||||
existing_wind.set_shader_parameter(
|
||||
"local_wind_strength",
|
||||
local_strength,
|
||||
)
|
||||
continue
|
||||
var source_material: Material = mesh_instance.get_active_material(
|
||||
surface_index
|
||||
)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ func set_light_performance_profile(_enabled: bool) -> void:
|
|||
pass
|
||||
|
||||
|
||||
func set_foliage_wind_strength_multiplier(_multiplier: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func set_water_motion_strength_multiplier(_multiplier: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func get_playable_half_extents() -> Vector2:
|
||||
return Vector2(50.0, 50.0)
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ const WORLD_BOUNDARY_SHORELINE_CLEARANCE := 18.0
|
|||
var _world_layout: StringName = WorldLayoutType.GENERATED
|
||||
var _world_seed: int = PlayerSaveManager.DEFAULT_WORLD_SEED
|
||||
var _light_performance_profile: bool = false
|
||||
var _foliage_wind_strength_multiplier: float = 1.0
|
||||
var _water_motion_strength_multiplier: float = 1.0
|
||||
var _dedicated_simulation: bool = false
|
||||
var _local_home_interior_presentation_active: bool = false
|
||||
|
||||
|
|
@ -100,6 +102,22 @@ func set_light_performance_profile(enabled: bool) -> void:
|
|||
_active_region.set_light_performance_profile(enabled)
|
||||
|
||||
|
||||
func set_foliage_wind_strength_multiplier(multiplier: float) -> void:
|
||||
_foliage_wind_strength_multiplier = maxf(multiplier, 0.0)
|
||||
if _active_region != null:
|
||||
_active_region.set_foliage_wind_strength_multiplier(
|
||||
_foliage_wind_strength_multiplier
|
||||
)
|
||||
|
||||
|
||||
func set_water_motion_strength_multiplier(multiplier: float) -> void:
|
||||
_water_motion_strength_multiplier = maxf(multiplier, 0.0)
|
||||
if _active_region != null:
|
||||
_active_region.set_water_motion_strength_multiplier(
|
||||
_water_motion_strength_multiplier
|
||||
)
|
||||
|
||||
|
||||
func set_local_home_interior_presentation_active(enabled: bool) -> void:
|
||||
_local_home_interior_presentation_active = enabled
|
||||
if _active_region != null and not _dedicated_simulation:
|
||||
|
|
@ -310,6 +328,12 @@ func _replace_active_region(layout: StringName, world_seed: int) -> bool:
|
|||
_active_region = replacement
|
||||
_regions_root.add_child(_active_region)
|
||||
_active_region.set_light_performance_profile(_light_performance_profile)
|
||||
_active_region.set_foliage_wind_strength_multiplier(
|
||||
_foliage_wind_strength_multiplier
|
||||
)
|
||||
_active_region.set_water_motion_strength_multiplier(
|
||||
_water_motion_strength_multiplier
|
||||
)
|
||||
if _dedicated_simulation:
|
||||
_set_region_presentation_enabled(_active_region, false)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const DEFAULT_PHASE_OFFSET: float = 0.0
|
|||
@export_range(0.0, TAU, 0.01, "radians") var phase_offset: float = 0.0
|
||||
|
||||
var _base_height: float
|
||||
var _motion_strength_multiplier: float = 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -28,7 +29,7 @@ func _ready() -> void:
|
|||
func _process(_delta: float) -> void:
|
||||
position.y = _base_height + calculate_height_offset(
|
||||
_current_time_seconds(),
|
||||
amplitude,
|
||||
get_effective_amplitude(),
|
||||
cycle_seconds,
|
||||
secondary_swell,
|
||||
phase_offset,
|
||||
|
|
@ -41,6 +42,20 @@ func set_motion_enabled(enabled: bool) -> void:
|
|||
position.y = _base_height
|
||||
|
||||
|
||||
func set_motion_strength_multiplier(multiplier: float) -> void:
|
||||
_motion_strength_multiplier = maxf(multiplier, 0.0)
|
||||
if _motion_strength_multiplier <= 0.0:
|
||||
position.y = _base_height
|
||||
|
||||
|
||||
func get_motion_strength_multiplier() -> float:
|
||||
return _motion_strength_multiplier
|
||||
|
||||
|
||||
func get_effective_amplitude() -> float:
|
||||
return amplitude * _motion_strength_multiplier
|
||||
|
||||
|
||||
static func get_default_height_offset() -> float:
|
||||
return calculate_height_offset(
|
||||
_current_time_seconds(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue