Add first pass sky lighting

This commit is contained in:
2026-05-16 01:32:48 -07:00
parent 06508061da
commit dddac97658
7 changed files with 311 additions and 21 deletions
+11 -18
View File
@@ -68,25 +68,11 @@ DEMO_ACTORS = [
"rotation": unreal.Rotator(0.0, 135.0, 0.0),
},
{
"label": "AGR_DemoSun",
"class": unreal.DirectionalLight,
"location_xy": unreal.Vector(-22000.0, -9000.0, 0.0),
"fixed_z": 35000.0,
"rotation": unreal.Rotator(-42.0, -35.0, 0.0),
},
{
"label": "AGR_DemoSkyLight",
"class": unreal.SkyLight,
"label": "AGR_DemoSkyLightingController",
"class": unreal.AgrarianSkyLightingController,
"location_xy": unreal.Vector(-18000.0, -7000.0, 0.0),
"fixed_z": 12000.0,
"rotation": unreal.Rotator(0.0, 0.0, 0.0),
},
{
"label": "AGR_DemoFog",
"class": unreal.ExponentialHeightFog,
"location_xy": unreal.Vector(-18000.0, -7000.0, 0.0),
"fixed_z": 4000.0,
"rotation": unreal.Rotator(0.0, 0.0, 0.0),
"rotation": unreal.Rotator(-42.0, -35.0, 0.0),
},
{
"label": "AGR_DemoNoticeActor",
@@ -97,6 +83,12 @@ DEMO_ACTORS = [
},
]
LEGACY_DEMO_LIGHTING_LABELS = {
"AGR_DemoSun",
"AGR_DemoSkyLight",
"AGR_DemoFog",
}
BIOME_RESOURCE_ACTORS = [
{
@@ -330,7 +322,7 @@ def spawn_foliage_actor(height_values):
reserved_points = [
spec["location_xy"]
for spec in DEMO_ACTORS
if spec["label"] not in {"AGR_DemoSun", "AGR_DemoSkyLight", "AGR_DemoFog", "AGR_DemoNoticeActor"}
if spec["label"] not in {"AGR_DemoSkyLightingController", "AGR_DemoNoticeActor"}
]
foliage_actor = unreal.AgrarianEditorAutomationLibrary.spawn_actor_in_editor_world(
@@ -405,6 +397,7 @@ def main():
raise RuntimeError(f"Could not load map: {MAP_PATH}")
labels = {spec["label"] for spec in DEMO_ACTORS}
labels.update(LEGACY_DEMO_LIGHTING_LABELS)
labels.update(spec["label"] for spec in BIOME_RESOURCE_ACTORS)
labels.update(spec["label"] for spec in WATER_SOURCE_ACTORS)
labels.add(FOLIAGE_LABEL)
+66
View File
@@ -0,0 +1,66 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SKY_H = ROOT / "Source" / "AgrarianGame" / "AgrarianSkyLightingController.h"
SKY_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianSkyLightingController.cpp"
MAP_SETUP = ROOT / "Scripts" / "setup_ground_zero_demo_map.py"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"
EXPECTED = {
SKY_H: [
"class AAgrarianSkyLightingController : public AActor",
"TObjectPtr<UDirectionalLightComponent> SunLight;",
"TObjectPtr<USkyLightComponent> SkyLight;",
"TObjectPtr<UExponentialHeightFogComponent> HeightFog;",
"void RefreshSkyLighting();",
"float CalculateSunAlpha",
"float CalculateWeatherCloudAlpha",
],
SKY_CPP: [
"#include \"AgrarianGameState.h\"",
"SunLight = CreateDefaultSubobject<UDirectionalLightComponent>",
"SkyLight = CreateDefaultSubobject<USkyLightComponent>",
"HeightFog = CreateDefaultSubobject<UExponentialHeightFogComponent>",
"GameState->SunriseHourLocal",
"GameState->SunsetHourLocal",
"GameState->ActiveWeatherInputs.CloudCoverPercent",
"SunLight->SetWorldRotation",
"SunLight->SetIntensity",
"SkyLight->SetIntensity",
"HeightFog->SetFogDensity",
],
MAP_SETUP: [
"AGR_DemoSkyLightingController",
"unreal.AgrarianSkyLightingController",
"LEGACY_DEMO_LIGHTING_LABELS",
"\"AGR_DemoSun\"",
"\"AGR_DemoSkyLight\"",
"\"AGR_DemoFog\"",
],
TDD: [
"`AAgrarianSkyLightingController`",
"movable sun, skylight, and exponential-height-fog components",
],
ROADMAP: [
"[x] Add first-pass sky and lighting.",
],
}
def main() -> None:
missing = []
for path, snippets in EXPECTED.items():
text = path.read_text(encoding="utf-8")
for snippet in snippets:
if snippet not in text:
missing.append(f"{path.relative_to(ROOT)}: {snippet}")
if missing:
raise RuntimeError("Sky lighting controller verification failed: " + "; ".join(missing))
print("Agrarian sky lighting controller verification complete.")
if __name__ == "__main__":
main()