restore full world effects outside portmaster

This commit is contained in:
Alexander Sellite 2026-09-01 19:00:13 -04:00
parent 4fda6e97f6
commit 41b4f86ddf
15 changed files with 398 additions and 122 deletions

View file

@ -4,6 +4,9 @@ const MainScene: PackedScene = preload("res://main/main.tscn")
const RuntimePerformanceProfileType = preload(
"res://main/runtime_performance_profile.gd"
)
const FOLIAGE_WIND_SHADER: Shader = preload(
"res://world/materials/foliage_wind.gdshader"
)
func _initialize() -> void:
call_deferred("_run")
@ -30,8 +33,11 @@ func _run() -> void:
PlayerSaveManager.DEFAULT_WORLD_SEED,
true,
)))
_validate_main_profile(main)
_validate_minimal_weather(main)
# A regular editor/desktop runtime must ignore a light-profile environment
# variable. Only the tagged PortMaster export is allowed to honor it.
_validate_normal_profile(main)
_validate_rain_visual_motion(main)
_validate_new_game_music_transition(main)
_stop_audio_players(main)
main.queue_free()
for _frame: int in 8:
@ -39,28 +45,7 @@ func _run() -> void:
OS.unset_environment(
RuntimePerformanceProfileType.PROFILE_ENVIRONMENT_VARIABLE
)
var normal_main: Node = MainScene.instantiate()
root.add_child(normal_main)
for _frame: int in 4:
await process_frame
if not bool(normal_main.get("_application_initialized")):
normal_main.call("_activate_selected_data_path", "", true)
for _frame: int in 8:
await process_frame
assert(bool(normal_main.get("_application_initialized")))
assert(bool(normal_main.call(
"_apply_world",
WorldLayout.GENERATED,
PlayerSaveManager.DEFAULT_WORLD_SEED,
true,
)))
_validate_normal_profile(normal_main)
_validate_new_game_music_transition(normal_main)
_stop_audio_players(normal_main)
normal_main.queue_free()
for _frame: int in 8:
await process_frame
print("Light performance profile validation: PASS")
print("Runtime performance profile validation: PASS")
quit()
@ -73,53 +58,31 @@ func _validate_profile_resolution() -> void:
assert(light.is_light())
assert(is_equal_approx(light.get_world_render_scale(), 0.375))
assert(legacy.is_light())
func _validate_main_profile(main: Node) -> void:
var profile: RuntimePerformanceProfile = main.get("_performance_profile")
assert(profile != null and profile.is_light())
assert(is_equal_approx(root.scaling_3d_scale, 0.375))
var pixelation: Node = main.get_node("%WorldPixelationPostprocess")
assert(bool(pixelation.call("is_light_performance_profile")))
pixelation.call("set_gameplay_active", true)
var screen_grid := pixelation.get_node("ScreenGrid") as ColorRect
assert(screen_grid != null and not screen_grid.visible)
var pond := _first_fresh_water_visual(main)
var ocean := main.get_node(
"TestWorld/Regions/GeneratedWorldRegion/WaterBodies/OceanWater/VisualWater"
) as MeshInstance3D
assert(not pond.visible)
assert(ocean.material_override is StandardMaterial3D)
assert(not ocean.material_override is ShaderMaterial)
_validate_ocean_fishing_coverage(main, ocean)
var region := main.get_node(
"TestWorld/Regions/GeneratedWorldRegion"
) as GeneratedWorldRegion
assert(region != null)
assert(region.get_node("Decorations").get_child_count() > 0)
var title_background := main.get_node("%TitleBackground") as ColorRect
var title_material := title_background.material as ShaderMaterial
assert(title_material != null)
assert(not bool(title_material.get_shader_parameter(
"animation_enabled"
)))
_validate_no_full_screen_menu_backdrops(main)
var game_ui := main.get_node("%GameUI") as GameUI
var title_screen := game_ui.get_title_screen()
assert(title_screen != null)
var player_menu := game_ui.get("_player_menu") as PlayerMenu
assert(player_menu != null)
assert(not player_menu.is_cooler_water_effect_enabled())
assert((main.get_node("%TitleMusic") as AudioStreamPlayer).stream != null)
assert((main.get_node("%NewGameMusic") as AudioStreamPlayer).stream != null)
assert((main.get_node("%DuskMusic") as AudioStreamPlayer).stream != null)
assert(
(main.get_node("%WavesAudio") as AudioStreamPlayer).stream == null
OS.set_environment(
RuntimePerformanceProfileType.PROFILE_ENVIRONMENT_VARIABLE,
"light",
)
assert(
(main.get_node("RainAmbience") as AudioStreamPlayer).stream == null
assert(not RuntimePerformanceProfileType.from_environment_for_portmaster_build(
false
).is_light())
assert(RuntimePerformanceProfileType.from_environment_for_portmaster_build(
true
).is_light())
OS.unset_environment(
RuntimePerformanceProfileType.PROFILE_ENVIRONMENT_VARIABLE
)
OS.set_environment(
RuntimePerformanceProfileType.LEGACY_LIGHT_ENVIRONMENT_VARIABLE,
"1",
)
assert(not RuntimePerformanceProfileType.from_environment_for_portmaster_build(
false
).is_light())
assert(RuntimePerformanceProfileType.from_environment_for_portmaster_build(
true
).is_light())
OS.unset_environment(
RuntimePerformanceProfileType.LEGACY_LIGHT_ENVIRONMENT_VARIABLE
)
@ -176,6 +139,54 @@ func _validate_normal_profile(main: Node) -> void:
)
func _validate_rain_visual_motion(main: Node) -> void:
var region := main.get_node(
"TestWorld/Regions/GeneratedWorldRegion"
) as GeneratedWorldRegion
assert(region != null)
var ocean_motion := region.get_node(
"WaterBodies/OceanWater/VisualWater"
) as WaterSurfaceMotion
assert(ocean_motion != null)
var normal_water_amplitude: float = ocean_motion.get_effective_amplitude()
var decorations := region.get_node("Decorations") as Node3D
assert(decorations != null)
var normal_wind := _first_foliage_wind_material(decorations)
assert(normal_wind != null)
var normal_wind_strength: float = float(
normal_wind.get_shader_parameter("local_wind_strength")
)
var weather := main.get_node("%WorldWeatherService") as WorldWeatherService
assert(weather != null)
weather.apply_authoritative_snapshot(
WorldWeatherService.Weather.RAINY,
60.0,
)
assert(is_equal_approx(
ocean_motion.get_effective_amplitude(),
normal_water_amplitude * 2.0,
))
var rainy_wind := _first_foliage_wind_material(decorations)
assert(rainy_wind != null)
assert(is_equal_approx(
float(rainy_wind.get_shader_parameter("local_wind_strength")),
normal_wind_strength * 2.0,
))
weather.apply_authoritative_snapshot(
WorldWeatherService.Weather.SUNNY,
60.0,
)
assert(is_equal_approx(
ocean_motion.get_effective_amplitude(), normal_water_amplitude
))
var restored_wind := _first_foliage_wind_material(decorations)
assert(restored_wind != null)
assert(is_equal_approx(
float(restored_wind.get_shader_parameter("local_wind_strength")),
normal_wind_strength,
))
func _validate_new_game_music_transition(main: Node) -> void:
var title_music := main.get_node("%TitleMusic") as AudioStreamPlayer
var new_game_music := main.get_node("%NewGameMusic") as AudioStreamPlayer
@ -201,6 +212,22 @@ func _first_fresh_water_visual(main: Node) -> MeshInstance3D:
return fresh_water_root.get_child(0).get_node("VisualWater") as MeshInstance3D
func _first_foliage_wind_material(root_node: Node) -> ShaderMaterial:
for node: Node in root_node.find_children(
"*", "MeshInstance3D", true, false
):
var mesh_instance := node as MeshInstance3D
if mesh_instance == null or mesh_instance.mesh == null:
continue
for surface_index: int in mesh_instance.mesh.get_surface_count():
var material := mesh_instance.get_surface_override_material(
surface_index
) as ShaderMaterial
if material != null and material.shader == FOLIAGE_WIND_SHADER:
return material
return null
func _validate_ocean_fishing_coverage(
main: Node,
ocean: MeshInstance3D,
@ -230,41 +257,3 @@ func _stop_audio_players(root_node: Node) -> void:
(root_node as AudioStreamPlayer3D).stop()
for child: Node in root_node.get_children():
_stop_audio_players(child)
func _validate_minimal_weather(main: Node) -> void:
var visuals: WorldTimeVisualController = main.get_node(
"%WorldTimeVisualController"
)
var rain := visuals.get_node("LocalRain") as GPUParticles3D
assert(rain.amount == WorldTimeVisualController.LIGHT_RAIN_PARTICLE_AMOUNT)
assert(rain.fixed_fps == WorldTimeVisualController.LIGHT_RAIN_FIXED_FPS)
assert(rain.amount == 48)
assert(rain.fixed_fps == 8)
var clouds := visuals.get_node("LocalStormClouds") as LocalStormCloudLayer
assert(clouds.get_patch_count() == 1)
var ceiling := clouds.get_node("CloudCeiling") as MeshInstance3D
assert(ceiling != null and ceiling.mesh is PlaneMesh)
assert(ceiling.material_override == null)
assert((ceiling.mesh as PlaneMesh).material is StandardMaterial3D)
visuals.apply_weather_immediately(WorldWeatherService.Weather.RAINY)
assert(rain.emitting and rain.amount_ratio > 0.99)
assert(clouds.visible and clouds.get_storm_amount() > 0.87)
var cloud_material := (
(ceiling.mesh as PlaneMesh).material as StandardMaterial3D
)
assert(cloud_material.albedo_color.a < 0.65)
var test_world := main.get_node("TestWorld") as TestWorld
var runtime_environment := (
test_world.get_world_environment().environment as Environment
)
var sky_material := (
runtime_environment.sky.sky_material as ShaderMaterial
)
assert(is_zero_approx(float(
sky_material.get_shader_parameter("cloud_coverage")
)))
assert(is_zero_approx(float(
sky_material.get_shader_parameter("cloud_opacity")
)))