@babylonjs/core 5.28.0 → 5.30.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/Actions/actionManager.js +2 -0
- package/Actions/actionManager.js.map +1 -1
- package/Cameras/camera.js +4 -4
- package/Cameras/camera.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +1 -2
- package/Collisions/pickingInfo.js +7 -4
- package/Collisions/pickingInfo.js.map +1 -1
- package/Culling/ray.d.ts +1 -1
- package/Culling/ray.js +5 -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/Extensions/engine.videoTexture.js +6 -3
- package/Engines/Extensions/engine.videoTexture.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/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/renderTargetWrapper.d.ts +2 -1
- package/Engines/renderTargetWrapper.js +1 -0
- package/Engines/renderTargetWrapper.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/Events/pointerEvents.d.ts +11 -6
- package/Events/pointerEvents.js +24 -6
- package/Events/pointerEvents.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 +9 -1
- package/Inputs/scene.inputManager.js +83 -37
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +2 -6
- package/Layers/effectLayer.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/PBR/pbrMetallicRoughnessMaterial.d.ts +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.d.ts +5 -0
- package/Materials/Textures/htmlElementTexture.js +4 -1
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +6 -1
- package/Materials/Textures/videoTexture.js +7 -2
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Maths/math.vector.d.ts +460 -337
- package/Maths/math.vector.js +370 -184
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/decalBuilder.d.ts +8 -0
- package/Meshes/Builders/decalBuilder.js +270 -51
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/mesh.d.ts +1 -1
- package/Meshes/mesh.js +42 -1
- package/Meshes/mesh.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/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/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +14 -8
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +16 -6
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +2 -1
- package/PostProcesses/blurPostProcess.js +3 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js +2 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js +3 -5
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.js +9 -4
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js +4 -4
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +2 -6
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +4 -0
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthRenderer.js +2 -6
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +2 -6
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/renderingGroup.d.ts +4 -0
- package/Rendering/renderingGroup.js +7 -1
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.d.ts +8 -0
- package/Rendering/renderingManager.js +18 -0
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +18 -13
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/circleOfConfusion.fragment.js +1 -1
- package/Shaders/circleOfConfusion.fragment.js.map +1 -1
- package/Shaders/depthOfFieldMerge.fragment.js +1 -1
- package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
- package/Shaders/fxaa.fragment.js +10 -5
- package/Shaders/fxaa.fragment.js.map +1 -1
- package/Shaders/kernelBlur.fragment.js +2 -2
- package/Shaders/kernelBlur.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/XR/webXRRenderTargetTextureProvider.js +1 -0
- package/XR/webXRRenderTargetTextureProvider.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 +6 -8
- package/scene.js +11 -30
- 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,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,GAAmE,EAAE,CAAC;QACrG,wBAAmB,GAAiC,IAAI,kBAAkB,EAAE,CAAC;QAE7E,gCAA2B,GAAG,KAAK,CAAC;QA2CxC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YAC9F,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SACpF;IACL,CAAC;IA/CD;;;;;OAKG;IACH,IAAW,0BAA0B;QACjC,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC5C,CAAC;IAED,IAAW,0BAA0B,CAAC,KAAc;QAChD,IAAI,KAAK,KAAK,IAAI,CAAC,2BAA2B,EAAE;YAC5C,OAAO;SACV;QAED,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;QAEzC,oFAAoF;QACpF,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAA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C,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;;AAnTD;;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 * 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,GAAmE,EAAE,CAAC;QACrG,wBAAmB,GAAiC,IAAI,kBAAkB,EAAE,CAAC;QAE7E,gCAA2B,GAAG,KAAK,CAAC;QA2CxC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YAC9F,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SACpF;IACL,CAAC;IA/CD;;;;;OAKG;IACH,IAAW,0BAA0B;QACjC,OAAO,IAAI,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,CAAC,CAAC;YACtD,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;YAC9E,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;YACpF,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;SAC3F;IACL,CAAC;IAED;;;;;;;OAOG;IACI,iCAAiC,CAAC,gBAAwB,EAAE,qBAA8B,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI;QAC3H,IAAI,CAAC,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;;AAvUD;;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 /**\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"]}
|
|
@@ -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)
|
|
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)
|
|
@@ -28,20 +33,20 @@ 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
|
|
@@ -53,11 +58,11 @@ float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),dar
|
|
|
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)\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)\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)\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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
3
|
const name = "circleOfConfusionPixelShader";
|
|
4
4
|
const shader = `uniform sampler2D depthSampler;
|
|
5
|
-
void main(void)
|
|
5
|
+
void main(void)
|
|
6
6
|
// Sideeffect
|
|
7
7
|
ShaderStore.ShadersStore[name] = shader;
|
|
8
8
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circleOfConfusion.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/circleOfConfusion.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;CAcd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"circleOfConfusionPixelShader\";\nconst shader = `uniform sampler2D depthSampler;\rvarying vec2 vUV;\runiform vec2 cameraMinMaxZ;\runiform float focusDistance;\runiform float cocPrecalculation;\r#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rfloat depth=texture2D(depthSampler,vUV).r;\rfloat pixelDistance=(cameraMinMaxZ.x+
|
|
1
|
+
{"version":3,"file":"circleOfConfusion.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/circleOfConfusion.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;CAcd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"circleOfConfusionPixelShader\";\nconst shader = `uniform sampler2D depthSampler;\rvarying vec2 vUV;\runiform vec2 cameraMinMaxZ;\runiform float focusDistance;\runiform float cocPrecalculation;\r#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rfloat depth=texture2D(depthSampler,vUV).r;\rfloat pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0; \rfloat coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));\rcoc=clamp(coc,0.0,1.0);\rgl_FragColor=vec4(coc,coc,coc,1.0);\r}\r`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const circleOfConfusionPixelShader = { name, shader };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depthOfFieldMerge.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/depthOfFieldMerge.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Cd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"depthOfFieldMergePixelShader\";\nconst shader = `uniform sampler2D textureSampler;\rvarying vec2 vUV;\runiform sampler2D circleOfConfusionSampler;\runiform sampler2D blurStep0;\r#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\r#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\r#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\r#if BLUR_LEVEL==0\nvec4 original=texture2D(textureSampler,vUV);\rvec4 blurred0=texture2D(blurStep0,vUV);\rgl_FragColor=mix(original,blurred0,coc);\r#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){\rvec4 original=texture2D(textureSampler,vUV);\rvec4 blurred1=texture2D(blurStep1,vUV);\rgl_FragColor=mix(original,blurred1,coc/0.5);\r}else{\rvec4 blurred0=texture2D(blurStep0,vUV)
|
|
1
|
+
{"version":3,"file":"depthOfFieldMerge.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/depthOfFieldMerge.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Cd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"depthOfFieldMergePixelShader\";\nconst shader = `uniform sampler2D textureSampler;\rvarying vec2 vUV;\runiform sampler2D circleOfConfusionSampler;\runiform sampler2D blurStep0;\r#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\r#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\r#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\r#if BLUR_LEVEL==0\nvec4 original=texture2D(textureSampler,vUV);\rvec4 blurred0=texture2D(blurStep0,vUV);\rgl_FragColor=mix(original,blurred0,coc);\r#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){\rvec4 original=texture2D(textureSampler,vUV);\rvec4 blurred1=texture2D(blurStep1,vUV);\rgl_FragColor=mix(original,blurred1,coc/0.5);\r}else{\rvec4 blurred0=texture2D(blurStep0,vUV);\rvec4 blurred1=texture2D(blurStep1,vUV);\rgl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\r}\r#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){\rvec4 original=texture2D(textureSampler,vUV);\rvec4 blurred2=texture2D(blurStep2,vUV);\rgl_FragColor=mix(original,blurred2,coc/0.33);\r}else if(coc<0.66){\rvec4 blurred1=texture2D(blurStep1,vUV);\rvec4 blurred2=texture2D(blurStep2,vUV);\rgl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\r}else{\rvec4 blurred0=texture2D(blurStep0,vUV);\rvec4 blurred1=texture2D(blurStep1,vUV);\rgl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\r}\r#endif\n}\r`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const depthOfFieldMergePixelShader = { 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)
|
|
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)\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"]}
|
|
@@ -6,13 +6,13 @@ import "./ShadersInclude/kernelBlurFragment.js";
|
|
|
6
6
|
import "./ShadersInclude/kernelBlurFragment2.js";
|
|
7
7
|
const name = "kernelBlurPixelShader";
|
|
8
8
|
const shader = `uniform sampler2D textureSampler;
|
|
9
|
-
uniform sampler2D circleOfConfusionSampler;
|
|
9
|
+
uniform sampler2D circleOfConfusionSampler;
|
|
10
10
|
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
|
|
11
11
|
#ifdef PACKEDFLOAT
|
|
12
12
|
#include<packingFunctions>
|
|
13
13
|
#endif
|
|
14
14
|
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
15
|
-
void main(void)
|
|
15
|
+
void main(void)
|
|
16
16
|
float blend=0.;
|
|
17
17
|
vec4 blend=vec4(0.);
|
|
18
18
|
#ifdef DOF
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernelBlur.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/kernelBlur.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,sCAAsC,CAAC;AAE9C,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"kernelBlur.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/kernelBlur.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,sCAAsC,CAAC;AAE9C,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Cb,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/kernelBlurVaryingDeclaration\";\nimport \"./ShadersInclude/packingFunctions\";\nimport \"./ShadersInclude/kernelBlurFragment\";\nimport \"./ShadersInclude/kernelBlurFragment2\";\n\nconst name = \"kernelBlurPixelShader\";\nconst shader = `uniform sampler2D textureSampler;\runiform vec2 delta;\rvarying vec2 sampleCenter;\r#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\rfloat sampleCoC(in vec2 offset) {\rfloat coc=texture2D(circleOfConfusionSampler,offset).r;\rreturn coc; \r}\r#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include<packingFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rfloat computedWeight=0.0;\r#ifdef PACKEDFLOAT\nfloat blend=0.;\r#else\nvec4 blend=vec4(0.);\r#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \rfloat factor=0.0;\r#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\r#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\r#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\r#else\ngl_FragColor=blend;\r#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\r#endif\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const kernelBlurPixelShader = { 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)
|
|
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)\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
|
});
|