babylonjs-editor-tools 5.5.0 → 5.5.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/build/index.node.js +2330 -1
  2. package/build/src/index.js +4 -0
  3. package/build/src/index.js.map +1 -1
  4. package/build/src/loading/loader.js +7 -2
  5. package/build/src/loading/loader.js.map +1 -1
  6. package/build/src/loading/mesh.js +22 -0
  7. package/build/src/loading/mesh.js.map +1 -0
  8. package/build/src/loading/rendering.js +4 -0
  9. package/build/src/loading/rendering.js.map +1 -1
  10. package/build/src/loading/transform-node.js +4 -1
  11. package/build/src/loading/transform-node.js.map +1 -1
  12. package/build/src/rendering/tools.js +7 -0
  13. package/build/src/rendering/tools.js.map +1 -1
  14. package/build/src/rendering/volumetric/pipeline.js +915 -0
  15. package/build/src/rendering/volumetric/pipeline.js.map +1 -0
  16. package/build/src/rendering/volumetric/selector.js +525 -0
  17. package/build/src/rendering/volumetric/selector.js.map +1 -0
  18. package/build/src/rendering/volumetric/shaders-wgsl.js +1207 -0
  19. package/build/src/rendering/volumetric/shaders-wgsl.js.map +1 -0
  20. package/build/src/rendering/volumetric/shaders.js +1293 -0
  21. package/build/src/rendering/volumetric/shaders.js.map +1 -0
  22. package/build/src/rendering/volumetric/types.js +301 -0
  23. package/build/src/rendering/volumetric/types.js.map +1 -0
  24. package/build/src/rendering/volumetric-lighting.js +72 -0
  25. package/build/src/rendering/volumetric-lighting.js.map +1 -0
  26. package/build/src/tools/guards.js +14 -0
  27. package/build/src/tools/guards.js.map +1 -1
  28. package/declaration/src/index.d.ts +4 -0
  29. package/declaration/src/loading/mesh.d.ts +1 -0
  30. package/declaration/src/rendering/tools.d.ts +1 -0
  31. package/declaration/src/rendering/volumetric/pipeline.d.ts +231 -0
  32. package/declaration/src/rendering/volumetric/selector.d.ts +263 -0
  33. package/declaration/src/rendering/volumetric/shaders-wgsl.d.ts +21 -0
  34. package/declaration/src/rendering/volumetric/shaders.d.ts +60 -0
  35. package/declaration/src/rendering/volumetric/types.d.ts +362 -0
  36. package/declaration/src/rendering/volumetric-lighting.d.ts +28 -0
  37. package/declaration/src/tools/guards.d.ts +12 -0
  38. package/package.json +1 -1
