Feature: Implement screen-space lens flare light source and rendering
This commit is contained in:
@@ -113,6 +113,10 @@ import {
|
||||
resolveDominantScreenSpaceGodRaysLightInput,
|
||||
syncScreenSpaceGodRaysLightSource
|
||||
} from "../rendering/screen-space-god-rays";
|
||||
import {
|
||||
createScreenSpaceLensFlareLightSource,
|
||||
syncScreenSpaceLensFlareLightSource
|
||||
} from "../rendering/screen-space-lens-flare";
|
||||
import {
|
||||
fitCelestialDirectionalShadow,
|
||||
resolveDominantCelestialShadowCaster
|
||||
@@ -706,6 +710,8 @@ export class RuntimeHost {
|
||||
private readonly sunLight = new DirectionalLight();
|
||||
private readonly moonLight = new DirectionalLight();
|
||||
private readonly godRaysLightSource = createScreenSpaceGodRaysLightSource();
|
||||
private readonly lensFlareLightSource =
|
||||
createScreenSpaceLensFlareLightSource();
|
||||
private readonly distanceFogSkyColorSource =
|
||||
createDistanceFogSkyColorSource();
|
||||
private readonly localLightGroup = new Group();
|
||||
|
||||
@@ -2930,58 +2930,64 @@ export class ViewportHost {
|
||||
this.distanceFogSkyColorSource,
|
||||
resolveWorldBackgroundSkyColorState(displayedBackground, shaderSkyState)
|
||||
);
|
||||
const godRaysLightInput =
|
||||
const screenSpaceSunLightInput =
|
||||
shaderSkyState !== null
|
||||
? resolveDominantScreenSpaceGodRaysLightInput(
|
||||
shaderSkyState.celestial.sunVisible
|
||||
? {
|
||||
colorHex: shaderSkyState.celestial.sunColorHex,
|
||||
intensity:
|
||||
shaderSkyState.celestial.sunIntensity *
|
||||
resolveWorldCelestialHorizonVisibility(
|
||||
shaderSkyState.celestial.sunDirection.y,
|
||||
shaderSkyState.sky.horizonHeight
|
||||
),
|
||||
direction: shaderSkyState.celestial.sunDirection
|
||||
}
|
||||
: null,
|
||||
shaderSkyState.celestial.moonVisible
|
||||
? {
|
||||
colorHex: shaderSkyState.celestial.moonColorHex,
|
||||
intensity:
|
||||
shaderSkyState.celestial.moonIntensity *
|
||||
resolveWorldCelestialHorizonVisibility(
|
||||
shaderSkyState.celestial.moonDirection.y,
|
||||
shaderSkyState.sky.horizonHeight
|
||||
),
|
||||
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
|
||||
? null
|
||||
: {
|
||||
colorHex: celestialBodiesState.moon.colorHex,
|
||||
direction: celestialBodiesState.moon.direction,
|
||||
intensity:
|
||||
celestialBodiesState.moon.intensity *
|
||||
celestialBodiesState.moon.horizonVisibility
|
||||
}
|
||||
);
|
||||
? shaderSkyState.celestial.sunVisible
|
||||
? {
|
||||
colorHex: shaderSkyState.celestial.sunColorHex,
|
||||
intensity:
|
||||
shaderSkyState.celestial.sunIntensity *
|
||||
resolveWorldCelestialHorizonVisibility(
|
||||
shaderSkyState.celestial.sunDirection.y,
|
||||
shaderSkyState.sky.horizonHeight
|
||||
),
|
||||
direction: shaderSkyState.celestial.sunDirection
|
||||
}
|
||||
: 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:
|
||||
shaderSkyState.celestial.moonIntensity *
|
||||
resolveWorldCelestialHorizonVisibility(
|
||||
shaderSkyState.celestial.moonDirection.y,
|
||||
shaderSkyState.sky.horizonHeight
|
||||
),
|
||||
direction: shaderSkyState.celestial.moonDirection
|
||||
}
|
||||
: null
|
||||
: celestialBodiesState.moon === null
|
||||
? null
|
||||
: {
|
||||
colorHex: celestialBodiesState.moon.colorHex,
|
||||
direction: celestialBodiesState.moon.direction,
|
||||
intensity:
|
||||
celestialBodiesState.moon.intensity *
|
||||
celestialBodiesState.moon.horizonVisibility
|
||||
};
|
||||
const godRaysLightInput = resolveDominantScreenSpaceGodRaysLightInput(
|
||||
screenSpaceSunLightInput,
|
||||
screenSpaceMoonLightInput
|
||||
);
|
||||
syncScreenSpaceGodRaysLightSource(
|
||||
this.godRaysLightSource,
|
||||
godRaysLightInput
|
||||
);
|
||||
syncScreenSpaceLensFlareLightSource(
|
||||
this.lensFlareLightSource,
|
||||
screenSpaceSunLightInput
|
||||
);
|
||||
const environmentState = resolveWorldEnvironmentState(
|
||||
displayedBackground,
|
||||
backgroundTexture,
|
||||
@@ -3051,7 +3057,8 @@ export class ViewportHost {
|
||||
settings,
|
||||
this.worldBackgroundRenderer.scene,
|
||||
this.godRaysLightSource,
|
||||
this.distanceFogSkyColorSource
|
||||
this.distanceFogSkyColorSource,
|
||||
this.lensFlareLightSource
|
||||
);
|
||||
this.currentAdvancedRenderingSettings =
|
||||
cloneAdvancedRenderingSettings(settings);
|
||||
|
||||
Reference in New Issue
Block a user