@onerjs/core 8.26.4 → 8.26.5
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.
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +6 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +2 -1
- package/FrameGraph/frameGraphContext.js +4 -1
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +4 -5
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Lights/pointLight.js +4 -4
- package/Lights/pointLight.js.map +1 -1
- package/Lights/rectAreaLight.js +4 -4
- package/Lights/rectAreaLight.js.map +1 -1
- package/Lights/spotLight.js +2 -2
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.d.ts +19 -91
- package/Materials/Background/backgroundMaterial.js +17 -245
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +15 -4
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +28 -5
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +57 -69
- package/Materials/Node/nodeMaterial.js +9 -86
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +3 -1
- package/Materials/Node/nodeMaterialBuildState.js +35 -15
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/index.d.ts +5 -0
- package/Materials/PBR/index.js +5 -0
- package/Materials/PBR/index.js.map +1 -1
- package/Materials/PBR/openPbrMaterial.d.ts +998 -0
- package/Materials/PBR/openPbrMaterial.js +2069 -0
- package/Materials/PBR/openPbrMaterial.js.map +1 -0
- package/Materials/PBR/pbrBaseMaterial.d.ts +57 -43
- package/Materials/PBR/pbrBaseMaterial.js +21 -304
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +0 -78
- package/Materials/PBR/pbrMaterial.js +0 -110
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +3 -0
- package/Materials/floatingOriginMatrixOverrides.js +91 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -0
- package/Materials/imageProcessing.d.ts +65 -0
- package/Materials/imageProcessing.js +162 -0
- package/Materials/imageProcessing.js.map +1 -0
- package/Materials/imageProcessingConfiguration.defines.d.ts +25 -0
- package/Materials/imageProcessingConfiguration.defines.js +27 -0
- package/Materials/imageProcessingConfiguration.defines.js.map +1 -1
- package/Materials/index.d.ts +2 -0
- package/Materials/index.js +2 -0
- package/Materials/index.js.map +1 -1
- package/Materials/material.d.ts +14 -0
- package/Materials/material.js +14 -0
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +53 -0
- package/Materials/materialHelper.functions.js +297 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +57 -121
- package/Materials/standardMaterial.js +21 -250
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uv.defines.d.ts +22 -0
- package/Materials/uv.defines.js +24 -0
- package/Materials/uv.defines.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/decorators.d.ts +7 -0
- package/Misc/decorators.js +34 -0
- package/Misc/decorators.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +10 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +2 -0
- package/Particles/Node/Blocks/index.js +2 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +4 -1
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.d.ts +38 -0
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +108 -0
- package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.d.ts +26 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.js +50 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +2 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +45 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +6 -4
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +28 -20
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/reflectiveShadowMap.d.ts +3 -3
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +3 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +34 -0
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/importanceSampling.js +4 -0
- package/Shaders/ShadersInclude/importanceSampling.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +3 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrHelperFunctions.js +2 -0
- package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/backgroundUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +28 -0
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/importanceSampling.js +4 -0
- package/ShadersWGSL/ShadersInclude/importanceSampling.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +3 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +2 -0
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +21 -0
- package/scene.js +29 -3
- package/scene.js.map +1 -1
|
@@ -11,6 +11,7 @@ import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
|
11
11
|
import type { Material } from "./material.js";
|
|
12
12
|
import type { Nullable } from "../types.js";
|
|
13
13
|
import type { MorphTargetManager } from "../Morph/morphTargetManager.js";
|
|
14
|
+
import { Color3 } from "../Maths/math.color.js";
|
|
14
15
|
/**
|
|
15
16
|
* Binds the logarithmic depth information from the scene to the effect for the given defines.
|
|
16
17
|
* @param defines The generated defines used in the effect
|
|
@@ -74,6 +75,30 @@ export declare function BindMorphTargetParameters(abstractMesh: AbstractMesh, ef
|
|
|
74
75
|
* @param sceneUbo defines the uniform buffer storing scene data
|
|
75
76
|
*/
|
|
76
77
|
export declare function BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
|
|
78
|
+
/**
|
|
79
|
+
* Update parameters for IBL
|
|
80
|
+
* @param scene The scene
|
|
81
|
+
* @param defines The list of shader defines for the material
|
|
82
|
+
* @param ubo The uniform buffer to update
|
|
83
|
+
* @param reflectionTexture The IBL texture
|
|
84
|
+
* @param realTimeFiltering Whether realtime filtering of IBL texture is being used
|
|
85
|
+
* @param supportTextureInfo Whether the texture info is supported
|
|
86
|
+
* @param supportLocalProjection Whether local projection is supported
|
|
87
|
+
* @param usePBR Whether PBR is being used
|
|
88
|
+
* @param supportSH Whether spherical harmonics are supported
|
|
89
|
+
* @param useColor Whether to use the reflection color
|
|
90
|
+
* @param reflectionColor The color to use for the reflection
|
|
91
|
+
*/
|
|
92
|
+
export declare function BindIBLParameters(scene: Scene, defines: any, ubo: UniformBuffer, reflectionTexture?: Nullable<BaseTexture>, realTimeFiltering?: boolean, supportTextureInfo?: boolean, supportLocalProjection?: boolean, usePBR?: boolean, supportSH?: boolean, useColor?: boolean, reflectionColor?: Color3): void;
|
|
93
|
+
/**
|
|
94
|
+
* Update parameters for IBL
|
|
95
|
+
* @param scene The scene
|
|
96
|
+
* @param defines The list of shader defines for the material
|
|
97
|
+
* @param ubo The uniform buffer to update
|
|
98
|
+
* @param reflectionTexture The IBL texture
|
|
99
|
+
* @param realTimeFiltering Whether realtime filtering of IBL texture is being used
|
|
100
|
+
*/
|
|
101
|
+
export declare function BindIBLSamplers(scene: Scene, defines: any, ubo: UniformBuffer, reflectionTexture?: Nullable<BaseTexture>, realTimeFiltering?: boolean): void;
|
|
77
102
|
/**
|
|
78
103
|
* Helps preparing the defines values about the UVs in used in the effect.
|
|
79
104
|
* UVs are shared as much as we can across channels in the shaders.
|
|
@@ -185,6 +210,17 @@ export declare function PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene,
|
|
|
185
210
|
* @returns true if normals will be required for the rest of the effect
|
|
186
211
|
*/
|
|
187
212
|
export declare function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Prepare defines relating to IBL logic.
|
|
215
|
+
* @param scene The scene
|
|
216
|
+
* @param reflectionTexture The texture to use for IBL
|
|
217
|
+
* @param defines The defines to update
|
|
218
|
+
* @param realTimeFiltering Whether realtime filting of IBL texture is being used
|
|
219
|
+
* @param realTimeFilteringQuality The quality of realtime filtering
|
|
220
|
+
* @param forceSHInVertex Whether the SH are handled in the vertex shader
|
|
221
|
+
* @returns true if the defines were updated
|
|
222
|
+
*/
|
|
223
|
+
export declare function PrepareDefinesForIBL(scene: Scene, reflectionTexture: Nullable<BaseTexture>, defines: any, realTimeFiltering?: boolean, realTimeFilteringQuality?: number, forceSHInVertex?: boolean): boolean;
|
|
188
224
|
/**
|
|
189
225
|
* Prepares the defines related to the light information passed in parameter
|
|
190
226
|
* @param scene The scene we are intending to draw
|
|
@@ -287,6 +323,13 @@ export declare function PrepareDefinesForCamera(scene: Scene, defines: any): boo
|
|
|
287
323
|
* @param clusteredLightTextures defines if the clustered light textures must be used
|
|
288
324
|
*/
|
|
289
325
|
export declare function PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean, iesLightTexture?: boolean, clusteredLightTextures?: boolean): void;
|
|
326
|
+
/**
|
|
327
|
+
* Append uniforms and samplers related to IBL to the provided lists
|
|
328
|
+
* @param uniformsList The list of uniforms to append to
|
|
329
|
+
* @param samplersList The list of samplers to append to
|
|
330
|
+
* @param useSH Whether to include spherical harmonics uniforms
|
|
331
|
+
*/
|
|
332
|
+
export declare function PrepareUniformsAndSamplersForIBL(uniformsList: string[], samplersList: string[], useSH: boolean): void;
|
|
290
333
|
/**
|
|
291
334
|
* Prepares the uniforms and samplers list to be used in the effect
|
|
292
335
|
* @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
|
|
@@ -295,3 +338,13 @@ export declare function PrepareUniformsAndSamplersForLight(lightIndex: number, u
|
|
|
295
338
|
* @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
|
|
296
339
|
*/
|
|
297
340
|
export declare function PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
|
|
341
|
+
/**
|
|
342
|
+
*
|
|
343
|
+
* @param ubo Add uniforms to UBO
|
|
344
|
+
* @param supportTextureInfo Add uniforms for texture info if true
|
|
345
|
+
* @param supportLocalProjection Add uniforms for local projection if true
|
|
346
|
+
* @param usePBR Add uniforms for IBL if true
|
|
347
|
+
* @param supportSH Add uniforms for spherical harmonics if true
|
|
348
|
+
* @param useColor Add uniforms for reflection color if true
|
|
349
|
+
*/
|
|
350
|
+
export declare function PrepareUniformLayoutForIBL(ubo: UniformBuffer, supportTextureInfo?: boolean, supportLocalProjection?: boolean, usePBR?: boolean, supportSH?: boolean, useColor?: boolean): void;
|
|
@@ -3,6 +3,9 @@ import { Logger } from "../Misc/logger.js";
|
|
|
3
3
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
4
4
|
import { LightConstants } from "../Lights/lightConstants.js";
|
|
5
5
|
import { PrepareDefinesForClipPlanes } from "./clipPlaneMaterialHelper.js";
|
|
6
|
+
import { MaterialFlags } from "./materialFlags.js";
|
|
7
|
+
import { Texture } from "./Textures/texture.js";
|
|
8
|
+
import { Color3 } from "../Maths/math.color.js";
|
|
6
9
|
// Temps
|
|
7
10
|
const TempFogColor = { r: 0, g: 0, b: 0 };
|
|
8
11
|
const TmpMorphInfluencers = {
|
|
@@ -215,6 +218,105 @@ export function BindMorphTargetParameters(abstractMesh, effect) {
|
|
|
215
218
|
export function BindSceneUniformBuffer(effect, sceneUbo) {
|
|
216
219
|
sceneUbo.bindToEffect(effect, "Scene");
|
|
217
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Update parameters for IBL
|
|
223
|
+
* @param scene The scene
|
|
224
|
+
* @param defines The list of shader defines for the material
|
|
225
|
+
* @param ubo The uniform buffer to update
|
|
226
|
+
* @param reflectionTexture The IBL texture
|
|
227
|
+
* @param realTimeFiltering Whether realtime filtering of IBL texture is being used
|
|
228
|
+
* @param supportTextureInfo Whether the texture info is supported
|
|
229
|
+
* @param supportLocalProjection Whether local projection is supported
|
|
230
|
+
* @param usePBR Whether PBR is being used
|
|
231
|
+
* @param supportSH Whether spherical harmonics are supported
|
|
232
|
+
* @param useColor Whether to use the reflection color
|
|
233
|
+
* @param reflectionColor The color to use for the reflection
|
|
234
|
+
*/
|
|
235
|
+
export function BindIBLParameters(scene, defines, ubo, reflectionTexture = null, realTimeFiltering = false, supportTextureInfo = false, supportLocalProjection = false, usePBR = false, supportSH = false, useColor = false, reflectionColor = Color3.White()) {
|
|
236
|
+
if (scene.texturesEnabled) {
|
|
237
|
+
if (reflectionTexture && MaterialFlags.ReflectionTextureEnabled) {
|
|
238
|
+
ubo.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
|
|
239
|
+
ubo.updateFloat2("vReflectionInfos", reflectionTexture.level * scene.iblIntensity, 0);
|
|
240
|
+
if (supportLocalProjection && reflectionTexture.boundingBoxSize) {
|
|
241
|
+
const cubeTexture = reflectionTexture;
|
|
242
|
+
ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
|
|
243
|
+
ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
|
|
244
|
+
}
|
|
245
|
+
if (realTimeFiltering) {
|
|
246
|
+
const width = reflectionTexture.getSize().width;
|
|
247
|
+
ubo.updateFloat2("vReflectionFilteringInfo", width, Math.log2(width));
|
|
248
|
+
}
|
|
249
|
+
if (supportSH && !defines.USEIRRADIANCEMAP) {
|
|
250
|
+
const polynomials = reflectionTexture.sphericalPolynomial;
|
|
251
|
+
if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
|
|
252
|
+
if (defines.SPHERICAL_HARMONICS) {
|
|
253
|
+
const preScaledHarmonics = polynomials.preScaledHarmonics;
|
|
254
|
+
ubo.updateVector3("vSphericalL00", preScaledHarmonics.l00);
|
|
255
|
+
ubo.updateVector3("vSphericalL1_1", preScaledHarmonics.l1_1);
|
|
256
|
+
ubo.updateVector3("vSphericalL10", preScaledHarmonics.l10);
|
|
257
|
+
ubo.updateVector3("vSphericalL11", preScaledHarmonics.l11);
|
|
258
|
+
ubo.updateVector3("vSphericalL2_2", preScaledHarmonics.l2_2);
|
|
259
|
+
ubo.updateVector3("vSphericalL2_1", preScaledHarmonics.l2_1);
|
|
260
|
+
ubo.updateVector3("vSphericalL20", preScaledHarmonics.l20);
|
|
261
|
+
ubo.updateVector3("vSphericalL21", preScaledHarmonics.l21);
|
|
262
|
+
ubo.updateVector3("vSphericalL22", preScaledHarmonics.l22);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
ubo.updateFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
|
|
266
|
+
ubo.updateFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
|
|
267
|
+
ubo.updateFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
|
|
268
|
+
ubo.updateFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
|
|
269
|
+
ubo.updateFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
|
|
270
|
+
ubo.updateFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
|
|
271
|
+
ubo.updateFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
|
|
272
|
+
ubo.updateFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
|
|
273
|
+
ubo.updateFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else if (usePBR) {
|
|
278
|
+
// If we're using an irradiance map with a dominant direction assigned, set it.
|
|
279
|
+
if (defines.USEIRRADIANCEMAP && defines.USE_IRRADIANCE_DOMINANT_DIRECTION) {
|
|
280
|
+
ubo.updateVector3("vReflectionDominantDirection", reflectionTexture.irradianceTexture._dominantDirection);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (supportTextureInfo) {
|
|
284
|
+
ubo.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (useColor) {
|
|
289
|
+
ubo.updateColor3("vReflectionColor", reflectionColor);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Update parameters for IBL
|
|
294
|
+
* @param scene The scene
|
|
295
|
+
* @param defines The list of shader defines for the material
|
|
296
|
+
* @param ubo The uniform buffer to update
|
|
297
|
+
* @param reflectionTexture The IBL texture
|
|
298
|
+
* @param realTimeFiltering Whether realtime filtering of IBL texture is being used
|
|
299
|
+
*/
|
|
300
|
+
export function BindIBLSamplers(scene, defines, ubo, reflectionTexture = null, realTimeFiltering = false) {
|
|
301
|
+
if (reflectionTexture && MaterialFlags.ReflectionTextureEnabled) {
|
|
302
|
+
if (defines.LODBASEDMICROSFURACE) {
|
|
303
|
+
ubo.setTexture("reflectionSampler", reflectionTexture);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
ubo.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
|
|
307
|
+
ubo.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
|
|
308
|
+
ubo.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
|
|
309
|
+
}
|
|
310
|
+
if (defines.USEIRRADIANCEMAP) {
|
|
311
|
+
ubo.setTexture("irradianceSampler", reflectionTexture.irradianceTexture);
|
|
312
|
+
}
|
|
313
|
+
//if realtime filtering and using CDF maps, set them.
|
|
314
|
+
const cdfGenerator = scene.iblCdfGenerator;
|
|
315
|
+
if (realTimeFiltering && cdfGenerator) {
|
|
316
|
+
ubo.setTexture("icdfSampler", cdfGenerator.getIcdfTexture());
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
218
320
|
/**
|
|
219
321
|
* Helps preparing the defines values about the UVs in used in the effect.
|
|
220
322
|
* UVs are shared as much as we can across channels in the shaders.
|
|
@@ -515,6 +617,130 @@ export function PrepareDefinesForLights(scene, mesh, defines, specularSupported,
|
|
|
515
617
|
}
|
|
516
618
|
return state.needNormals;
|
|
517
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Prepare defines relating to IBL logic.
|
|
622
|
+
* @param scene The scene
|
|
623
|
+
* @param reflectionTexture The texture to use for IBL
|
|
624
|
+
* @param defines The defines to update
|
|
625
|
+
* @param realTimeFiltering Whether realtime filting of IBL texture is being used
|
|
626
|
+
* @param realTimeFilteringQuality The quality of realtime filtering
|
|
627
|
+
* @param forceSHInVertex Whether the SH are handled in the vertex shader
|
|
628
|
+
* @returns true if the defines were updated
|
|
629
|
+
*/
|
|
630
|
+
export function PrepareDefinesForIBL(scene, reflectionTexture, defines, realTimeFiltering = false, realTimeFilteringQuality = 8, forceSHInVertex = false) {
|
|
631
|
+
if (reflectionTexture && MaterialFlags.ReflectionTextureEnabled) {
|
|
632
|
+
if (!reflectionTexture.isReadyOrNotBlocking()) {
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
defines._needNormals = true;
|
|
636
|
+
defines.REFLECTION = true;
|
|
637
|
+
defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
|
|
638
|
+
defines.RGBDREFLECTION = reflectionTexture.isRGBD;
|
|
639
|
+
defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
|
|
640
|
+
defines.LINEARSPECULARREFLECTION = reflectionTexture.linearSpecularLOD;
|
|
641
|
+
defines.USEIRRADIANCEMAP = false;
|
|
642
|
+
const engine = scene.getEngine();
|
|
643
|
+
if (realTimeFiltering && realTimeFilteringQuality > 0) {
|
|
644
|
+
defines.NUM_SAMPLES = "" + realTimeFilteringQuality;
|
|
645
|
+
if (engine._features.needTypeSuffixInShaderConstants) {
|
|
646
|
+
defines.NUM_SAMPLES = defines.NUM_SAMPLES + "u";
|
|
647
|
+
}
|
|
648
|
+
defines.REALTIME_FILTERING = true;
|
|
649
|
+
if (scene.iblCdfGenerator) {
|
|
650
|
+
defines.IBL_CDF_FILTERING = true;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
defines.REALTIME_FILTERING = false;
|
|
655
|
+
}
|
|
656
|
+
defines.INVERTCUBICMAP = reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE;
|
|
657
|
+
defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
|
|
658
|
+
defines.REFLECTIONMAP_OPPOSITEZ = defines.REFLECTIONMAP_3D && scene.useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
|
|
659
|
+
defines.REFLECTIONMAP_CUBIC = false;
|
|
660
|
+
defines.REFLECTIONMAP_EXPLICIT = false;
|
|
661
|
+
defines.REFLECTIONMAP_PLANAR = false;
|
|
662
|
+
defines.REFLECTIONMAP_PROJECTION = false;
|
|
663
|
+
defines.REFLECTIONMAP_SKYBOX = false;
|
|
664
|
+
defines.REFLECTIONMAP_SPHERICAL = false;
|
|
665
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
|
|
666
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
|
|
667
|
+
defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
|
|
668
|
+
switch (reflectionTexture.coordinatesMode) {
|
|
669
|
+
case Texture.EXPLICIT_MODE:
|
|
670
|
+
defines.REFLECTIONMAP_EXPLICIT = true;
|
|
671
|
+
break;
|
|
672
|
+
case Texture.PLANAR_MODE:
|
|
673
|
+
defines.REFLECTIONMAP_PLANAR = true;
|
|
674
|
+
break;
|
|
675
|
+
case Texture.PROJECTION_MODE:
|
|
676
|
+
defines.REFLECTIONMAP_PROJECTION = true;
|
|
677
|
+
break;
|
|
678
|
+
case Texture.SKYBOX_MODE:
|
|
679
|
+
defines.REFLECTIONMAP_SKYBOX = true;
|
|
680
|
+
break;
|
|
681
|
+
case Texture.SPHERICAL_MODE:
|
|
682
|
+
defines.REFLECTIONMAP_SPHERICAL = true;
|
|
683
|
+
break;
|
|
684
|
+
case Texture.EQUIRECTANGULAR_MODE:
|
|
685
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
|
|
686
|
+
break;
|
|
687
|
+
case Texture.FIXED_EQUIRECTANGULAR_MODE:
|
|
688
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
|
|
689
|
+
break;
|
|
690
|
+
case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
|
|
691
|
+
defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
|
|
692
|
+
break;
|
|
693
|
+
case Texture.CUBIC_MODE:
|
|
694
|
+
case Texture.INVCUBIC_MODE:
|
|
695
|
+
default:
|
|
696
|
+
defines.REFLECTIONMAP_CUBIC = true;
|
|
697
|
+
defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
if (reflectionTexture.coordinatesMode !== Texture.SKYBOX_MODE) {
|
|
701
|
+
if (reflectionTexture.irradianceTexture) {
|
|
702
|
+
defines.USEIRRADIANCEMAP = true;
|
|
703
|
+
defines.USESPHERICALFROMREFLECTIONMAP = false;
|
|
704
|
+
defines.USESPHERICALINVERTEX = false;
|
|
705
|
+
if (reflectionTexture.irradianceTexture._dominantDirection) {
|
|
706
|
+
defines.USE_IRRADIANCE_DOMINANT_DIRECTION = true;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Assume using spherical polynomial if the reflection texture is a cube map
|
|
710
|
+
else if (reflectionTexture.isCube) {
|
|
711
|
+
defines.USESPHERICALFROMREFLECTIONMAP = true;
|
|
712
|
+
defines.USEIRRADIANCEMAP = false;
|
|
713
|
+
defines.USE_IRRADIANCE_DOMINANT_DIRECTION = false;
|
|
714
|
+
defines.USESPHERICALINVERTEX = forceSHInVertex;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
defines.REFLECTION = false;
|
|
720
|
+
defines.REFLECTIONMAP_3D = false;
|
|
721
|
+
defines.REFLECTIONMAP_SPHERICAL = false;
|
|
722
|
+
defines.REFLECTIONMAP_PLANAR = false;
|
|
723
|
+
defines.REFLECTIONMAP_CUBIC = false;
|
|
724
|
+
defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
|
|
725
|
+
defines.REFLECTIONMAP_PROJECTION = false;
|
|
726
|
+
defines.REFLECTIONMAP_SKYBOX = false;
|
|
727
|
+
defines.REFLECTIONMAP_EXPLICIT = false;
|
|
728
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
|
|
729
|
+
defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
|
|
730
|
+
defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
|
|
731
|
+
defines.INVERTCUBICMAP = false;
|
|
732
|
+
defines.USESPHERICALFROMREFLECTIONMAP = false;
|
|
733
|
+
defines.USEIRRADIANCEMAP = false;
|
|
734
|
+
defines.USE_IRRADIANCE_DOMINANT_DIRECTION = false;
|
|
735
|
+
defines.USESPHERICALINVERTEX = false;
|
|
736
|
+
defines.REFLECTIONMAP_OPPOSITEZ = false;
|
|
737
|
+
defines.LODINREFLECTIONALPHA = false;
|
|
738
|
+
defines.GAMMAREFLECTION = false;
|
|
739
|
+
defines.RGBDREFLECTION = false;
|
|
740
|
+
defines.LINEARSPECULARREFLECTION = false;
|
|
741
|
+
}
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
518
744
|
/**
|
|
519
745
|
* Prepares the defines related to the light information passed in parameter
|
|
520
746
|
* @param scene The scene we are intending to draw
|
|
@@ -934,6 +1160,30 @@ export function PrepareUniformsAndSamplersForLight(lightIndex, uniformsList, sam
|
|
|
934
1160
|
samplersList.push("tileMaskTexture" + lightIndex);
|
|
935
1161
|
}
|
|
936
1162
|
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Append uniforms and samplers related to IBL to the provided lists
|
|
1165
|
+
* @param uniformsList The list of uniforms to append to
|
|
1166
|
+
* @param samplersList The list of samplers to append to
|
|
1167
|
+
* @param useSH Whether to include spherical harmonics uniforms
|
|
1168
|
+
*/
|
|
1169
|
+
export function PrepareUniformsAndSamplersForIBL(uniformsList, samplersList, useSH) {
|
|
1170
|
+
const iblUniforms = [
|
|
1171
|
+
"vReflectionMicrosurfaceInfos",
|
|
1172
|
+
"vReflectionDominantDirection",
|
|
1173
|
+
"reflectionMatrix",
|
|
1174
|
+
"vReflectionInfos",
|
|
1175
|
+
"vReflectionPosition",
|
|
1176
|
+
"vReflectionSize",
|
|
1177
|
+
"vReflectionColor",
|
|
1178
|
+
"vReflectionFilteringInfo",
|
|
1179
|
+
];
|
|
1180
|
+
if (useSH) {
|
|
1181
|
+
iblUniforms.push("vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vSphericalL00", "vSphericalL1_1", "vSphericalL10", "vSphericalL11", "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22");
|
|
1182
|
+
}
|
|
1183
|
+
uniformsList.push(...iblUniforms);
|
|
1184
|
+
const iblSamplers = ["reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "icdfSampler"];
|
|
1185
|
+
samplersList.push(...iblSamplers);
|
|
1186
|
+
}
|
|
937
1187
|
/**
|
|
938
1188
|
* Prepares the uniforms and samplers list to be used in the effect
|
|
939
1189
|
* @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
|
|
@@ -975,4 +1225,51 @@ export function PrepareUniformsAndSamplersList(uniformsListOrOptions, samplersLi
|
|
|
975
1225
|
samplersList.push("bakedVertexAnimationTexture");
|
|
976
1226
|
}
|
|
977
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
*
|
|
1230
|
+
* @param ubo Add uniforms to UBO
|
|
1231
|
+
* @param supportTextureInfo Add uniforms for texture info if true
|
|
1232
|
+
* @param supportLocalProjection Add uniforms for local projection if true
|
|
1233
|
+
* @param usePBR Add uniforms for IBL if true
|
|
1234
|
+
* @param supportSH Add uniforms for spherical harmonics if true
|
|
1235
|
+
* @param useColor Add uniforms for reflection color if true
|
|
1236
|
+
*/
|
|
1237
|
+
export function PrepareUniformLayoutForIBL(ubo, supportTextureInfo = false, supportLocalProjection = false, usePBR = false, supportSH = false, useColor = false) {
|
|
1238
|
+
ubo.addUniform("vReflectionInfos", 2);
|
|
1239
|
+
ubo.addUniform("reflectionMatrix", 16);
|
|
1240
|
+
if (supportTextureInfo) {
|
|
1241
|
+
ubo.addUniform("vReflectionMicrosurfaceInfos", 3);
|
|
1242
|
+
}
|
|
1243
|
+
if (supportLocalProjection) {
|
|
1244
|
+
ubo.addUniform("vReflectionPosition", 3);
|
|
1245
|
+
ubo.addUniform("vReflectionSize", 3);
|
|
1246
|
+
}
|
|
1247
|
+
if (usePBR) {
|
|
1248
|
+
ubo.addUniform("vReflectionFilteringInfo", 2);
|
|
1249
|
+
ubo.addUniform("vReflectionDominantDirection", 3);
|
|
1250
|
+
}
|
|
1251
|
+
if (useColor) {
|
|
1252
|
+
ubo.addUniform("vReflectionColor", 3);
|
|
1253
|
+
}
|
|
1254
|
+
if (supportSH) {
|
|
1255
|
+
ubo.addUniform("vSphericalL00", 3);
|
|
1256
|
+
ubo.addUniform("vSphericalL1_1", 3);
|
|
1257
|
+
ubo.addUniform("vSphericalL10", 3);
|
|
1258
|
+
ubo.addUniform("vSphericalL11", 3);
|
|
1259
|
+
ubo.addUniform("vSphericalL2_2", 3);
|
|
1260
|
+
ubo.addUniform("vSphericalL2_1", 3);
|
|
1261
|
+
ubo.addUniform("vSphericalL20", 3);
|
|
1262
|
+
ubo.addUniform("vSphericalL21", 3);
|
|
1263
|
+
ubo.addUniform("vSphericalL22", 3);
|
|
1264
|
+
ubo.addUniform("vSphericalX", 3);
|
|
1265
|
+
ubo.addUniform("vSphericalY", 3);
|
|
1266
|
+
ubo.addUniform("vSphericalZ", 3);
|
|
1267
|
+
ubo.addUniform("vSphericalXX_ZZ", 3);
|
|
1268
|
+
ubo.addUniform("vSphericalYY_ZZ", 3);
|
|
1269
|
+
ubo.addUniform("vSphericalZZ", 3);
|
|
1270
|
+
ubo.addUniform("vSphericalXY", 3);
|
|
1271
|
+
ubo.addUniform("vSphericalYZ", 3);
|
|
1272
|
+
ubo.addUniform("vSphericalZX", 3);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
978
1275
|
//# sourceMappingURL=materialHelper.functions.js.map
|