Feat: Add screen-space lens flare support and refactor lighting calculation

This commit is contained in:
2026-05-19 21:12:01 +02:00
parent beabde908d
commit 107ccbf640
2 changed files with 56 additions and 48 deletions

View File

@@ -205,6 +205,7 @@ import {
ADVANCED_RENDERING_SHADOW_TYPES,
ADVANCED_RENDERING_TONE_MAPPING_MODES,
FOLIAGE_QUALITY_SHADOW_MODES,
MAX_ADVANCED_RENDERING_LENS_FLARE_GHOST_COUNT,
MAX_FOLIAGE_QUALITY_DENSITY_MULTIPLIER,
MAX_FOLIAGE_QUALITY_MAX_DISTANCE_MULTIPLIER,
MIN_FOLIAGE_QUALITY_DENSITY_MULTIPLIER,

View File

@@ -3024,10 +3024,9 @@ export class RuntimeHost {
shaderSkyState
)
);
const godRaysLightInput =
const screenSpaceSunLightInput =
shaderSkyState !== null
? resolveDominantScreenSpaceGodRaysLightInput(
shaderSkyState.celestial.sunVisible
? shaderSkyState.celestial.sunVisible
? {
colorHex: shaderSkyState.celestial.sunColorHex,
intensity:
@@ -3038,8 +3037,19 @@ export class RuntimeHost {
),
direction: shaderSkyState.celestial.sunDirection
}
: null,
shaderSkyState.celestial.moonVisible
: null
: celestialBodiesState.sun === null
? null
: {
colorHex: celestialBodiesState.sun.colorHex,
direction: celestialBodiesState.sun.direction,
intensity:
celestialBodiesState.sun.intensity *
celestialBodiesState.sun.horizonVisibility
};
const screenSpaceMoonLightInput =
shaderSkyState !== null
? shaderSkyState.celestial.moonVisible
? {
colorHex: shaderSkyState.celestial.moonColorHex,
intensity:
@@ -3051,18 +3061,7 @@ export class RuntimeHost {
direction: shaderSkyState.celestial.moonDirection
}
: null
)
: resolveDominantScreenSpaceGodRaysLightInput(
celestialBodiesState.sun === null
? null
: {
colorHex: celestialBodiesState.sun.colorHex,
direction: celestialBodiesState.sun.direction,
intensity:
celestialBodiesState.sun.intensity *
celestialBodiesState.sun.horizonVisibility
},
celestialBodiesState.moon === null
: celestialBodiesState.moon === null
? null
: {
colorHex: celestialBodiesState.moon.colorHex,
@@ -3070,12 +3069,19 @@ export class RuntimeHost {
intensity:
celestialBodiesState.moon.intensity *
celestialBodiesState.moon.horizonVisibility
}
};
const godRaysLightInput = resolveDominantScreenSpaceGodRaysLightInput(
screenSpaceSunLightInput,
screenSpaceMoonLightInput
);
syncScreenSpaceGodRaysLightSource(
this.godRaysLightSource,
godRaysLightInput
);
syncScreenSpaceLensFlareLightSource(
this.lensFlareLightSource,
screenSpaceSunLightInput
);
const environmentState = resolveWorldEnvironmentState(
resolvedWorld.background,
backgroundTexture,
@@ -3203,7 +3209,8 @@ export class RuntimeHost {
settings,
this.worldBackgroundRenderer.scene,
this.godRaysLightSource,
this.distanceFogSkyColorSource
this.distanceFogSkyColorSource,
this.lensFlareLightSource
);
this.currentAdvancedRenderingSettings =
cloneAdvancedRenderingSettings(settings);