@babylonjs/core 5.29.0 → 5.31.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.
- package/Cameras/cameraInputsManager.d.ts +2 -2
- package/Cameras/cameraInputsManager.js +5 -4
- package/Cameras/cameraInputsManager.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +1 -0
- package/Collisions/pickingInfo.js +7 -2
- package/Collisions/pickingInfo.js.map +1 -1
- package/Culling/ray.d.ts +1 -1
- package/Culling/ray.js +0 -6
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.d.ts +5 -0
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +5 -1
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Processors/iShaderProcessor.d.ts +4 -0
- package/Engines/Processors/iShaderProcessor.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +11 -2
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +4 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js +3 -7
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.d.ts +6 -0
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +36 -8
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.d.ts +1 -0
- package/Engines/WebGPU/webgpuTintWASM.js +7 -1
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +45 -12
- package/Engines/nativeEngine.js +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +6 -3
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +0 -2
- package/Engines/webgpuEngine.js +15 -14
- package/Engines/webgpuEngine.js.map +1 -1
- package/IAccessibilityTag.d.ts +29 -0
- package/IAccessibilityTag.js +2 -0
- package/IAccessibilityTag.js.map +1 -0
- package/Inputs/scene.inputManager.d.ts +1 -1
- package/Inputs/scene.inputManager.js +9 -2
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +3 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +19 -16
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +6 -2
- package/Lights/Shadows/shadowGenerator.js +32 -7
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGeneratorSceneComponent.js +16 -8
- package/Lights/Shadows/shadowGeneratorSceneComponent.js.map +1 -1
- package/Lights/light.d.ts +10 -3
- package/Lights/light.js +28 -6
- package/Lights/light.js.map +1 -1
- package/Lights/pointLight.js +6 -2
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +24 -3
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +92 -21
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +3 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +8 -2
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +4 -0
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +11 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +1 -0
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +7 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/materialHelper.js +2 -1
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +88 -20
- package/Maths/math.vector.js +88 -31
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.js +11 -7
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +3 -3
- package/Meshes/mesh.js +28 -19
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +1 -1
- package/Meshes/transformNode.js +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.d.ts +17 -4
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +49 -9
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/iInspectable.d.ts +5 -1
- package/Misc/iInspectable.js +4 -0
- package/Misc/iInspectable.js.map +1 -1
- package/Misc/index.d.ts +1 -1
- package/Misc/index.js +1 -1
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +41 -46
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/observable.js +4 -4
- package/Misc/observable.js.map +1 -1
- package/Misc/pressureObserverWrapper.d.ts +36 -0
- package/Misc/pressureObserverWrapper.js +68 -0
- package/Misc/pressureObserverWrapper.js.map +1 -0
- package/Misc/sceneRecorder.js +10 -4
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/screenshotTools.js +0 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Particles/particleSystem.d.ts +4 -0
- package/Particles/particleSystem.js +12 -4
- package/Particles/particleSystem.js.map +1 -1
- package/PostProcesses/postProcess.js +4 -4
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +4 -0
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/renderingManager.d.ts +3 -0
- package/Rendering/renderingManager.js +3 -0
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +3 -3
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +20 -15
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/fxaa.fragment.js +10 -5
- package/Shaders/fxaa.fragment.js.map +1 -1
- package/Shaders/particles.vertex.js +4 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/spriteMap.fragment.js +7 -2
- package/Shaders/spriteMap.fragment.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +1 -0
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/node.d.ts +8 -0
- package/node.js +13 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -8
- package/scene.js +1 -24
- package/scene.js.map +1 -1
- package/Misc/computePressure.d.ts +0 -57
- package/Misc/computePressure.js +0 -48
- package/Misc/computePressure.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderingManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/renderingManager.ts"],"names":[],"mappings":"AAIA,OAA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,sBAAsB,CAAC,gBAAgB,CAAC,GAAG;YAC5C,SAAS,EAAE,qBAAqB;YAChC,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,OAAO;SACnB,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACI,6BAA6B,CAAC,KAAa;QAC9C,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;;AApUD;;GAEG;AACW,oCAAmB,GAAG,CAAC,CAAC;AAEtC;;GAEG;AACW,oCAAmB,GAAG,CAAC,CAAC;AAEtC;;GAEG;AACW,0BAAS,GAAG,IAAI,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport type { ISpriteManager } from \"../Sprites/spriteManager\";\r\nimport type { IParticleSystem } from \"../Particles/IParticleSystem\";\r\nimport { RenderingGroup } from \"./renderingGroup\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Camera = import(\"../Cameras/camera\").Camera;\r\ndeclare type Material = import(\"../Materials/material\").Material;\r\ndeclare type SubMesh = import(\"../Meshes/subMesh\").SubMesh;\r\ndeclare type AbstractMesh = import(\"../Meshes/abstractMesh\").AbstractMesh;\r\n\r\n/**\r\n * Interface describing the different options available in the rendering manager\r\n * regarding Auto Clear between groups.\r\n */\r\nexport interface IRenderingManagerAutoClearSetup {\r\n /**\r\n * Defines whether or not autoclear is enable.\r\n */\r\n autoClear: boolean;\r\n /**\r\n * Defines whether or not to autoclear the depth buffer.\r\n */\r\n depth: boolean;\r\n /**\r\n * Defines whether or not to autoclear the stencil buffer.\r\n */\r\n stencil: boolean;\r\n}\r\n\r\n/**\r\n * This class is used by the onRenderingGroupObservable\r\n */\r\nexport class RenderingGroupInfo {\r\n /**\r\n * The Scene that being rendered\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * The camera currently used for the rendering pass\r\n */\r\n camera: Nullable<Camera>;\r\n\r\n /**\r\n * The ID of the renderingGroup being processed\r\n */\r\n renderingGroupId: number;\r\n}\r\n\r\n/**\r\n * This is the manager responsible of all the rendering for meshes sprites and particles.\r\n * It is enable to manage the different groups as well as the different necessary sort functions.\r\n * This should not be used directly aside of the few static configurations\r\n */\r\nexport class RenderingManager {\r\n /**\r\n * The max id used for rendering groups (not included)\r\n */\r\n public static MAX_RENDERINGGROUPS = 4;\r\n\r\n /**\r\n * The min id used for rendering groups (included)\r\n */\r\n public static MIN_RENDERINGGROUPS = 0;\r\n\r\n /**\r\n * Used to globally prevent autoclearing scenes.\r\n */\r\n public static AUTOCLEAR = true;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _useSceneAutoClearSetup = false;\r\n\r\n private _scene: Scene;\r\n private _renderingGroups = new Array<RenderingGroup>();\r\n private _depthStencilBufferAlreadyCleaned: boolean;\r\n\r\n private _autoClearDepthStencil: { [id: number]: IRenderingManagerAutoClearSetup } = {};\r\n private _customOpaqueSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customAlphaTestSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customTransparentSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _renderingGroupInfo: Nullable<RenderingGroupInfo> = new RenderingGroupInfo();\r\n\r\n private _maintainStateBetweenFrames = false;\r\n /**\r\n * Gets or sets a boolean indicating that the manager will not reset between frames.\r\n * This means that if a mesh becomes invisible or transparent it will not be visible until this boolean is set to false again.\r\n * By default, the rendering manager will dispatch all active meshes per frame (moving them to the transparent, opaque or alpha testing lists).\r\n * By turning this property on, you will accelerate the rendering by keeping all these lists unchanged between frames.\r\n */\r\n public get maintainStateBetweenFrames() {\r\n return this._maintainStateBetweenFrames;\r\n }\r\n\r\n public set maintainStateBetweenFrames(value: boolean) {\r\n if (value === this._maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n this._maintainStateBetweenFrames = value;\r\n\r\n // Restore wasDispatched flags when switching to maintainStateBetweenFrames to false\r\n if (!this._maintainStateBetweenFrames) {\r\n for (const mesh of this._scene.meshes) {\r\n if (mesh.subMeshes) {\r\n for (const subMesh of mesh.subMeshes) {\r\n subMesh._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n for (const spriteManager of this._scene.spriteManagers) {\r\n spriteManager._wasDispatched = false;\r\n }\r\n\r\n for (const particleSystem of this._scene.particleSystems) {\r\n particleSystem._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates a new rendering group for a particular scene\r\n * @param scene Defines the scene the groups belongs to\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n\r\n for (let i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {\r\n this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };\r\n }\r\n }\r\n\r\n public getRenderingGroup(id: number) {\r\n const renderingGroupId = id || 0;\r\n\r\n this._prepareRenderingGroup(renderingGroupId);\r\n\r\n return this._renderingGroups[renderingGroupId];\r\n }\r\n\r\n private _clearDepthStencilBuffer(depth = true, stencil = true): void {\r\n if (this._depthStencilBufferAlreadyCleaned) {\r\n return;\r\n }\r\n\r\n this._scene.getEngine().clear(null, false, depth, stencil);\r\n this._depthStencilBufferAlreadyCleaned = true;\r\n }\r\n\r\n /**\r\n * Renders the entire managed groups. This is used by the scene or the different render targets.\r\n * @internal\r\n */\r\n public render(\r\n customRenderFunction: Nullable<\r\n (\r\n opaqueSubMeshes: SmartArray<SubMesh>,\r\n transparentSubMeshes: SmartArray<SubMesh>,\r\n alphaTestSubMeshes: SmartArray<SubMesh>,\r\n depthOnlySubMeshes: SmartArray<SubMesh>\r\n ) => void\r\n >,\r\n activeMeshes: Nullable<AbstractMesh[]>,\r\n renderParticles: boolean,\r\n renderSprites: boolean\r\n ): void {\r\n // Update the observable context (not null as it only goes away on dispose)\r\n const info = this._renderingGroupInfo!;\r\n info.scene = this._scene;\r\n info.camera = this._scene.activeCamera;\r\n\r\n // Dispatch sprites\r\n if (this._scene.spriteManagers && renderSprites) {\r\n for (let index = 0; index < this._scene.spriteManagers.length; index++) {\r\n const manager = this._scene.spriteManagers[index];\r\n this.dispatchSprites(manager);\r\n }\r\n }\r\n\r\n // Render\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;\r\n const renderingGroup = this._renderingGroups[index];\r\n if (!renderingGroup || renderingGroup._empty) {\r\n continue;\r\n }\r\n\r\n const renderingGroupMask = Math.pow(2, index);\r\n info.renderingGroupId = index;\r\n\r\n // Before Observable\r\n this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n\r\n // Clear depth/stencil if needed\r\n if (RenderingManager.AUTOCLEAR) {\r\n const autoClear = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(index) : this._autoClearDepthStencil[index];\r\n\r\n if (autoClear && autoClear.autoClear) {\r\n this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);\r\n }\r\n }\r\n\r\n // Render\r\n for (const step of this._scene._beforeRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);\r\n for (const step of this._scene._afterRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n\r\n // After Observable\r\n this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n }\r\n }\r\n\r\n /**\r\n * Resets the different information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public reset(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepare();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Resets the sprites information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public resetSprites(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepareSprites();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the group and its associated resources.\r\n * @internal\r\n */\r\n public dispose(): void {\r\n this.freeRenderingGroups();\r\n this._renderingGroups.length = 0;\r\n this._renderingGroupInfo = null;\r\n }\r\n\r\n /**\r\n * Clear the info related to rendering groups preventing retention points during dispose.\r\n */\r\n public freeRenderingGroups(): void {\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _prepareRenderingGroup(renderingGroupId: number): void {\r\n if (this._renderingGroups[renderingGroupId] === undefined) {\r\n this._renderingGroups[renderingGroupId] = new RenderingGroup(\r\n renderingGroupId,\r\n this._scene,\r\n this._customOpaqueSortCompareFn[renderingGroupId],\r\n this._customAlphaTestSortCompareFn[renderingGroupId],\r\n this._customTransparentSortCompareFn[renderingGroupId]\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Add a sprite manager to the rendering manager in order to render it this frame.\r\n * @param spriteManager Define the sprite manager to render\r\n */\r\n public dispatchSprites(spriteManager: ISpriteManager) {\r\n if (this.maintainStateBetweenFrames && spriteManager._wasDispatched) {\r\n return;\r\n }\r\n spriteManager._wasDispatched = true;\r\n this.getRenderingGroup(spriteManager.renderingGroupId).dispatchSprites(spriteManager);\r\n }\r\n\r\n /**\r\n * Add a particle system to the rendering manager in order to render it this frame.\r\n * @param particleSystem Define the particle system to render\r\n */\r\n public dispatchParticles(particleSystem: IParticleSystem) {\r\n if (this.maintainStateBetweenFrames && particleSystem._wasDispatched) {\r\n return;\r\n }\r\n particleSystem._wasDispatched = true;\r\n this.getRenderingGroup(particleSystem.renderingGroupId).dispatchParticles(particleSystem);\r\n }\r\n\r\n /**\r\n * Add a submesh to the manager in order to render it this frame\r\n * @param subMesh The submesh to dispatch\r\n * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.\r\n * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.\r\n */\r\n public dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void {\r\n if (mesh === undefined) {\r\n mesh = subMesh.getMesh();\r\n }\r\n if (this.maintainStateBetweenFrames && subMesh._wasDispatched) {\r\n return;\r\n }\r\n subMesh._wasDispatched = true;\r\n this.getRenderingGroup(mesh.renderingGroupId).dispatch(subMesh, mesh, material);\r\n }\r\n\r\n /**\r\n * Overrides the default sort function applied in the rendering group to prepare the meshes.\r\n * This allowed control for front to back rendering or reversely depending of the special needs.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param opaqueSortCompareFn The opaque queue comparison function use to sort.\r\n * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.\r\n * @param transparentSortCompareFn The transparent queue comparison function use to sort.\r\n */\r\n public setRenderingOrder(\r\n renderingGroupId: number,\r\n opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null\r\n ) {\r\n this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;\r\n this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;\r\n this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;\r\n\r\n if (this._renderingGroups[renderingGroupId]) {\r\n const group = this._renderingGroups[renderingGroupId];\r\n group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];\r\n group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];\r\n group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];\r\n }\r\n }\r\n\r\n /**\r\n * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.\r\n * @param depth Automatically clears depth between groups if true and autoClear is true.\r\n * @param stencil Automatically clears stencil between groups if true and autoClear is true.\r\n */\r\n public setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth = true, stencil = true): void {\r\n this._autoClearDepthStencil[renderingGroupId] = {\r\n autoClear: autoClearDepthStencil,\r\n depth: depth,\r\n stencil: stencil,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current auto clear configuration for one rendering group of the rendering\r\n * manager.\r\n * @param index the rendering group index to get the information for\r\n * @returns The auto clear setup for the requested rendering group\r\n */\r\n public getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup {\r\n return this._autoClearDepthStencil[index];\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"renderingManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/renderingManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2BlD;;GAEG;AACH,MAAM,OAAO,kBAAkB;CAe9B;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAqEzB;;;OAGG;IACH,YAAY,KAAY;QAzDxB;;WAEG;QACI,4BAAuB,GAAG,KAAK,CAAC;QAG/B,qBAAgB,GAAG,IAAI,KAAK,EAAkB,CAAC;QAG/C,2BAAsB,GAAsD,EAAE,CAAC;QAC/E,+BAA0B,GAAmE,EAAE,CAAC;QAChG,kCAA6B,GAAmE,EAAE,CAAC;QACnG,oCAA+B,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AS,GAAG,IAAI,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport type { ISpriteManager } from \"../Sprites/spriteManager\";\r\nimport type { IParticleSystem } from \"../Particles/IParticleSystem\";\r\nimport { RenderingGroup } from \"./renderingGroup\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Camera = import(\"../Cameras/camera\").Camera;\r\ndeclare type Material = import(\"../Materials/material\").Material;\r\ndeclare type SubMesh = import(\"../Meshes/subMesh\").SubMesh;\r\ndeclare type AbstractMesh = import(\"../Meshes/abstractMesh\").AbstractMesh;\r\n\r\n/**\r\n * Interface describing the different options available in the rendering manager\r\n * regarding Auto Clear between groups.\r\n */\r\nexport interface IRenderingManagerAutoClearSetup {\r\n /**\r\n * Defines whether or not autoclear is enable.\r\n */\r\n autoClear: boolean;\r\n /**\r\n * Defines whether or not to autoclear the depth buffer.\r\n */\r\n depth: boolean;\r\n /**\r\n * Defines whether or not to autoclear the stencil buffer.\r\n */\r\n stencil: boolean;\r\n}\r\n\r\n/**\r\n * This class is used by the onRenderingGroupObservable\r\n */\r\nexport class RenderingGroupInfo {\r\n /**\r\n * The Scene that being rendered\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * The camera currently used for the rendering pass\r\n */\r\n camera: Nullable<Camera>;\r\n\r\n /**\r\n * The ID of the renderingGroup being processed\r\n */\r\n renderingGroupId: number;\r\n}\r\n\r\n/**\r\n * This is the manager responsible of all the rendering for meshes sprites and particles.\r\n * It is enable to manage the different groups as well as the different necessary sort functions.\r\n * This should not be used directly aside of the few static configurations\r\n */\r\nexport class RenderingManager {\r\n /**\r\n * The max id used for rendering groups (not included)\r\n */\r\n public static MAX_RENDERINGGROUPS = 4;\r\n\r\n /**\r\n * The min id used for rendering groups (included)\r\n */\r\n public static MIN_RENDERINGGROUPS = 0;\r\n\r\n /**\r\n * Used to globally prevent autoclearing scenes.\r\n */\r\n public static AUTOCLEAR = true;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _useSceneAutoClearSetup = false;\r\n\r\n private _scene: Scene;\r\n private _renderingGroups = new Array<RenderingGroup>();\r\n private _depthStencilBufferAlreadyCleaned: boolean;\r\n\r\n private _autoClearDepthStencil: { [id: number]: IRenderingManagerAutoClearSetup } = {};\r\n private _customOpaqueSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customAlphaTestSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customTransparentSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _renderingGroupInfo: Nullable<RenderingGroupInfo> = new RenderingGroupInfo();\r\n\r\n private _maintainStateBetweenFrames = false;\r\n /**\r\n * Gets or sets a boolean indicating that the manager will not reset between frames.\r\n * This means that if a mesh becomes invisible or transparent it will not be visible until this boolean is set to false again.\r\n * By default, the rendering manager will dispatch all active meshes per frame (moving them to the transparent, opaque or alpha testing lists).\r\n * By turning this property on, you will accelerate the rendering by keeping all these lists unchanged between frames.\r\n */\r\n public get maintainStateBetweenFrames() {\r\n return this._maintainStateBetweenFrames;\r\n }\r\n\r\n public set maintainStateBetweenFrames(value: boolean) {\r\n if (value === this._maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n this._maintainStateBetweenFrames = value;\r\n\r\n // Restore wasDispatched flags when switching to maintainStateBetweenFrames to false\r\n if (!this._maintainStateBetweenFrames) {\r\n for (const mesh of this._scene.meshes) {\r\n if (mesh.subMeshes) {\r\n for (const subMesh of mesh.subMeshes) {\r\n subMesh._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n for (const spriteManager of this._scene.spriteManagers) {\r\n spriteManager._wasDispatched = false;\r\n }\r\n\r\n for (const particleSystem of this._scene.particleSystems) {\r\n particleSystem._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates a new rendering group for a particular scene\r\n * @param scene Defines the scene the groups belongs to\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n\r\n for (let i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {\r\n this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };\r\n }\r\n }\r\n\r\n /**\r\n * Gets the rendering group with the specified id.\r\n */\r\n public getRenderingGroup(id: number): RenderingGroup {\r\n const renderingGroupId = id || 0;\r\n\r\n this._prepareRenderingGroup(renderingGroupId);\r\n\r\n return this._renderingGroups[renderingGroupId];\r\n }\r\n\r\n private _clearDepthStencilBuffer(depth = true, stencil = true): void {\r\n if (this._depthStencilBufferAlreadyCleaned) {\r\n return;\r\n }\r\n\r\n this._scene.getEngine().clear(null, false, depth, stencil);\r\n this._depthStencilBufferAlreadyCleaned = true;\r\n }\r\n\r\n /**\r\n * Renders the entire managed groups. This is used by the scene or the different render targets.\r\n * @internal\r\n */\r\n public render(\r\n customRenderFunction: Nullable<\r\n (\r\n opaqueSubMeshes: SmartArray<SubMesh>,\r\n transparentSubMeshes: SmartArray<SubMesh>,\r\n alphaTestSubMeshes: SmartArray<SubMesh>,\r\n depthOnlySubMeshes: SmartArray<SubMesh>\r\n ) => void\r\n >,\r\n activeMeshes: Nullable<AbstractMesh[]>,\r\n renderParticles: boolean,\r\n renderSprites: boolean\r\n ): void {\r\n // Update the observable context (not null as it only goes away on dispose)\r\n const info = this._renderingGroupInfo!;\r\n info.scene = this._scene;\r\n info.camera = this._scene.activeCamera;\r\n\r\n // Dispatch sprites\r\n if (this._scene.spriteManagers && renderSprites) {\r\n for (let index = 0; index < this._scene.spriteManagers.length; index++) {\r\n const manager = this._scene.spriteManagers[index];\r\n this.dispatchSprites(manager);\r\n }\r\n }\r\n\r\n // Render\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;\r\n const renderingGroup = this._renderingGroups[index];\r\n if (!renderingGroup || renderingGroup._empty) {\r\n continue;\r\n }\r\n\r\n const renderingGroupMask = Math.pow(2, index);\r\n info.renderingGroupId = index;\r\n\r\n // Before Observable\r\n this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n\r\n // Clear depth/stencil if needed\r\n if (RenderingManager.AUTOCLEAR) {\r\n const autoClear = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(index) : this._autoClearDepthStencil[index];\r\n\r\n if (autoClear && autoClear.autoClear) {\r\n this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);\r\n }\r\n }\r\n\r\n // Render\r\n for (const step of this._scene._beforeRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);\r\n for (const step of this._scene._afterRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n\r\n // After Observable\r\n this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n }\r\n }\r\n\r\n /**\r\n * Resets the different information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public reset(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepare();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Resets the sprites information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public resetSprites(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepareSprites();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the group and its associated resources.\r\n * @internal\r\n */\r\n public dispose(): void {\r\n this.freeRenderingGroups();\r\n this._renderingGroups.length = 0;\r\n this._renderingGroupInfo = null;\r\n }\r\n\r\n /**\r\n * Clear the info related to rendering groups preventing retention points during dispose.\r\n */\r\n public freeRenderingGroups(): void {\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _prepareRenderingGroup(renderingGroupId: number): void {\r\n if (this._renderingGroups[renderingGroupId] === undefined) {\r\n this._renderingGroups[renderingGroupId] = new RenderingGroup(\r\n renderingGroupId,\r\n this._scene,\r\n this._customOpaqueSortCompareFn[renderingGroupId],\r\n this._customAlphaTestSortCompareFn[renderingGroupId],\r\n this._customTransparentSortCompareFn[renderingGroupId]\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Add a sprite manager to the rendering manager in order to render it this frame.\r\n * @param spriteManager Define the sprite manager to render\r\n */\r\n public dispatchSprites(spriteManager: ISpriteManager) {\r\n if (this.maintainStateBetweenFrames && spriteManager._wasDispatched) {\r\n return;\r\n }\r\n spriteManager._wasDispatched = true;\r\n this.getRenderingGroup(spriteManager.renderingGroupId).dispatchSprites(spriteManager);\r\n }\r\n\r\n /**\r\n * Add a particle system to the rendering manager in order to render it this frame.\r\n * @param particleSystem Define the particle system to render\r\n */\r\n public dispatchParticles(particleSystem: IParticleSystem) {\r\n if (this.maintainStateBetweenFrames && particleSystem._wasDispatched) {\r\n return;\r\n }\r\n particleSystem._wasDispatched = true;\r\n this.getRenderingGroup(particleSystem.renderingGroupId).dispatchParticles(particleSystem);\r\n }\r\n\r\n /**\r\n * Add a submesh to the manager in order to render it this frame\r\n * @param subMesh The submesh to dispatch\r\n * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.\r\n * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.\r\n */\r\n public dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void {\r\n if (mesh === undefined) {\r\n mesh = subMesh.getMesh();\r\n }\r\n if (this.maintainStateBetweenFrames && subMesh._wasDispatched) {\r\n return;\r\n }\r\n subMesh._wasDispatched = true;\r\n this.getRenderingGroup(mesh.renderingGroupId).dispatch(subMesh, mesh, material);\r\n }\r\n\r\n /**\r\n * Overrides the default sort function applied in the rendering group to prepare the meshes.\r\n * This allowed control for front to back rendering or reversely depending of the special needs.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param opaqueSortCompareFn The opaque queue comparison function use to sort.\r\n * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.\r\n * @param transparentSortCompareFn The transparent queue comparison function use to sort.\r\n */\r\n public setRenderingOrder(\r\n renderingGroupId: number,\r\n opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null\r\n ) {\r\n this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;\r\n this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;\r\n this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;\r\n\r\n if (this._renderingGroups[renderingGroupId]) {\r\n const group = this._renderingGroups[renderingGroupId];\r\n group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];\r\n group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];\r\n group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];\r\n }\r\n }\r\n\r\n /**\r\n * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.\r\n * @param depth Automatically clears depth between groups if true and autoClear is true.\r\n * @param stencil Automatically clears stencil between groups if true and autoClear is true.\r\n */\r\n public setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth = true, stencil = true): void {\r\n this._autoClearDepthStencil[renderingGroupId] = {\r\n autoClear: autoClearDepthStencil,\r\n depth: depth,\r\n stencil: stencil,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current auto clear configuration for one rendering group of the rendering\r\n * manager.\r\n * @param index the rendering group index to get the information for\r\n * @returns The auto clear setup for the requested rendering group\r\n */\r\n public getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup {\r\n return this._autoClearDepthStencil[index];\r\n }\r\n}\r\n"]}
|
|
@@ -3,11 +3,11 @@ import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
|
3
3
|
const name = "hdrFilteringFunctions";
|
|
4
4
|
const shader = `#ifdef NUM_SAMPLES
|
|
5
5
|
#if NUM_SAMPLES>0
|
|
6
|
-
#if defined(WEBGL2) || defined(WEBGPU)
|
|
6
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
7
7
|
float radicalInverse_VdC(uint bits)
|
|
8
8
|
float vanDerCorpus(int n,int base)
|
|
9
9
|
float log4(float x) {
|
|
10
|
-
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
|
10
|
+
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
|
11
11
|
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
12
12
|
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@ c=toLinearSpace(c);
|
|
|
15
15
|
result+=c;
|
|
16
16
|
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
|
17
17
|
c=toLinearSpace(c);
|
|
18
|
-
return c;
|
|
18
|
+
return c;
|
|
19
19
|
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
20
20
|
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
21
21
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwId,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU)\nfloat radicalInverse_VdC(uint bits) \r{\rbits=(bits<<16u) | (bits>>16u);\rbits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);\rbits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);\rbits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);\rbits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);\rreturn float(bits)*2.3283064365386963e-10; \r}\rvec2 hammersley(uint i,uint N)\r{\rreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\r}\r#else\nfloat vanDerCorpus(int n,int base)\r{\rfloat invBase=1.0/float(base);\rfloat denom =1.0;\rfloat result =0.0;\rfor(int i=0; i<32; ++i)\r{\rif(n>0)\r{\rdenom =mod(float(n),2.0);\rresult+=denom*invBase;\rinvBase=invBase/2.0;\rn =int(float(n)/2.0);\r}\r}\rreturn result;\r}\rvec2 hammersley(int i,int N)\r{\rreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\r}\r#endif\nfloat log4(float x) {\rreturn log2(x)/2.;\r}\rconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\rconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\rconst float K=4.;\r#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\r{\rvec3 n=normalize(inputN);\rvec3 result=vec3(0.0);\rvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\rtangent=normalize(cross(tangent,n));\rvec3 bitangent=cross(n,tangent);\rmat3 tbn=mat3(tangent,bitangent,n);\rfloat maxLevel=filteringInfo.y;\rfloat dim0=filteringInfo.x;\rfloat omegaP=(4.*PI)/(6.*dim0*dim0);\r#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\r#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\r#endif\n{\rvec2 Xi=hammersley(i,NUM_SAMPLES);\rvec3 Ls=hemisphereCosSample(Xi);\rLs=normalize(Ls);\rvec3 Ns=vec3(0.,0.,1.);\rfloat NoL=dot(Ns,Ls);\rif (NoL>0.) {\rfloat pdf_inversed=PI/NoL;\rfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\rfloat l=log4(omegaS)-log4(omegaP)+log4(K);\rfloat mipLevel=clamp(l,0.0,maxLevel);\rvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nresult+=c;\r}\r}\rresult=result*NUM_SAMPLES_FLOAT_INVERSED;\rreturn result;\r}\r#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\r{\rvec3 n=normalize(inputN);\rif (alphaG==0.) {\rvec3 c=textureCube(inputTexture,n).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nreturn c;\r} else {\rvec3 result=vec3(0.);\rvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\rtangent=normalize(cross(tangent,n));\rvec3 bitangent=cross(n,tangent);\rmat3 tbn=mat3(tangent,bitangent,n);\rfloat maxLevel=filteringInfo.y;\rfloat dim0=filteringInfo.x;\rfloat omegaP=(4.*PI)/(6.*dim0*dim0);\rfloat weight=0.;\r#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\r#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\r#endif\n{\rvec2 Xi=hammersley(i,NUM_SAMPLES);\rvec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);\rfloat NoV=1.;\rfloat NoH=H.z;\rfloat NoH2=H.z*H.z;\rfloat NoL=2.*NoH2-1.;\rvec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);\rL=normalize(L);\rif (NoL>0.) {\rfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\rfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\rfloat l=log4(omegaS)-log4(omegaP)+log4(K);\rfloat mipLevel=clamp(float(l),0.0,maxLevel);\rweight+=NoL;\rvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nresult+=c*NoL;\r}\r}\rresult=result/weight;\rreturn result;\r}\r}\r#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const hdrFilteringFunctions = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwId,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfloat radicalInverse_VdC(uint bits) \r{\rbits=(bits<<16u) | (bits>>16u);\rbits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);\rbits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);\rbits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);\rbits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);\rreturn float(bits)*2.3283064365386963e-10; \r}\rvec2 hammersley(uint i,uint N)\r{\rreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\r}\r#else\nfloat vanDerCorpus(int n,int base)\r{\rfloat invBase=1.0/float(base);\rfloat denom =1.0;\rfloat result =0.0;\rfor(int i=0; i<32; ++i)\r{\rif(n>0)\r{\rdenom =mod(float(n),2.0);\rresult+=denom*invBase;\rinvBase=invBase/2.0;\rn =int(float(n)/2.0);\r}\r}\rreturn result;\r}\rvec2 hammersley(int i,int N)\r{\rreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\r}\r#endif\nfloat log4(float x) {\rreturn log2(x)/2.;\r}\rconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\rconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\rconst float K=4.;\r#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\r{\rvec3 n=normalize(inputN);\rvec3 result=vec3(0.0);\rvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\rtangent=normalize(cross(tangent,n));\rvec3 bitangent=cross(n,tangent);\rmat3 tbn=mat3(tangent,bitangent,n);\rfloat maxLevel=filteringInfo.y;\rfloat dim0=filteringInfo.x;\rfloat omegaP=(4.*PI)/(6.*dim0*dim0);\r#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\r#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\r#endif\n{\rvec2 Xi=hammersley(i,NUM_SAMPLES);\rvec3 Ls=hemisphereCosSample(Xi);\rLs=normalize(Ls);\rvec3 Ns=vec3(0.,0.,1.);\rfloat NoL=dot(Ns,Ls);\rif (NoL>0.) {\rfloat pdf_inversed=PI/NoL;\rfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\rfloat l=log4(omegaS)-log4(omegaP)+log4(K);\rfloat mipLevel=clamp(l,0.0,maxLevel);\rvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nresult+=c;\r}\r}\rresult=result*NUM_SAMPLES_FLOAT_INVERSED;\rreturn result;\r}\r#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\r{\rvec3 n=normalize(inputN);\rif (alphaG==0.) {\rvec3 c=textureCube(inputTexture,n).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nreturn c;\r} else {\rvec3 result=vec3(0.);\rvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\rtangent=normalize(cross(tangent,n));\rvec3 bitangent=cross(n,tangent);\rmat3 tbn=mat3(tangent,bitangent,n);\rfloat maxLevel=filteringInfo.y;\rfloat dim0=filteringInfo.x;\rfloat omegaP=(4.*PI)/(6.*dim0*dim0);\rfloat weight=0.;\r#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\r#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\r#endif\n{\rvec2 Xi=hammersley(i,NUM_SAMPLES);\rvec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);\rfloat NoV=1.;\rfloat NoH=H.z;\rfloat NoH2=H.z*H.z;\rfloat NoL=2.*NoH2-1.;\rvec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);\rL=normalize(L);\rif (NoL>0.) {\rfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\rfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\rfloat l=log4(omegaS)-log4(omegaP)+log4(K);\rfloat mipLevel=clamp(float(l),0.0,maxLevel);\rweight+=NoL;\rvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\r#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\r#endif\nresult+=c*NoL;\r}\r}\rresult=result/weight;\rreturn result;\r}\r}\r#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const hdrFilteringFunctions = { name, shader };\n"]}
|
|
@@ -6,10 +6,10 @@ const shader = `const float PI=3.1415926535897932384626433832795;
|
|
|
6
6
|
#define maxEps(x) max(x,Epsilon)
|
|
7
7
|
#define saturateEps(x) clamp(x,Epsilon,1.0)
|
|
8
8
|
mat3 transposeMat3(mat3 inMatrix) {
|
|
9
|
-
vec3 toLinearSpaceExact(vec3 color)
|
|
9
|
+
vec3 toLinearSpaceExact(vec3 color)
|
|
10
10
|
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));
|
|
11
11
|
return
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));
|
|
14
14
|
return
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/helperFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmKd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"helperFunctions\";\nconst shader = `const float PI=3.1415926535897932384626433832795;\rconst float HALF_MIN=5.96046448e-08; \rconst float LinearEncodePowerApprox=2.2;\rconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\rconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\rconst float Epsilon=0.0000001;\r#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\rvec3 i0=inMatrix[0];\rvec3 i1=inMatrix[1];\rvec3 i2=inMatrix[2];\rmat3 outMatrix=mat3(\rvec3(i0.x,i1.x,i2.x),\rvec3(i0.y,i1.y,i2.y),\rvec3(i0.z,i1.z,i2.z)\r);\rreturn outMatrix;\r}\rmat3 inverseMat3(mat3 inMatrix) {\rfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\rfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\rfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\rfloat b01=a22*a11-a12*a21;\rfloat b11=-a22*a10+a12*a20;\rfloat b21=a21*a10-a11*a20;\rfloat det=a00*b01+a01*b11+a02*b21;\rreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\rb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\rb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\r}\r#if USE_EXACT_SRGB_CONVERSIONS\nvec3 toLinearSpaceExact(vec3 color)\r{\rvec3 nearZeroSection=0.0773993808*color;\rvec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));\r#if defined(WEBGL2) || defined(WEBGPU)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));\r#else\nreturn\rvec3(\rcolor.r<=0.04045 ? nearZeroSection.r : remainingSection.r,\rcolor.g<=0.04045 ? nearZeroSection.g : remainingSection.g,\rcolor.b<=0.04045 ? nearZeroSection.b : remainingSection.b);\r#endif\n}\rvec3 toGammaSpaceExact(vec3 color)\r{\rvec3 nearZeroSection=12.92*color;\rvec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);\r#if defined(WEBGL2) || defined(WEBGPU)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));\r#else\nreturn\rvec3(\rcolor.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,\rcolor.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,\rcolor.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);\r#endif\n}\r#endif\nfloat toLinearSpace(float color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=0.0773993808*color;\rfloat remainingSection=pow(0.947867299*(color+0.055),2.4);\rreturn color<=0.04045 ? nearZeroSection : remainingSection;\r#else\nreturn pow(color,LinearEncodePowerApprox);\r#endif\n}\rvec3 toLinearSpace(vec3 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\r#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\r#endif\n}\rvec4 toLinearSpace(vec4 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\r#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\r#endif\n}\rfloat toGammaSpace(float color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=12.92*color;\rfloat remainingSection=1.055*pow(color,0.41666)-0.055;\rreturn color<=0.0031308 ? nearZeroSection : remainingSection;\r#else\nreturn pow(color,GammaEncodePowerApprox);\r#endif\n}\rvec3 toGammaSpace(vec3 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\r#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\r#endif\n}\rvec4 toGammaSpace(vec4 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\r#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\r#endif\n}\rfloat square(float value)\r{\rreturn value*value;\r}\rvec3 square(vec3 value)\r{\rreturn value*value;\r}\rfloat pow5(float value) {\rfloat sq=value*value;\rreturn sq*sq*value;\r}\rfloat getLuminance(vec3 color)\r{\rreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\r}\rfloat getRand(vec2 seed) {\rreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\r}\rfloat dither(vec2 seed,float varianceAmount) {\rfloat rand=getRand(seed);\rfloat normVariance=varianceAmount/255.0;\rfloat dither=mix(-normVariance,normVariance,rand);\rreturn dither;\r}\rconst float rgbdMaxRange=255.0;\rvec4 toRGBD(vec3 color) {\rfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\rfloat D =max(rgbdMaxRange/maxRGB,1.);\rD =clamp(floor(D)/255.0,0.,1.);\rvec3 rgb=color.rgb*D;\rrgb=toGammaSpace(rgb);\rreturn vec4(clamp(rgb,0.,1.),D); \r}\rvec3 fromRGBD(vec4 rgbd) {\rrgbd.rgb=toLinearSpace(rgbd.rgb);\rreturn rgbd.rgb/rgbd.a;\r}\rvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\rvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\rvec3 halfSize=cubeSize*0.5;\rvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\rvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\rvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\rfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\rvec3 intersectPositionWS=vertexPos+origVec*distance;\rreturn intersectPositionWS-cubePos;\r}\r`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const helperFunctions = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/helperFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmKd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"helperFunctions\";\nconst shader = `const float PI=3.1415926535897932384626433832795;\rconst float HALF_MIN=5.96046448e-08; \rconst float LinearEncodePowerApprox=2.2;\rconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\rconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\rconst float Epsilon=0.0000001;\r#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\rvec3 i0=inMatrix[0];\rvec3 i1=inMatrix[1];\rvec3 i2=inMatrix[2];\rmat3 outMatrix=mat3(\rvec3(i0.x,i1.x,i2.x),\rvec3(i0.y,i1.y,i2.y),\rvec3(i0.z,i1.z,i2.z)\r);\rreturn outMatrix;\r}\rmat3 inverseMat3(mat3 inMatrix) {\rfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\rfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\rfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\rfloat b01=a22*a11-a12*a21;\rfloat b11=-a22*a10+a12*a20;\rfloat b21=a21*a10-a11*a20;\rfloat det=a00*b01+a01*b11+a02*b21;\rreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\rb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\rb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\r}\r#if USE_EXACT_SRGB_CONVERSIONS\nvec3 toLinearSpaceExact(vec3 color)\r{\rvec3 nearZeroSection=0.0773993808*color;\rvec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));\r#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));\r#else\nreturn\rvec3(\rcolor.r<=0.04045 ? nearZeroSection.r : remainingSection.r,\rcolor.g<=0.04045 ? nearZeroSection.g : remainingSection.g,\rcolor.b<=0.04045 ? nearZeroSection.b : remainingSection.b);\r#endif\n}\rvec3 toGammaSpaceExact(vec3 color)\r{\rvec3 nearZeroSection=12.92*color;\rvec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);\r#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));\r#else\nreturn\rvec3(\rcolor.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,\rcolor.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,\rcolor.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);\r#endif\n}\r#endif\nfloat toLinearSpace(float color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=0.0773993808*color;\rfloat remainingSection=pow(0.947867299*(color+0.055),2.4);\rreturn color<=0.04045 ? nearZeroSection : remainingSection;\r#else\nreturn pow(color,LinearEncodePowerApprox);\r#endif\n}\rvec3 toLinearSpace(vec3 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\r#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\r#endif\n}\rvec4 toLinearSpace(vec4 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\r#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\r#endif\n}\rfloat toGammaSpace(float color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=12.92*color;\rfloat remainingSection=1.055*pow(color,0.41666)-0.055;\rreturn color<=0.0031308 ? nearZeroSection : remainingSection;\r#else\nreturn pow(color,GammaEncodePowerApprox);\r#endif\n}\rvec3 toGammaSpace(vec3 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\r#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\r#endif\n}\rvec4 toGammaSpace(vec4 color)\r{\r#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\r#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\r#endif\n}\rfloat square(float value)\r{\rreturn value*value;\r}\rvec3 square(vec3 value)\r{\rreturn value*value;\r}\rfloat pow5(float value) {\rfloat sq=value*value;\rreturn sq*sq*value;\r}\rfloat getLuminance(vec3 color)\r{\rreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\r}\rfloat getRand(vec2 seed) {\rreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\r}\rfloat dither(vec2 seed,float varianceAmount) {\rfloat rand=getRand(seed);\rfloat normVariance=varianceAmount/255.0;\rfloat dither=mix(-normVariance,normVariance,rand);\rreturn dither;\r}\rconst float rgbdMaxRange=255.0;\rvec4 toRGBD(vec3 color) {\rfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\rfloat D =max(rgbdMaxRange/maxRGB,1.);\rD =clamp(floor(D)/255.0,0.,1.);\rvec3 rgb=color.rgb*D;\rrgb=toGammaSpace(rgb);\rreturn vec4(clamp(rgb,0.,1.),D); \r}\rvec3 fromRGBD(vec4 rgbd) {\rrgbd.rgb=toLinearSpace(rgbd.rgb);\rreturn rgbd.rgb/rgbd.a;\r}\rvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\rvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\rvec3 halfSize=cubeSize*0.5;\rvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\rvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\rvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\rfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\rvec3 intersectPositionWS=vertexPos+origVec*distance;\rreturn intersectPositionWS-cubePos;\r}\r`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const helperFunctions = { name, shader };\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
3
|
const name = "mrtFragmentDeclaration";
|
|
4
|
-
const shader = `#if defined(WEBGL2) || defined(WEBGPU)
|
|
4
|
+
const shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
5
5
|
layout(location=0) out vec4 glFragData[{X}];
|
|
6
6
|
#endif
|
|
7
7
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mrtFragmentDeclaration.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/mrtFragmentDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;CAGd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"mrtFragmentDeclaration\";\nconst shader = `#if defined(WEBGL2) || defined(WEBGPU)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const mrtFragmentDeclaration = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"mrtFragmentDeclaration.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/mrtFragmentDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;CAGd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"mrtFragmentDeclaration\";\nconst shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const mrtFragmentDeclaration = { name, shader };\n"]}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
3
|
const name = "shadowsFragmentFunctions";
|
|
4
4
|
const shader = `#ifdef SHADOWS
|
|
5
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
6
|
+
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
|
7
|
+
#else
|
|
8
|
+
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
|
9
|
+
#endif
|
|
5
10
|
#ifndef SHADOWFLOAT
|
|
6
11
|
float unpack(vec4 color)
|
|
7
12
|
float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
|
|
@@ -20,7 +25,7 @@ float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.
|
|
|
20
25
|
float computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
|
|
21
26
|
float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
|
|
22
27
|
float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
|
|
23
|
-
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
|
|
28
|
+
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
|
|
24
29
|
#define inline
|
|
25
30
|
float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
|
|
26
31
|
float shadow=unpack(texture2D(shadowSampler,uvLayer));
|
|
@@ -28,36 +33,36 @@ float shadow=texture2D(shadowSampler,uvLayer).x;
|
|
|
28
33
|
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
|
|
29
34
|
#define inline
|
|
30
35
|
float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
|
|
31
|
-
float shadow=unpack(
|
|
32
|
-
float shadow=
|
|
36
|
+
float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
|
37
|
+
float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
|
33
38
|
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
|
|
34
39
|
float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
|
|
35
|
-
if (unpack(
|
|
36
|
-
if (
|
|
40
|
+
if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;
|
|
41
|
+
if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;
|
|
37
42
|
return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);
|
|
38
43
|
float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
|
|
39
|
-
float shadowMapSample=unpack(
|
|
40
|
-
float shadowMapSample=
|
|
44
|
+
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
|
45
|
+
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
|
41
46
|
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
|
|
42
47
|
float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
|
|
43
|
-
float shadowMapSample=unpack(
|
|
44
|
-
float shadowMapSample=
|
|
48
|
+
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
|
49
|
+
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
|
45
50
|
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
|
|
46
51
|
#define ZINCLIP clipSpace.z
|
|
47
52
|
#else
|
|
48
53
|
#define ZINCLIP uvDepth.z
|
|
49
54
|
#endif
|
|
50
|
-
#if defined(WEBGL2) || defined(WEBGPU)
|
|
55
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
51
56
|
#define GREATEST_LESS_THAN_ONE 0.99999994
|
|
52
57
|
#define inline
|
|
53
58
|
float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
|
|
54
59
|
float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
55
60
|
float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
56
|
-
float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
|
|
57
|
-
float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
58
|
-
float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
59
|
-
float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
|
|
60
|
-
float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
|
|
61
|
+
float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
|
|
62
|
+
float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
63
|
+
float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
|
64
|
+
float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
|
|
65
|
+
float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
|
|
61
66
|
float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
|
62
67
|
float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
|
63
68
|
float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowsFragmentFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/shadowsFragmentFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8lBd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"shadowsFragmentFunctions\";\nconst shader = `#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\r{\rconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\rreturn dot(color,bit_shift);\r}\r#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\r{\rfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\rreturn mix(value,1.0,mask);\r}\r#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rdepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\r#endif\nreturn depth>shadow ? darkness : 1.0;\r}\r#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rdepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\rfloat visibility=1.;\rvec3 poissonDisk[4];\rpoissonDisk[0]=vec3(-1.0,1.0,-1.0);\rpoissonDisk[1]=vec3(1.0,-1.0,-1.0);\rpoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\rpoissonDisk[3]=vec3(1.0,-1.0,1.0);\r#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\r#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\r#endif\nreturn min(1.0,visibility+darkness);\r}\r#define inline\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rfloat shadowPixelDepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\r#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \rreturn esm;\r}\r#define inline\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rfloat shadowPixelDepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\r#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\rreturn esm;\r}\r#if defined(WEBGL2) || defined(WEBGPU)\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rvec3 uvLayer=vec3(uv.x,uv.y,layer);\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\r#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\r#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\r}\r#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\r#else\nfloat shadow=texture2D(shadowSampler,uv).x;\r#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\r}\r}\r#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\rfloat visibility=1.;\rvec2 poissonDisk[4];\rpoissonDisk[0]=vec2(-0.94201624,-0.39906216);\rpoissonDisk[1]=vec2(0.94558609,-0.76890725);\rpoissonDisk[2]=vec2(-0.094184101,-0.92938870);\rpoissonDisk[3]=vec2(0.34495938,0.29387760);\r#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\rif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\rif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\rif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\r#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\rif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\rif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\rif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\r#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\r#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\r#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\rreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\r#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\r#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\rreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\rfloat shadow=texture2D(shadowSampler,uvDepthLayer);\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=3.-2.*st;\rvec2 uvw1=1.+2.*st;\rvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\rvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\rshadow=shadow/16.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=4.-3.*st;\rvec2 uvw1=vec2(7.);\rvec2 uvw2=1.+3.*st;\rvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\rvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\rshadow=shadow/144.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rfloat shadow=texture2D(shadowSampler,uvDepth);\rshadow=mix(darkness,1.,shadow);\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=3.-2.*st;\rvec2 uvw1=1.+2.*st;\rvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\rvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\rshadow=shadow/16.;\rshadow=mix(darkness,1.,shadow);\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=4.-3.*st;\rvec2 uvw1=vec2(7.);\rvec2 uvw2=1.+3.*st;\rvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\rvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\rshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\rshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\rshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\rshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\rshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\rshadow=shadow/144.;\rshadow=mix(darkness,1.,shadow);\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\rconst vec3 PoissonSamplers32[64]=vec3[64](\rvec3(0.06407013,0.05409927,0.),\rvec3(0.7366577,0.5789394,0.),\rvec3(-0.6270542,-0.5320278,0.),\rvec3(-0.4096107,0.8411095,0.),\rvec3(0.6849564,-0.4990818,0.),\rvec3(-0.874181,-0.04579735,0.),\rvec3(0.9989998,0.0009880066,0.),\rvec3(-0.004920578,-0.9151649,0.),\rvec3(0.1805763,0.9747483,0.),\rvec3(-0.2138451,0.2635818,0.),\rvec3(0.109845,0.3884785,0.),\rvec3(0.06876755,-0.3581074,0.),\rvec3(0.374073,-0.7661266,0.),\rvec3(0.3079132,-0.1216763,0.),\rvec3(-0.3794335,-0.8271583,0.),\rvec3(-0.203878,-0.07715034,0.),\rvec3(0.5912697,0.1469799,0.),\rvec3(-0.88069,0.3031784,0.),\rvec3(0.5040108,0.8283722,0.),\rvec3(-0.5844124,0.5494877,0.),\rvec3(0.6017799,-0.1726654,0.),\rvec3(-0.5554981,0.1559997,0.),\rvec3(-0.3016369,-0.3900928,0.),\rvec3(-0.5550632,-0.1723762,0.),\rvec3(0.925029,0.2995041,0.),\rvec3(-0.2473137,0.5538505,0.),\rvec3(0.9183037,-0.2862392,0.),\rvec3(0.2469421,0.6718712,0.),\rvec3(0.3916397,-0.4328209,0.),\rvec3(-0.03576927,-0.6220032,0.),\rvec3(-0.04661255,0.7995201,0.),\rvec3(0.4402924,0.3640312,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.)\r);\rconst vec3 PoissonSamplers64[64]=vec3[64](\rvec3(-0.613392,0.617481,0.),\rvec3(0.170019,-0.040254,0.),\rvec3(-0.299417,0.791925,0.),\rvec3(0.645680,0.493210,0.),\rvec3(-0.651784,0.717887,0.),\rvec3(0.421003,0.027070,0.),\rvec3(-0.817194,-0.271096,0.),\rvec3(-0.705374,-0.668203,0.),\rvec3(0.977050,-0.108615,0.),\rvec3(0.063326,0.142369,0.),\rvec3(0.203528,0.214331,0.),\rvec3(-0.667531,0.326090,0.),\rvec3(-0.098422,-0.295755,0.),\rvec3(-0.885922,0.215369,0.),\rvec3(0.566637,0.605213,0.),\rvec3(0.039766,-0.396100,0.),\rvec3(0.751946,0.453352,0.),\rvec3(0.078707,-0.715323,0.),\rvec3(-0.075838,-0.529344,0.),\rvec3(0.724479,-0.580798,0.),\rvec3(0.222999,-0.215125,0.),\rvec3(-0.467574,-0.405438,0.),\rvec3(-0.248268,-0.814753,0.),\rvec3(0.354411,-0.887570,0.),\rvec3(0.175817,0.382366,0.),\rvec3(0.487472,-0.063082,0.),\rvec3(-0.084078,0.898312,0.),\rvec3(0.488876,-0.783441,0.),\rvec3(0.470016,0.217933,0.),\rvec3(-0.696890,-0.549791,0.),\rvec3(-0.149693,0.605762,0.),\rvec3(0.034211,0.979980,0.),\rvec3(0.503098,-0.308878,0.),\rvec3(-0.016205,-0.872921,0.),\rvec3(0.385784,-0.393902,0.),\rvec3(-0.146886,-0.859249,0.),\rvec3(0.643361,0.164098,0.),\rvec3(0.634388,-0.049471,0.),\rvec3(-0.688894,0.007843,0.),\rvec3(0.464034,-0.188818,0.),\rvec3(-0.440840,0.137486,0.),\rvec3(0.364483,0.511704,0.),\rvec3(0.034028,0.325968,0.),\rvec3(0.099094,-0.308023,0.),\rvec3(0.693960,-0.366253,0.),\rvec3(0.678884,-0.204688,0.),\rvec3(0.001801,0.780328,0.),\rvec3(0.145177,-0.898984,0.),\rvec3(0.062655,-0.611866,0.),\rvec3(0.315226,-0.604297,0.),\rvec3(-0.780145,0.486251,0.),\rvec3(-0.371868,0.882138,0.),\rvec3(0.200476,0.494430,0.),\rvec3(-0.494552,-0.711051,0.),\rvec3(0.612476,0.705252,0.),\rvec3(-0.578845,-0.768792,0.),\rvec3(-0.772454,-0.090976,0.),\rvec3(0.504440,0.372295,0.),\rvec3(0.155736,0.065157,0.),\rvec3(0.391522,0.849605,0.),\rvec3(-0.620106,-0.328104,0.),\rvec3(0.789239,-0.419965,0.),\rvec3(-0.545396,0.538133,0.),\rvec3(-0.178564,-0.596057,0.)\r);\r#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\rfloat blockerDepth=0.0;\rfloat sumBlockerDepth=0.0;\rfloat numBlocker=0.0;\rfor (int i=0; i<searchTapCount; i ++) {\rblockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\rif (blockerDepth<depthMetric) {\rsumBlockerDepth+=blockerDepth;\rnumBlocker++;\r}\r}\rif (numBlocker<1.0) {\rreturn 1.0;\r}\relse\r{\rfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\rfloat AAOffset=shadowMapSizeInverse*10.;\rfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\rvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\rfloat random=getRand(vPositionFromLight.xy);\rfloat rotationAngle=random*3.1415926;\rvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\rfloat shadow=0.;\rfor (int i=0; i<pcfTapCount; i++) {\rvec4 offset=vec4(poissonSamplers[i],0.);\roffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\rshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\r}\rshadow/=float(pcfTapCount);\rshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\r{\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rfloat blockerDepth=0.0;\rfloat sumBlockerDepth=0.0;\rfloat numBlocker=0.0;\rfor (int i=0; i<searchTapCount; i ++) {\rblockerDepth=texture2D(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\rif (blockerDepth<depthMetric) {\rsumBlockerDepth+=blockerDepth;\rnumBlocker++;\r}\r}\rif (numBlocker<1.0) {\rreturn 1.0;\r}\relse\r{\rfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\rfloat AAOffset=shadowMapSizeInverse*10.;\rfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\rfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\rfloat random=getRand(vPositionFromLight.xy);\rfloat rotationAngle=random*3.1415926;\rvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\rfloat shadow=0.;\rfor (int i=0; i<pcfTapCount; i++) {\rvec3 offset=poissonSamplers[i];\roffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\rshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\r}\rshadow/=float(pcfTapCount);\rshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r}\r#define inline\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\r}\r#define inline\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\r}\r#define inline\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\r}\r#define inline\nfloat computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#define inline\nfloat computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#define inline\nfloat computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const shadowsFragmentFunctions = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"shadowsFragmentFunctions.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Shaders/ShadersInclude/shadowsFragmentFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmmBd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"shadowsFragmentFunctions\";\nconst shader = `#ifdef SHADOWS\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\r{\rconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\rreturn dot(color,bit_shift);\r}\r#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\r{\rfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\rreturn mix(value,1.0,mask);\r}\r#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rdepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\r#endif\nreturn depth>shadow ? darkness : 1.0;\r}\r#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rdepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\rfloat visibility=1.;\rvec3 poissonDisk[4];\rpoissonDisk[0]=vec3(-1.0,1.0,-1.0);\rpoissonDisk[1]=vec3(1.0,-1.0,-1.0);\rpoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\rpoissonDisk[3]=vec3(1.0,-1.0,1.0);\r#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\rif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\r#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\rif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\r#endif\nreturn min(1.0,visibility+darkness);\r}\r#define inline\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rfloat shadowPixelDepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\r#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \rreturn esm;\r}\r#define inline\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\r{\rvec3 directionToLight=vPositionW-lightPosition;\rfloat depth=length(directionToLight);\rdepth=(depth+depthValues.x)/(depthValues.y);\rfloat shadowPixelDepth=clamp(depth,0.,1.0);\rdirectionToLight=normalize(directionToLight);\rdirectionToLight.y=-directionToLight.y;\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\r#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\r#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\rreturn esm;\r}\r#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rvec3 uvLayer=vec3(uv.x,uv.y,layer);\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\r#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\r#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\r}\r#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\r#else\nfloat shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;\r#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\r}\r}\r#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\rfloat visibility=1.;\rvec2 poissonDisk[4];\rpoissonDisk[0]=vec2(-0.94201624,-0.39906216);\rpoissonDisk[1]=vec2(0.94558609,-0.76890725);\rpoissonDisk[2]=vec2(-0.094184101,-0.92938870);\rpoissonDisk[3]=vec2(0.34495938,0.29387760);\r#ifndef SHADOWFLOAT\nif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;\rif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;\rif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;\rif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;\r#else\nif (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;\rif (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;\rif (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;\rif (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;\r#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\r#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\r#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\rreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec2 uv=0.5*clipSpace.xy+vec2(0.5);\rif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\r{\rreturn 1.0;\r}\relse\r{\rfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \r#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\r#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\r#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\rreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\rfloat shadow=texture2D(shadowSampler,uvDepthLayer);\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=3.-2.*st;\rvec2 uvw1=1.+2.*st;\rvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\rvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\rshadow=shadow/16.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=4.-3.*st;\rvec2 uvw1=vec2(7.);\rvec2 uvw2=1.+3.*st;\rvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\rvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\rshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\rshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\rshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\rshadow=shadow/144.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\r{\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rfloat shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=3.-2.*st;\rvec2 uvw1=1.+2.*st;\rvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\rvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);\rshadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);\rshadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);\rshadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);\rshadow=shadow/16.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\r{\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \ruv+=0.5; \rvec2 st=fract(uv); \rvec2 base_uv=floor(uv)-0.5; \rbase_uv*=shadowMapSizeAndInverse.y; \rvec2 uvw0=4.-3.*st;\rvec2 uvw1=vec2(7.);\rvec2 uvw2=1.+3.*st;\rvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\rvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\rfloat shadow=0.;\rshadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);\rshadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);\rshadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);\rshadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);\rshadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);\rshadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);\rshadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);\rshadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);\rshadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);\rshadow=shadow/144.;\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\rconst vec3 PoissonSamplers32[64]=vec3[64](\rvec3(0.06407013,0.05409927,0.),\rvec3(0.7366577,0.5789394,0.),\rvec3(-0.6270542,-0.5320278,0.),\rvec3(-0.4096107,0.8411095,0.),\rvec3(0.6849564,-0.4990818,0.),\rvec3(-0.874181,-0.04579735,0.),\rvec3(0.9989998,0.0009880066,0.),\rvec3(-0.004920578,-0.9151649,0.),\rvec3(0.1805763,0.9747483,0.),\rvec3(-0.2138451,0.2635818,0.),\rvec3(0.109845,0.3884785,0.),\rvec3(0.06876755,-0.3581074,0.),\rvec3(0.374073,-0.7661266,0.),\rvec3(0.3079132,-0.1216763,0.),\rvec3(-0.3794335,-0.8271583,0.),\rvec3(-0.203878,-0.07715034,0.),\rvec3(0.5912697,0.1469799,0.),\rvec3(-0.88069,0.3031784,0.),\rvec3(0.5040108,0.8283722,0.),\rvec3(-0.5844124,0.5494877,0.),\rvec3(0.6017799,-0.1726654,0.),\rvec3(-0.5554981,0.1559997,0.),\rvec3(-0.3016369,-0.3900928,0.),\rvec3(-0.5550632,-0.1723762,0.),\rvec3(0.925029,0.2995041,0.),\rvec3(-0.2473137,0.5538505,0.),\rvec3(0.9183037,-0.2862392,0.),\rvec3(0.2469421,0.6718712,0.),\rvec3(0.3916397,-0.4328209,0.),\rvec3(-0.03576927,-0.6220032,0.),\rvec3(-0.04661255,0.7995201,0.),\rvec3(0.4402924,0.3640312,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.),\rvec3(0.,0.,0.)\r);\rconst vec3 PoissonSamplers64[64]=vec3[64](\rvec3(-0.613392,0.617481,0.),\rvec3(0.170019,-0.040254,0.),\rvec3(-0.299417,0.791925,0.),\rvec3(0.645680,0.493210,0.),\rvec3(-0.651784,0.717887,0.),\rvec3(0.421003,0.027070,0.),\rvec3(-0.817194,-0.271096,0.),\rvec3(-0.705374,-0.668203,0.),\rvec3(0.977050,-0.108615,0.),\rvec3(0.063326,0.142369,0.),\rvec3(0.203528,0.214331,0.),\rvec3(-0.667531,0.326090,0.),\rvec3(-0.098422,-0.295755,0.),\rvec3(-0.885922,0.215369,0.),\rvec3(0.566637,0.605213,0.),\rvec3(0.039766,-0.396100,0.),\rvec3(0.751946,0.453352,0.),\rvec3(0.078707,-0.715323,0.),\rvec3(-0.075838,-0.529344,0.),\rvec3(0.724479,-0.580798,0.),\rvec3(0.222999,-0.215125,0.),\rvec3(-0.467574,-0.405438,0.),\rvec3(-0.248268,-0.814753,0.),\rvec3(0.354411,-0.887570,0.),\rvec3(0.175817,0.382366,0.),\rvec3(0.487472,-0.063082,0.),\rvec3(-0.084078,0.898312,0.),\rvec3(0.488876,-0.783441,0.),\rvec3(0.470016,0.217933,0.),\rvec3(-0.696890,-0.549791,0.),\rvec3(-0.149693,0.605762,0.),\rvec3(0.034211,0.979980,0.),\rvec3(0.503098,-0.308878,0.),\rvec3(-0.016205,-0.872921,0.),\rvec3(0.385784,-0.393902,0.),\rvec3(-0.146886,-0.859249,0.),\rvec3(0.643361,0.164098,0.),\rvec3(0.634388,-0.049471,0.),\rvec3(-0.688894,0.007843,0.),\rvec3(0.464034,-0.188818,0.),\rvec3(-0.440840,0.137486,0.),\rvec3(0.364483,0.511704,0.),\rvec3(0.034028,0.325968,0.),\rvec3(0.099094,-0.308023,0.),\rvec3(0.693960,-0.366253,0.),\rvec3(0.678884,-0.204688,0.),\rvec3(0.001801,0.780328,0.),\rvec3(0.145177,-0.898984,0.),\rvec3(0.062655,-0.611866,0.),\rvec3(0.315226,-0.604297,0.),\rvec3(-0.780145,0.486251,0.),\rvec3(-0.371868,0.882138,0.),\rvec3(0.200476,0.494430,0.),\rvec3(-0.494552,-0.711051,0.),\rvec3(0.612476,0.705252,0.),\rvec3(-0.578845,-0.768792,0.),\rvec3(-0.772454,-0.090976,0.),\rvec3(0.504440,0.372295,0.),\rvec3(0.155736,0.065157,0.),\rvec3(0.391522,0.849605,0.),\rvec3(-0.620106,-0.328104,0.),\rvec3(0.789239,-0.419965,0.),\rvec3(-0.545396,0.538133,0.),\rvec3(-0.178564,-0.596057,0.)\r);\r#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\rvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\rfloat blockerDepth=0.0;\rfloat sumBlockerDepth=0.0;\rfloat numBlocker=0.0;\rfor (int i=0; i<searchTapCount; i ++) {\rblockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\rif (blockerDepth<depthMetric) {\rsumBlockerDepth+=blockerDepth;\rnumBlocker++;\r}\r}\rfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\rfloat AAOffset=shadowMapSizeInverse*10.;\rfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\rvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\rfloat random=getRand(vPositionFromLight.xy);\rfloat rotationAngle=random*3.1415926;\rvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\rfloat shadow=0.;\rfor (int i=0; i<pcfTapCount; i++) {\rvec4 offset=vec4(poissonSamplers[i],0.);\roffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\rshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\r}\rshadow/=float(pcfTapCount);\rshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\rshadow=mix(darkness,1.,shadow);\rif (numBlocker<1.0) {\rreturn 1.0;\r}\relse\r{\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r#define inline\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\r{\rif (depthMetric>1.0 || depthMetric<0.0) {\rreturn 1.0;\r}\relse\r{\rvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\rvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\ruvDepth.z=ZINCLIP;\rfloat blockerDepth=0.0;\rfloat sumBlockerDepth=0.0;\rfloat numBlocker=0.0;\rfor (int i=0; i<searchTapCount; i ++) {\rblockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;\rif (blockerDepth<depthMetric) {\rsumBlockerDepth+=blockerDepth;\rnumBlocker++;\r}\r}\rif (numBlocker<1.0) {\rreturn 1.0;\r}\relse\r{\rfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\rfloat AAOffset=shadowMapSizeInverse*10.;\rfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\rfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\rfloat random=getRand(vPositionFromLight.xy);\rfloat rotationAngle=random*3.1415926;\rvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\rfloat shadow=0.;\rfor (int i=0; i<pcfTapCount; i++) {\rvec3 offset=poissonSamplers[i];\roffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\rshadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);\r}\rshadow/=float(pcfTapCount);\rshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\rshadow=mix(darkness,1.,shadow);\rreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\r}\r}\r}\r#define inline\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\r}\r#define inline\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\r}\r#define inline\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\r{\rreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\r}\r#define inline\nfloat computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#define inline\nfloat computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#define inline\nfloat computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\r{\rreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\r}\r#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const shadowsFragmentFunctions = { name, shader };\n"]}
|
package/Shaders/fxaa.fragment.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
3
|
const name = "fxaaPixelShader";
|
|
4
|
-
const shader =
|
|
5
|
-
|
|
4
|
+
const shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
5
|
+
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
|
6
|
+
#else
|
|
7
|
+
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
|
8
|
+
#endif
|
|
9
|
+
uniform sampler2D textureSampler;
|
|
10
|
+
void main(){
|
|
6
11
|
if(range<rangeMaxClamped)
|
|
7
|
-
float lumaNW=FxaaLuma(
|
|
8
|
-
if(range<rangeMaxClamped)
|
|
9
|
-
gl_FragColor=
|
|
12
|
+
float lumaNW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNW,0.0));
|
|
13
|
+
if(range<rangeMaxClamped)
|
|
14
|
+
gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);
|
|
10
15
|
}`;
|
|
11
16
|
// Sideeffect
|
|
12
17
|
ShaderStore.ShadersStore[name] = shader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fxaa.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/fxaa.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"fxaa.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/fxaa.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgNb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"fxaaPixelShader\";\nconst shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nuniform sampler2D textureSampler;\runiform vec2 texelSize;\rvarying vec2 vUV;\rvarying vec2 sampleCoordS;\rvarying vec2 sampleCoordE;\rvarying vec2 sampleCoordN;\rvarying vec2 sampleCoordW;\rvarying vec2 sampleCoordNW;\rvarying vec2 sampleCoordSE;\rvarying vec2 sampleCoordNE;\rvarying vec2 sampleCoordSW;\rconst float fxaaQualitySubpix=1.0;\rconst float fxaaQualityEdgeThreshold=0.166;\rconst float fxaaQualityEdgeThresholdMin=0.0833;\rconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\r#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\rvec2 posM;\rposM.x=vUV.x;\rposM.y=vUV.y;\rvec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);\rfloat lumaM=FxaaLuma(rgbyM);\rfloat lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));\rfloat lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));\rfloat lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));\rfloat lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));\rfloat maxSM=max(lumaS,lumaM);\rfloat minSM=min(lumaS,lumaM);\rfloat maxESM=max(lumaE,maxSM);\rfloat minESM=min(lumaE,minSM);\rfloat maxWN=max(lumaN,lumaW);\rfloat minWN=min(lumaN,lumaW);\rfloat rangeMax=max(maxWN,maxESM);\rfloat rangeMin=min(minWN,minESM);\rfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\rfloat range=rangeMax-rangeMin;\rfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\r#ifndef MALI\nif(range<rangeMaxClamped) \r{\rgl_FragColor=rgbyM;\rreturn;\r}\r#endif\nfloat lumaNW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNW,0.0));\rfloat lumaSE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSE,0.0));\rfloat lumaNE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNE,0.0));\rfloat lumaSW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSW,0.0));\rfloat lumaNS=lumaN+lumaS;\rfloat lumaWE=lumaW+lumaE;\rfloat subpixRcpRange=1.0/range;\rfloat subpixNSWE=lumaNS+lumaWE;\rfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\rfloat edgeVert1=(-2.0*lumaM)+lumaWE;\rfloat lumaNESE=lumaNE+lumaSE;\rfloat lumaNWNE=lumaNW+lumaNE;\rfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\rfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\rfloat lumaNWSW=lumaNW+lumaSW;\rfloat lumaSWSE=lumaSW+lumaSE;\rfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\rfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\rfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\rfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\rfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\rfloat edgeVert=abs(edgeVert3)+edgeVert4;\rfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\rfloat lengthSign=texelSize.x;\rbool horzSpan=edgeHorz>=edgeVert;\rfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\rif (!horzSpan)\r{\rlumaN=lumaW;\r}\rif (!horzSpan) \r{\rlumaS=lumaE;\r}\rif (horzSpan) \r{\rlengthSign=texelSize.y;\r}\rfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\rfloat gradientN=lumaN-lumaM;\rfloat gradientS=lumaS-lumaM;\rfloat lumaNN=lumaN+lumaM;\rfloat lumaSS=lumaS+lumaM;\rbool pairN=abs(gradientN)>=abs(gradientS);\rfloat gradient=max(abs(gradientN),abs(gradientS));\rif (pairN)\r{\rlengthSign=-lengthSign;\r}\rfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\rvec2 posB;\rposB.x=posM.x;\rposB.y=posM.y;\rvec2 offNP;\roffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\roffNP.y=(horzSpan) ? 0.0 : texelSize.y;\rif (!horzSpan) \r{\rposB.x+=lengthSign*0.5;\r}\rif (horzSpan)\r{\rposB.y+=lengthSign*0.5;\r}\rvec2 posN;\rposN.x=posB.x-offNP.x*1.5;\rposN.y=posB.y-offNP.y*1.5;\rvec2 posP;\rposP.x=posB.x+offNP.x*1.5;\rposP.y=posB.y+offNP.y*1.5;\rfloat subpixD=((-2.0)*subpixC)+3.0;\rfloat lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));\rfloat subpixE=subpixC*subpixC;\rfloat lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));\rif (!pairN) \r{\rlumaNN=lumaSS;\r}\rfloat gradientScaled=gradient*1.0/4.0;\rfloat lumaMM=lumaM-lumaNN*0.5;\rfloat subpixF=subpixD*subpixE;\rbool lumaMLTZero=lumaMM<0.0;\rlumaEndN-=lumaNN*0.5;\rlumaEndP-=lumaNN*0.5;\rbool doneN=abs(lumaEndN)>=gradientScaled;\rbool doneP=abs(lumaEndP)>=gradientScaled;\rif (!doneN) \r{\rposN.x-=offNP.x*3.0;\r}\rif (!doneN) \r{\rposN.y-=offNP.y*3.0;\r}\rbool doneNP=(!doneN) || (!doneP);\rif (!doneP) \r{\rposP.x+=offNP.x*3.0;\r}\rif (!doneP)\r{\rposP.y+=offNP.y*3.0;\r}\rif (doneNP)\r{\rif (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));\rif (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));\rif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\rif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\rdoneN=abs(lumaEndN)>=gradientScaled;\rdoneP=abs(lumaEndP)>=gradientScaled;\rif (!doneN) posN.x-=offNP.x*12.0;\rif (!doneN) posN.y-=offNP.y*12.0;\rdoneNP=(!doneN) || (!doneP);\rif (!doneP) posP.x+=offNP.x*12.0;\rif (!doneP) posP.y+=offNP.y*12.0;\r}\rfloat dstN=posM.x-posN.x;\rfloat dstP=posP.x-posM.x;\rif (!horzSpan)\r{\rdstN=posM.y-posN.y;\r}\rif (!horzSpan) \r{\rdstP=posP.y-posM.y;\r}\rbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\rfloat spanLength=(dstP+dstN);\rbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\rfloat spanLengthRcp=1.0/spanLength;\rbool directionN=dstN<dstP;\rfloat dst=min(dstN,dstP);\rbool goodSpan=directionN ? goodSpanN : goodSpanP;\rfloat subpixG=subpixF*subpixF;\rfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\rfloat subpixH=subpixG*fxaaQualitySubpix;\rfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\rfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\rif (!horzSpan)\r{\rposM.x+=pixelOffsetSubpix*lengthSign;\r}\rif (horzSpan)\r{\rposM.y+=pixelOffsetSubpix*lengthSign;\r}\r#ifdef MALI\nif(range<rangeMaxClamped) \r{\rgl_FragColor=rgbyM;\r}\relse\r{\rgl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);\r}\r#else\ngl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);\r#endif\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const fxaaPixelShader = { name, shader };\n"]}
|
|
@@ -24,7 +24,10 @@ uniform mat4 invView;
|
|
|
24
24
|
#ifdef BILLBOARD
|
|
25
25
|
uniform vec3 eyePosition;
|
|
26
26
|
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
|
|
27
|
-
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
|
|
27
|
+
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
|
|
28
|
+
vec3 row1=direction;
|
|
29
|
+
vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
|
|
30
|
+
mat3 rotMatrix= mat3(row0,row1,row2);
|
|
28
31
|
#define CUSTOM_VERTEX_DEFINITIONS
|
|
29
32
|
void main(void) {
|
|
30
33
|
vec2 cornerPos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particles.vertex.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/particles.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,6CAA6C,CAAC;AACrD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,iCAAiC,CAAC;AAEzC,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"particles.vertex.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/particles.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,6CAA6C,CAAC;AACrD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,iCAAiC,CAAC;AAEzC,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Hb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/clipPlaneVertex\";\nimport \"./ShadersInclude/logDepthVertex\";\n\nconst name = \"particlesVertexShader\";\nconst shader = `attribute vec3 position;\rattribute vec4 color;\rattribute float angle;\rattribute vec2 size;\r#ifdef ANIMATESHEET\nattribute float cellIndex;\r#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\r#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\r#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\r#endif\nattribute vec2 offset;\runiform mat4 view;\runiform mat4 projection;\runiform vec2 translationPivot;\r#ifdef ANIMATESHEET\nuniform vec3 particlesInfos; \r#endif\nvarying vec2 vUV;\rvarying vec4 vColor;\rvarying vec3 vPositionW;\r#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\r#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\r#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\r#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\rvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\rvec3 zaxis=normalize(cross(yaxis,xaxis));\rvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\rvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\rvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\rmat3 rotMatrix= mat3(row0,row1,row2);\rvec3 alignedCorner=rotMatrix*rotatedCorner;\rreturn position+alignedCorner;\r}\r#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\rvec3 normalizedToCamera=normalize(toCamera);\rvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\rvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\rvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\r#ifdef BILLBOARDSTRETCHED_LOCAL\nvec3 row1=direction;\r#else\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\rvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\r#endif\nmat3 rotMatrix= mat3(row0,row1,row2);\rvec3 alignedCorner=rotMatrix*rotatedCorner;\rreturn position+alignedCorner;\r}\r#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\r#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 cornerPos;\rcornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size+translationPivot;\r#ifdef BILLBOARD\nvec3 rotatedCorner;\r#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\rrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\rrotatedCorner.y=0.;\rvec3 yaxis=position-eyePosition;\ryaxis.y=0.;\rvPositionW=rotate(normalize(yaxis),rotatedCorner);\rvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\r#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\rrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\rrotatedCorner.z=0.;\rvec3 toCamera=position-eyePosition;\rvPositionW=rotateAlign(toCamera,rotatedCorner);\rvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\r#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\rrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\rrotatedCorner.z=0.;\rvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\rvPositionW=(invView*vec4(viewPos,1)).xyz;\r#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\r#endif\ngl_Position=projection*vec4(viewPos,1.0);\r#else\nvec3 rotatedCorner;\rrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\rrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\rrotatedCorner.y=0.;\rvec3 yaxis=normalize(direction);\rvPositionW=rotate(yaxis,rotatedCorner);\rgl_Position=projection*view*vec4(vPositionW,1.0);\r#endif\nvColor=color;\r#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex*particlesInfos.z);\rfloat columnOffset=cellIndex-rowOffset/particlesInfos.z;\rvec2 uvScale=particlesInfos.xy;\rvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\rvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\r#else\nvUV=offset;\r#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\r#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const particlesVertexShader = { name, shader };\n"]}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
3
|
const name = "spriteMapPixelShader";
|
|
4
|
-
const shader =
|
|
4
|
+
const shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
5
|
+
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
|
6
|
+
#else
|
|
7
|
+
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
|
8
|
+
#endif
|
|
9
|
+
precision highp float;
|
|
5
10
|
tileUV.y=1.0-tileUV.y;
|
|
6
11
|
vec2 tileID=floor(tUV);
|
|
7
|
-
vec4 animationData=
|
|
12
|
+
vec4 animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);
|
|
8
13
|
// Sideeffect
|
|
9
14
|
ShaderStore.ShadersStore[name] = shader;
|
|
10
15
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spriteMap.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/spriteMap.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"spriteMap.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/spriteMap.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"spriteMapPixelShader\";\nconst shader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nprecision highp float;\rvarying vec3 vPosition;\rvarying vec2 vUV;\rvarying vec2 tUV;\runiform float time;\runiform float spriteCount;\runiform sampler2D spriteSheet;\runiform vec2 spriteMapSize;\runiform vec2 outputSize;\runiform vec2 stageSize;\runiform sampler2D frameMap;\runiform sampler2D tileMaps[LAYERS];\runiform sampler2D animationMap;\runiform vec3 colorMul;\rfloat mt;\rconst float fdStep=1./4.;\rconst float aFrameSteps=1./MAX_ANIMATION_FRAMES;\rmat4 getFrameData(float frameID){\rfloat fX=frameID/spriteCount;\rreturn mat4(\rtexture2D(frameMap,vec2(fX,0.),0.),\rtexture2D(frameMap,vec2(fX,fdStep*1.),0.),\rtexture2D(frameMap,vec2(fX,fdStep*2.),0.),\rvec4(0.)\r);\r}\rvoid main(){\rvec4 color=vec4(0.);\rvec2 tileUV=fract(tUV);\r#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\r#endif\nvec2 tileID=floor(tUV);\rvec2 sheetUnits=1./spriteMapSize;\rfloat spriteUnits=1./spriteCount;\rvec2 stageUnits=1./stageSize;\rfor(int i=0; i<LAYERS; i++) {\rfloat frameID;\r#define LAYER_ID_SWITCH\nvec4 animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);\rif(animationData.y>0.) {\rmt=mod(time*animationData.z,1.0);\rfor(float f=0.; f<MAX_ANIMATION_FRAMES; f++){\rif(animationData.y>mt){\rframeID=animationData.x;\rbreak;\r}\ranimationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);\r}\r}\rmat4 frameData=getFrameData(frameID+0.5);\rvec2 frameSize=(frameData[0].zw)/spriteMapSize;\rvec2 offset=frameData[0].xy*sheetUnits;\rvec2 ratio=frameData[2].xy/frameData[0].zw;\rif (frameData[2].z==1.){\rtileUV.xy=tileUV.yx;\r}\rvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\rif (i==0){\rcolor=nc;\r} else {\rfloat alpha=min(color.a+nc.a,1.0);\rvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\rcolor=vec4(mixed,alpha);\r}\r}\rcolor.xyz*=colorMul;\rgl_FragColor=color;\r}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const spriteMapPixelShader = { name, shader };\n"]}
|
|
@@ -531,6 +531,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
531
531
|
Object.keys(controllerData.eventListeners).forEach((eventName) => {
|
|
532
532
|
const func = controllerData.eventListeners && controllerData.eventListeners[eventName];
|
|
533
533
|
if (func) {
|
|
534
|
+
// For future reference - this is an issue in the WebXR typings.
|
|
534
535
|
this._xrSessionManager.session.removeEventListener(eventName, func);
|
|
535
536
|
}
|
|
536
537
|
});
|