@@ -0,0 +1,231 @@
1
+ import { Scene } from "@babylonjs/core/scene";
2
+ import { Camera } from "@babylonjs/core/Cameras/camera";
3
+ import { AbstractEngine } from "@babylonjs/core/Engines/abstractEngine";
4
+ import { ShaderLanguage } from "@babylonjs/core/Materials/shaderLanguage";
5
+ import { PostProcessRenderPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderPipeline";
6
+ import { IVolumetricLightingConfiguration } from "./types";
7
+ import { IVolumetricBudget, IVolumetricLightingStats } from "./selector";
8
+ /**
9
+ * Defines a rendering pipeline computing single-scattering volumetric lighting: the light shafts are
10
+ * integrated through a participating medium the pipeline describes on its own, and are occluded either by
11
+ * the shadow map a light already renders or, when it has none, by the depth buffer of the scene.
12
+ *
13
+ * Every light of the scene can take part in the effect, including the lights that live inside a clustered
14
+ * light container, and each one is configured individually through "light.metadata.volumetricLighting".
15
+ *
16
+ * The cost of the effect scales with what is on screen rather than with the number of lights: a directional
17
+ * light is marched along the whole view ray, but a point or a spot light is only integrated over the part
18
+ * of the view ray crossing its volume, so a light costs nothing to the pixels whose view ray misses it.
19
+ *
20
+ * The pipeline is composed of four passes:
21
+ * - a pass keeping the color of the scene untouched and extracting its linear depth, which every later pass
22
+ * reads instead of the depth map,
23
+ * - the raymarching pass, rendered at a fraction of the resolution of the canvas,
24
+ * - a separable depth aware blur denoising the result of the raymarching,
25
+ * - a composition pass upsampling the result and adding it to the color of the scene.
26
+ */
27
+ export declare class VolumetricLightingRenderingPipeline extends PostProcessRenderPipeline {
28
+ /**
29
+ * Defines the name of the render effect keeping the color of the scene and extracting its linear depth.
30
+ */
31
+ static readonly SceneColorEffectName: string;
32
+ /**
33
+ * Defines the name of the render effect raymarching the participating medium.
34
+ */
35
+ static readonly ScatteringEffectName: string;
36
+ /**
37
+ * Defines the name of the render effect denoising the result of the raymarching.
38
+ */
39
+ static readonly BlurEffectName: string;
40
+ /**
41
+ * Defines the name of the render effect composing the light shafts over the color of the scene.
42
+ */
43
+ static readonly ComposeEffectName: string;
44
+ /**
45
+ * Returns the distance at which the medium becomes fully opaque to use as a default for the linear mode.
46
+ * @param scene defines the reference to the scene to measure.
47
+ * @param camera defines the reference to the camera, used when the scene has no geometry yet.
48
+ */
49
+ static GetDefaultFogEnd(scene: Scene, camera: Camera): number;
50
+ /**
51
+ * Returns the extinction coefficient to use as a default for the medium of the pipeline.
52
+ *
53
+ * There is no unit agnostic constant that works here: an extinction of 1 per unit is a thick smoke in a
54
+ * scene authored in metres and a vacuum in one authored in centimetres. Deriving it from the size of the
55
+ * scene gives an optical depth of about 1 from one end of the content to the other, which reads well
56
+ * whatever the project is authored in.
57
+ * @param scene defines the reference to the scene to measure.
58
+ * @param camera defines the reference to the camera, used when the scene has no geometry yet.
59
+ */
60
+ static GetDefaultFogDensity(scene: Scene, camera: Camera): number;
61
+ /**
62
+ * Returns wether or not the volumetric lighting rendering pipeline is supported by the given engine.
63
+ * The raymarching shader relies on shadow samplers, texture arrays and texel fetches, which need WebGL 2,
64
+ * and ships as both GLSL and hand written WGSL so WebGPU is supported without an external transpiler.
65
+ * @param engine defines the reference to the engine to check.
66
+ */
67
+ static IsSupported(engine: AbstractEngine): boolean;
68
+ /**
69
+ * Returns the language the shaders of the pipeline must be written in for the given engine.
70
+ * @param engine defines the reference to the engine to check.
71
+ */
72
+ static GetShaderLanguage(engine: AbstractEngine): ShaderLanguage;
73
+ private _scene;
74
+ private _camera;
75
+ private _configuration;
76
+ private _configurationProxy;
77
+ private _textureType;
78
+ private _shaderLanguage;
79
+ private _ldrEncode;
80
+ private _linearDepthPacked;
81
+ private _depthRenderer;
82
+ private _ownsDepthRenderer;
83
+ private _depthMode;
84
+ private _linearDepthPostProcess;
85
+ private _scatteringPostProcess;
86
+ private _blurPostProcesses;
87
+ private _composePostProcess;
88
+ private _selection;
89
+ private _budget;
90
+ private _linearDepthDefines;
91
+ private _scatteringDefines;
92
+ private _blurDefines;
93
+ private _composeDefines;
94
+ private _frameCount;
95
+ private _lightsDirty;
96
+ private _disposed;
97
+ private _beforeCameraRenderObserver;
98
+ private _lightAddedObserver;
99
+ private _lightRemovedObserver;
100
+ private _inverseViewProjection;
101
+ private _temporaryVector;
102
+ private _temporaryColor;
103
+ private _lightData;
104
+ private _lightDiffuse;
105
+ private _lightDirection;
106
+ private _lightFalloff;
107
+ private _shadowLightData;
108
+ private _shadowLightDiffuse;
109
+ private _shadowLightDirection;
110
+ private _shadowLightFalloff;
111
+ private _shadowInfo;
112
+ private _shadowMatrices;
113
+ private _csmLightData;
114
+ private _csmLightDiffuse;
115
+ private _csmLightDirection;
116
+ private _csmLightFalloff;
117
+ private _csmMatrices;
118
+ /**
119
+ * Constructor.
120
+ * @param name defines the name of the pipeline.
121
+ * @param scene defines the reference to the scene the pipeline belongs to.
122
+ * @param camera defines the reference to the camera the pipeline is attached to.
123
+ * @param configuration defines the optional configuration to apply on the pipeline.
124
+ */
125
+ constructor(name: string, scene: Scene, camera: Camera, configuration?: Partial<IVolumetricLightingConfiguration>);
126
+ /**
127
+ * Gets wether or not the pipeline was disposed. Babylon.js disposes a rendering pipeline on its own when
128
+ * one of its post-processes fails to compile, so this is not always the result of an explicit call.
129
+ */
130
+ get isDisposed(): boolean;
131
+ /**
132
+ * Gets the reference to the scene the pipeline belongs to.
133
+ */
134
+ get scene(): Scene;
135
+ /**
136
+ * Gets the reference to the camera the pipeline is attached to.
137
+ */
138
+ get camera(): Camera;
139
+ /**
140
+ * Gets the live configuration of the pipeline. Assigning a property of the returned object applies the
141
+ * change immediately, rebuilding the chain of post-processes when the change requires it.
142
+ */
143
+ get configuration(): IVolumetricLightingConfiguration;
144
+ /**
145
+ * Gets the statistics of the last selection pass, used by the inspector to explain what each light does.
146
+ */
147
+ getStats(): IVolumetricLightingStats | null;
148
+ /**
149
+ * Gets the number of lights the raymarching shader can be compiled for on the current engine.
150
+ */
151
+ getBudget(): IVolumetricBudget;
152
+ /**
153
+ * Gets a string identifying the name of the class.
154
+ */
155
+ getClassName(): string;
156
+ /**
157
+ * Marks the list of lights contributing to the effect as dirty, forcing a new selection pass on the
158
+ * next frame. Called when the volumetric configuration of a light is edited in the inspector.
159
+ */
160
+ markLightsDirty(): void;
161
+ /**
162
+ * Applies the given configuration on the pipeline.
163
+ * @param data defines the configuration to apply.
164
+ */
165
+ applyConfiguration(data: Partial<IVolumetricLightingConfiguration>): void;
166
+ /**
167
+ * Serializes the configuration of the pipeline.
168
+ */
169
+ serializeConfiguration(): IVolumetricLightingConfiguration;
170
+ /**
171
+ * Disposes the pipeline and all the resources it owns.
172
+ */
173
+ dispose(): void;
174
+ private _onConfigurationChanged;
175
+ /**
176
+ * Adopts the depth renderer of the camera when one already exists (the SSAO and SSR pipelines create
177
+ * one) instead of paying for a second full depth pass, and detects the format it stores so the shader
178
+ * can be compiled for it.
179
+ */
180
+ private _setupDepthRenderer;
181
+ /**
182
+ * Binds the two values needed to turn the content of the depth map back into a distance along the view
183
+ * axis. The depth renderer stores "(clipZ + minZ) / (minZ + maxZ)", where "clipZ" is affine in the view
184
+ * space Z for both the perspective and the orthographic projections, so the inverse is affine too and
185
+ * can be derived exactly from the projection matrix instead of being approximated.
186
+ */
187
+ private _bindDepthUniforms;
188
+ private _getEnvironment;
189
+ /**
190
+ * Returns the defines of the passes reading the linear depth, which only depend on how it is stored.
191
+ */
192
+ private _buildLinearDepthReadDefines;
193
+ /**
194
+ * Returns the defines of the linear depth pass, the only one reading the depth map of the depth renderer.
195
+ */
196
+ private _buildLinearDepthDefines;
197
+ private _buildScatteringDefines;
198
+ private _buildBlurDefines;
199
+ private _buildComposeDefines;
200
+ private _createPostProcess;
201
+ private _buildRenderEffects;
202
+ private _disposePostProcesses;
203
+ /**
204
+ * Rebuilds the chain of post-processes. Changing the resolution of the scattering buffer or the number
205
+ * of blur passes changes the shape of the chain, which a post-process can't do in place.
206
+ */
207
+ private _rebuildRenderEffects;
208
+ /**
209
+ * Runs the selection pass and recompiles the shaders when, and only when, their defines changed. The
210
+ * identity, the number and the values of the point and spot lights change every frame and only cost a
211
+ * uniform update: only the directional lights and the kinds of the shadow maps shape the shader.
212
+ */
213
+ private _updateSelection;
214
+ /**
215
+ * Fills the four vectors describing a light in the raymarching shader. The packing follows what
216
+ * "Light.transferToEffect" writes for the surfaces of the scene so the shafts agree with them, except for
217
+ * the position of the point and spot lights, which is written relative to the camera: the raymarching
218
+ * works in that space, which keeps its precision whatever the distance of the scene to the origin.
219
+ */
220
+ private _writeLight;
221
+ private _bindLinearDepth;
222
+ private _bindScattering;
223
+ /**
224
+ * Binds the ratio between the resolution of the linear depth and the resolution of the scattering buffer.
225
+ * It is computed here rather than in the shaders so every pass rounds it exactly the same way, which is what
226
+ * makes them all associate each texel of the scattering buffer with the same texel of the linear depth.
227
+ */
228
+ private _bindDepthRatio;
229
+ private _bindBlur;
230
+ private _bindCompose;
231
+ }
@@ -0,0 +1,263 @@
1
+ import { Scene } from "@babylonjs/core/scene";
2
+ import { Light } from "@babylonjs/core/Lights/light";
3
+ import { Camera } from "@babylonjs/core/Cameras/camera";
4
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector";
5
+ import { AbstractEngine } from "@babylonjs/core/Engines/abstractEngine";
6
+ import { ShadowGenerator } from "@babylonjs/core/Lights/Shadows/shadowGenerator";
7
+ import { CascadedShadowGenerator } from "@babylonjs/core/Lights/Shadows/cascadedShadowGenerator";
8
+ import { IVolumetricLightConfiguration, IVolumetricLightingConfiguration } from "./types";
9
+ /**
10
+ * Defines the type of sampler needed to read the shadow map of a light.
11
+ */
12
+ export declare enum VolumetricShadowKind {
13
+ /**
14
+ * Regular 2d texture storing the depth encoded in its color channels.
15
+ */
16
+ Texture2D = 0,
17
+ /**
18
+ * Hardware comparison sampler, used by the percentage closer filtering.
19
+ */
20
+ Sampler2DShadow = 1,
21
+ /**
22
+ * Cube texture storing the radial distance to the light, used by point lights.
23
+ */
24
+ Cube = 2
25
+ }
26
+ /**
27
+ * Defines how the value stored in a shadow map must be interpreted.
28
+ */
29
+ export declare enum VolumetricShadowMode {
30
+ /**
31
+ * The shadow map stores the depth, the comparison is a simple "greater than".
32
+ */
33
+ Standard = 0,
34
+ /**
35
+ * The shadow map stores the exponential of the depth.
36
+ */
37
+ Esm = 1,
38
+ /**
39
+ * The shadow map stores the exponential of the depth, compared in the "close" space.
40
+ */
41
+ CloseEsm = 2
42
+ }
43
+ /**
44
+ * Defines how the transmittance of the medium is evaluated by the raymarching shader.
45
+ */
46
+ export declare enum VolumetricTransmittanceMode {
47
+ /**
48
+ * Closed form of the three fog modes, for a medium whose density doesn't depend on the altitude.
49
+ */
50
+ Analytic = 0,
51
+ /**
52
+ * Closed form of the exponential fog mode combined with the height falloff.
53
+ */
54
+ AnalyticHeight = 1,
55
+ /**
56
+ * Optical depth integrated numerically along the view ray, for the other fog modes combined with the
57
+ * height falloff, which have no closed form.
58
+ */
59
+ Numeric = 2
60
+ }
61
+ /**
62
+ * Defines the state of a light regarding the volumetric lighting, as reported to the inspector.
63
+ */
64
+ export type VolumetricLightState = "shadowed" | "unshadowed" | "culled" | "dropped" | "disabled";
65
+ /**
66
+ * Defines the status of a light regarding the volumetric lighting.
67
+ */
68
+ export interface IVolumetricLightStatus {
69
+ /**
70
+ * Defines the state of the light. @see VolumetricLightState
71
+ */
72
+ state: VolumetricLightState;
73
+ /**
74
+ * Defines the index of the shadowed slot used by the light, or -1.
75
+ */
76
+ slot: number;
77
+ /**
78
+ * Defines a human readable explanation of the state, drawn in the inspector of the light.
79
+ */
80
+ reason: string;
81
+ }
82
+ /**
83
+ * Defines the statistics of the last selection pass of the volumetric lighting rendering pipeline.
84
+ */
85
+ export interface IVolumetricLightingStats {
86
+ /**
87
+ * Defines the number of lights of the scene that have volumetric lighting enabled.
88
+ */
89
+ candidateCount: number;
90
+ /**
91
+ * Defines the number of candidates that were outside the frustum of the camera.
92
+ */
93
+ culledCount: number;
94
+ /**
95
+ * Defines the number of candidates that got a shadowed slot.
96
+ */
97
+ shadowedCount: number;
98
+ /**
99
+ * Defines the number of candidates that contribute without casting volumetric shadows.
100
+ */
101
+ unshadowedCount: number;
102
+ /**
103
+ * Defines the number of candidates that didn't fit in the budget of the shader.
104
+ */
105
+ droppedCount: number;
106
+ /**
107
+ * Defines the status of each candidate, keyed by the unique id of the light.
108
+ */
109
+ perLight: Map<number, IVolumetricLightStatus>;
110
+ }
111
+ /**
112
+ * Defines a light of the scene that has volumetric lighting enabled.
113
+ */
114
+ export interface IVolumetricLightCandidate {
115
+ light: Light;
116
+ config: IVolumetricLightConfiguration;
117
+ isClustered: boolean;
118
+ typeId: number;
119
+ score: number;
120
+ }
121
+ /**
122
+ * Defines the shadow map of a light, classified for the raymarching shader.
123
+ */
124
+ export interface IVolumetricShadowSlot {
125
+ generator: ShadowGenerator;
126
+ kind: VolumetricShadowKind;
127
+ mode: VolumetricShadowMode;
128
+ packed: boolean;
129
+ mapSize: number;
130
+ /**
131
+ * Defines wether or not the light of the slot has a bounded volume (point and spot lights). Those are
132
+ * integrated only over the part of the view ray crossing their volume, the others along the whole ray.
133
+ */
134
+ local: boolean;
135
+ }
136
+ /**
137
+ * Defines the result of a selection pass.
138
+ */
139
+ export interface IVolumetricLightSelection {
140
+ shadowed: {
141
+ candidate: IVolumetricLightCandidate;
142
+ shadow: IVolumetricShadowSlot;
143
+ }[];
144
+ /**
145
+ * Defines the lights evaluated without a shadow map. The first "directionalCount" entries are the
146
+ * directional lights, the point and spot lights follow.
147
+ */
148
+ unshadowed: IVolumetricLightCandidate[];
149
+ /**
150
+ * Defines the number of directional lights at the start of "unshadowed".
151
+ */
152
+ directionalCount: number;
153
+ csm: {
154
+ candidate: IVolumetricLightCandidate;
155
+ generator: CascadedShadowGenerator;
156
+ cascades: number;
157
+ kind: VolumetricShadowKind;
158
+ packed: boolean;
159
+ } | null;
160
+ stats: IVolumetricLightingStats;
161
+ }
162
+ /**
163
+ * Defines the number of lights the shader can be compiled for on the current engine.
164
+ */
165
+ export interface IVolumetricBudget {
166
+ maxShadowSlots: number;
167
+ maxArrayLights: number;
168
+ maxDirectionalLights: number;
169
+ allowCsm: boolean;
170
+ }
171
+ /**
172
+ * Computes the number of lights the raymarching shader can be compiled for, from the real capabilities
173
+ * of the engine rather than from a hardcoded guess.
174
+ * @param engine defines the reference to the engine to get its capabilities.
175
+ * @param configuration defines the configuration of the pipeline, used as an upper bound.
176
+ */
177
+ export declare function computeVolumetricBudget(engine: AbstractEngine, configuration: IVolumetricLightingConfiguration): IVolumetricBudget;
178
+ /**
179
+ * Returns the list of all the lights of the scene, including the ones that live inside a clustered light
180
+ * container. Adding a light to a container removes it from "scene.lights", so walking "scene.lights" alone
181
+ * misses exactly the lights this pipeline is meant to scale to.
182
+ * @param scene defines the reference to the scene to get its lights.
183
+ */
184
+ export declare function getAllVolumetricCandidateLights(scene: Scene): {
185
+ light: Light;
186
+ isClustered: boolean;
187
+ }[];
188
+ /**
189
+ * Returns the shadow generator of the given light classified for the raymarching shader, or null when the
190
+ * light has no shadow map that can be sampled by the volumetric pass.
191
+ * @param light defines the reference to the light to resolve its shadow map.
192
+ * @param scene defines the reference to the scene the light belongs to.
193
+ */
194
+ export declare function resolveVolumetricShadowSlot(light: Light, scene: Scene): IVolumetricShadowSlot | null;
195
+ /**
196
+ * Returns the world position of the given light, taking its parent into account.
197
+ * @param light defines the reference to the light to get its position.
198
+ * @param result defines the vector the position is written to.
199
+ */
200
+ export declare function getVolumetricLightWorldPosition(light: Light, result: Vector3): Vector3;
201
+ /**
202
+ * Returns the normalized world direction of the given light, taking its parent into account.
203
+ * @param light defines the reference to the light to get its direction.
204
+ * @param result defines the vector the direction is written to.
205
+ */
206
+ export declare function getVolumetricLightWorldDirection(light: Light, result: Vector3): Vector3;
207
+ /**
208
+ * Returns the radius of the volume reached by the given light, as used by the raymarching shader.
209
+ * "Light.range" defaults to Number.MAX_VALUE, anything past the reach of the march means no attenuation at all.
210
+ * @param light defines the reference to the light to get its radius.
211
+ * @param config defines the volumetric configuration of the light.
212
+ * @param configuration defines the configuration of the pipeline.
213
+ */
214
+ export declare function getVolumetricLightRange(light: Light, config: IVolumetricLightConfiguration, configuration: IVolumetricLightingConfiguration): number;
215
+ /**
216
+ * Selects the lights of the scene that contribute to the volumetric lighting for the given camera, splits
217
+ * them between the shadowed and the unshadowed tiers of the shader and reports why each one ended where it did.
218
+ * @param scene defines the reference to the scene to select the lights from.
219
+ * @param camera defines the reference to the camera the pipeline is attached to.
220
+ * @param configuration defines the configuration of the pipeline.
221
+ * @param budget defines the number of lights the shader can be compiled for.
222
+ * @param previous defines the result of the previous selection pass, used to keep the slots stable over time.
223
+ */
224
+ export declare function selectVolumetricLights(scene: Scene, camera: Camera, configuration: IVolumetricLightingConfiguration, budget: IVolumetricBudget, previous: IVolumetricLightSelection | null): IVolumetricLightSelection;
225
+ /**
226
+ * Defines everything that ends up in a "#define" of the raymarching shader. Any change to this key
227
+ * requires the shader to be recompiled, everything else is a simple uniform update.
228
+ */
229
+ export interface IVolumetricShaderEnvironment {
230
+ depthMode: 0 | 1 | 2;
231
+ ldrEncode: boolean;
232
+ reverseDepth: boolean;
233
+ ndcHalfZ: boolean;
234
+ fogMode: number;
235
+ transmittance: VolumetricTransmittanceMode;
236
+ /**
237
+ * Defines wether or not the linear depth of the scene is packed in an 8 bits RGBA texture because the
238
+ * engine can't render to a 32 bits float one.
239
+ */
240
+ linearDepthPacked: boolean;
241
+ /**
242
+ * Defines the size of the uniform arrays holding the lights evaluated without a shadow map. The number of
243
+ * lights actually stored in them is a uniform, which is what lets lights enter and leave the frustum of
244
+ * the camera without recompiling anything.
245
+ */
246
+ arrayLightCapacity: number;
247
+ /**
248
+ * Defines the number of samples taken across the volume of each point and spot light.
249
+ */
250
+ lightSteps: number;
251
+ }
252
+ /**
253
+ * Computes a key that changes whenever the raymarching shader must be recompiled.
254
+ * @param selection defines the result of the last selection pass.
255
+ * @param configuration defines the configuration of the pipeline.
256
+ * @param environment defines the state of the engine and of the scene the shader depends on.
257
+ */
258
+ export declare function computeVolumetricShapeKey(selection: IVolumetricLightSelection, configuration: IVolumetricLightingConfiguration, environment: IVolumetricShaderEnvironment): string;
259
+ /**
260
+ * Returns wether or not the given light can be used by the volumetric lighting rendering pipeline.
261
+ * @param light defines the reference to the light to check.
262
+ */
263
+ export declare function isVolumetricLightSupported(light: Light): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The linear depth pass. @see buildVolumetricLightingLinearDepthShader.
3
+ */
4
+ export declare function buildVolumetricLightingLinearDepthShaderWGSL(): string;
5
+ /**
6
+ * The raymarching pass. @see buildVolumetricLightingScatteringShader for what it computes.
7
+ * @param shadowSlotCount defines the number of shadowed light slots the shader is generated for.
8
+ */
9
+ export declare function buildVolumetricLightingScatteringShaderWGSL(shadowSlotCount: number): string;
10
+ /**
11
+ * The separable bilateral blur pass. @see buildVolumetricLightingBlurShader.
12
+ */
13
+ export declare function buildVolumetricLightingBlurShaderWGSL(): string;
14
+ /**
15
+ * The composition pass. @see buildVolumetricLightingComposeShader.
16
+ */
17
+ export declare function buildVolumetricLightingComposeShaderWGSL(): string;
18
+ /**
19
+ * Returns the four WGSL sources of the pipeline, keyed by the name they are registered under.
20
+ */
21
+ export declare function getVolumetricLightingShadersWGSL(): Record<string, string>;
@@ -0,0 +1,60 @@
1
+ import { ShaderLanguage } from "@babylonjs/core/Materials/shaderLanguage";
2
+ /**
3
+ * Defines the name of the linear depth shader in the shader store of Babylon.js.
4
+ */
5
+ export declare const volumetricLightingLinearDepthShaderName = "volumetricLightingLinearDepth";
6
+ /**
7
+ * Defines the name of the raymarching shader in the shader store of Babylon.js.
8
+ */
9
+ export declare const volumetricLightingScatteringShaderName = "volumetricLightingScattering";
10
+ /**
11
+ * Defines the name of the bilateral blur shader in the shader store of Babylon.js.
12
+ */
13
+ export declare const volumetricLightingBlurShaderName = "volumetricLightingBlur";
14
+ /**
15
+ * Defines the name of the composition shader in the shader store of Babylon.js.
16
+ */
17
+ export declare const volumetricLightingComposeShaderName = "volumetricLightingCompose";
18
+ /**
19
+ * The linear depth pass. It is the first pass of the pipeline, so its input is the untouched color of the
20
+ * scene that the composition reads back, and it writes the distance along the view axis of each pixel.
21
+ *
22
+ * Every later pass reads this texture instead of the depth map of the depth renderer: a single 32 bits
23
+ * channel is half the memory traffic of the 16 bits RGBA depth map, which matters for the thousands of reads
24
+ * of the depth-buffer occlusion, and it needs neither unpacking nor linearization. It is kept at the full
25
+ * resolution so the occlusion sees the geometry exactly as the surfaces of the scene draw it.
26
+ */
27
+ export declare function buildVolumetricLightingLinearDepthShader(): string;
28
+ /**
29
+ * The raymarching pass. Accumulates the single-scattering integral of every enabled light of the scene
30
+ * along the view ray, through the participating medium described by the configuration of the pipeline.
31
+ *
32
+ * The lights are not all marched together: a directional light lights the whole view ray and is marched
33
+ * along it, but a point or a spot light only reaches the part of the ray crossing its volume, so each one is
34
+ * integrated over that part alone, with samples of its own. A light the ray doesn't cross costs a single
35
+ * ray/volume intersection, and a small light gets as many samples as a big one instead of the few steps of
36
+ * the global march that happened to fall inside it.
37
+ *
38
+ * The result is written as (rgb = in-scattered radiance, a = transmittance of the medium at the end of the ray).
39
+ * @param shadowSlotCount defines the number of shadowed light slots the shader is generated for.
40
+ */
41
+ export declare function buildVolumetricLightingScatteringShader(shadowSlotCount: number): string;
42
+ /**
43
+ * The separable bilateral blur pass. Denoises the low resolution scattering buffer without letting the
44
+ * light shafts bleed across the silhouettes of the geometry.
45
+ */
46
+ export declare function buildVolumetricLightingBlurShader(): string;
47
+ /**
48
+ * The composition pass. Upsamples the low resolution scattering buffer using a depth aware filter and
49
+ * adds it to the color of the scene.
50
+ */
51
+ export declare function buildVolumetricLightingComposeShader(): string;
52
+ /**
53
+ * Registers the shaders of the volumetric lighting rendering pipeline in the shader store of Babylon.js.
54
+ * Calling this function multiple times for the same language has no effect.
55
+ *
56
+ * The WGSL sources are hand written rather than transpiled from the GLSL ones: Babylon.js can only convert
57
+ * GLSL to WGSL by downloading twgsl from its CDN, which an offline application can't rely on.
58
+ * @param shaderLanguage defines the language the shaders are registered for.
59
+ */
60
+ export declare function registerVolumetricLightingShaders(shaderLanguage: ShaderLanguage): void;