Integrate screen space god rays lighting

This commit is contained in:
2026-04-28 04:34:18 +02:00
parent bb6f5ae8b8
commit d6d2c5b4a2

View File

@@ -86,6 +86,10 @@ import {
type ResolvedBoxVolumeRenderPaths type ResolvedBoxVolumeRenderPaths
} from "../rendering/advanced-rendering"; } from "../rendering/advanced-rendering";
import { applyAdvancedRenderingPerspectiveCameraFar } from "../rendering/distance-fog-pass"; import { applyAdvancedRenderingPerspectiveCameraFar } from "../rendering/distance-fog-pass";
import {
createScreenSpaceGodRaysLightSource,
syncScreenSpaceGodRaysLightSource
} from "../rendering/screen-space-god-rays";
import { import {
fitCelestialDirectionalShadow, fitCelestialDirectionalShadow,
resolveDominantCelestialShadowCaster resolveDominantCelestialShadowCaster
@@ -641,6 +645,7 @@ export class RuntimeHost {
private readonly ambientLight = new AmbientLight(); private readonly ambientLight = new AmbientLight();
private readonly sunLight = new DirectionalLight(); private readonly sunLight = new DirectionalLight();
private readonly moonLight = new DirectionalLight(); private readonly moonLight = new DirectionalLight();
private readonly godRaysLightSource = createScreenSpaceGodRaysLightSource();
private readonly localLightGroup = new Group(); private readonly localLightGroup = new Group();
private readonly lightVolumeGroup = new Group(); private readonly lightVolumeGroup = new Group();
private readonly brushGroup = new Group(); private readonly brushGroup = new Group();
@@ -2910,11 +2915,15 @@ export class RuntimeHost {
this.ambientLight.color.set(resolvedWorld.ambientLight.colorHex); this.ambientLight.color.set(resolvedWorld.ambientLight.colorHex);
this.ambientLight.intensity = resolvedWorld.ambientLight.intensity; this.ambientLight.intensity = resolvedWorld.ambientLight.intensity;
this.currentCelestialShadowCaster = const dominantCelestialLight = resolveDominantCelestialShadowCaster(
resolveDominantCelestialShadowCaster( resolvedWorld.sunLight,
resolvedWorld.sunLight, resolvedWorld.moonLight
resolvedWorld.moonLight );
)?.key ?? null; this.currentCelestialShadowCaster = dominantCelestialLight?.key ?? null;
syncScreenSpaceGodRaysLightSource(
this.godRaysLightSource,
dominantCelestialLight?.light ?? null
);
this.sunLight.color.set(resolvedWorld.sunLight.colorHex); this.sunLight.color.set(resolvedWorld.sunLight.colorHex);
this.sunLight.intensity = resolvedWorld.sunLight.intensity; this.sunLight.intensity = resolvedWorld.sunLight.intensity;
this.sunLight.visible = resolvedWorld.sunLight.intensity > 1e-4; this.sunLight.visible = resolvedWorld.sunLight.intensity > 1e-4;
@@ -3021,7 +3030,8 @@ export class RuntimeHost {
this.scene, this.scene,
this.camera, this.camera,
settings, settings,
this.worldBackgroundRenderer.scene this.worldBackgroundRenderer.scene,
this.godRaysLightSource
); );
this.currentAdvancedRenderingSettings = this.currentAdvancedRenderingSettings =
cloneAdvancedRenderingSettings(settings); cloneAdvancedRenderingSettings(settings);