@babylonjs/core 9.1.0 → 9.2.1
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/Animations/animation.js +2 -2
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.js +1 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/animatorAvatar.js +13 -12
- package/Animations/animatorAvatar.js.map +1 -1
- package/Animations/easing.js +1 -1
- package/Animations/easing.js.map +1 -1
- package/Animations/pathCursor.js +1 -2
- package/Animations/pathCursor.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.js +10 -8
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/geospatialCameraMovement.js +6 -7
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Engines/Extensions/engine.multiview.js +6 -0
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +9 -4
- package/Engines/constants.js +9 -4
- package/Engines/constants.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +38 -11
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.d.ts +105 -0
- package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.js +318 -0
- package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +4 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +34 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +144 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.d.ts +26 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js +82 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.d.ts +61 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js +207 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.d.ts +104 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js +218 -0
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +217 -0
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +640 -0
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -0
- package/FrameGraph/frameGraph.js +1 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +4 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Layers/selectionOutlineLayer.d.ts +7 -0
- package/Layers/selectionOutlineLayer.js +18 -1
- package/Layers/selectionOutlineLayer.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.d.ts +7 -0
- package/Layers/thinSelectionOutlineLayer.js +86 -36
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +6 -0
- package/Lights/Clustered/clusteredLightContainer.js +50 -5
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Lights/light.d.ts +7 -0
- package/Lights/light.js +10 -0
- package/Lights/light.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +13 -3
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.d.ts +166 -53
- package/Materials/PBR/openpbrMaterial.js +180 -61
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.js +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +36 -31
- package/Materials/PBR/pbrBaseMaterial.js +2 -32
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +6 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +10 -0
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/envCubeTexture.js +13 -13
- package/Materials/Textures/envCubeTexture.js.map +1 -1
- package/Materials/environmentLighting.defines.d.ts +31 -0
- package/Materials/environmentLighting.defines.js +33 -0
- package/Materials/environmentLighting.defines.js.map +1 -0
- package/Materials/material.js +1 -0
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.functions.js +9 -3
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +10 -3
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/prepass.defines.d.ts +43 -0
- package/Materials/prepass.defines.js +45 -0
- package/Materials/prepass.defines.js.map +1 -0
- package/Materials/standardMaterial.d.ts +36 -31
- package/Materials/standardMaterial.js +2 -32
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +101 -62
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +39 -25
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +8 -1
- package/Meshes/abstractMesh.js +9 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +31 -4
- package/Meshes/mesh.js.map +1 -1
- package/Misc/greasedLineTools.js +5 -0
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/textureTools.d.ts +3 -1
- package/Misc/textureTools.js +74 -13
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +2 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +33 -1
- package/Particles/baseParticleSystem.js +65 -0
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +6 -0
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +24 -6
- package/Particles/gpuParticleSystem.js +85 -36
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +0 -6
- package/Particles/particleSystem.js +3 -14
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +1 -3
- package/Particles/thinParticleSystem.js +1 -27
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.js +7 -0
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +6 -10
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +46 -13
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -19
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +21 -65
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +15 -52
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +129 -220
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +3 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthRenderer.js +6 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.d.ts +34 -5
- package/Rendering/geometryBufferRenderer.js +209 -16
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/geometryBufferRendererSceneComponent.d.ts +4 -6
- package/Rendering/geometryBufferRendererSceneComponent.js.map +1 -1
- package/Rendering/iblCdfGenerator.d.ts +10 -0
- package/Rendering/iblCdfGenerator.js +52 -17
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/index.d.ts +0 -6
- package/Rendering/index.js +0 -6
- package/Rendering/index.js.map +1 -1
- package/Rendering/objectRenderer.js +1 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js +7 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +5 -0
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js +1 -1
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
- package/Shaders/{iblVoxelSlabDebug.fragment.d.ts → ShadersInclude/openpbrBlockPrePass.d.ts} +1 -1
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js +77 -0
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +42 -17
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +43 -17
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +10 -1
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +14 -38
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +4 -2
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/Shaders/{iblVoxelSlabDebug.vertex.d.ts → ShadersInclude/openpbrSubsurfaceLayerData.d.ts} +1 -1
- package/Shaders/ShadersInclude/openpbrSubsurfaceLayerData.js +35 -0
- package/Shaders/ShadersInclude/openpbrSubsurfaceLayerData.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js +1 -1
- package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +9 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
- package/Shaders/{iblVoxelGrid3dDebug.fragment.d.ts → ShadersInclude/openpbrVolumeFunctions.d.ts} +1 -1
- package/Shaders/ShadersInclude/openpbrVolumeFunctions.js +67 -0
- package/Shaders/ShadersInclude/openpbrVolumeFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +14 -3
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/{ShadersWGSL/iblVoxelSlabDebug.fragment.d.ts → Shaders/ShadersInclude/pbrFragmentReflectionDeclaration.d.ts} +1 -1
- package/Shaders/ShadersInclude/pbrFragmentReflectionDeclaration.js +43 -0
- package/Shaders/ShadersInclude/pbrFragmentReflectionDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -32
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/sceneFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/sceneFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/sceneUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/Shaders/geometry.fragment.d.ts +12 -0
- package/Shaders/geometry.fragment.js +102 -1
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/geometry.vertex.d.ts +1 -0
- package/Shaders/geometry.vertex.js +46 -2
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +12 -6
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/iblShadowVoxelTracing.fragment.d.ts +1 -0
- package/Shaders/iblShadowVoxelTracing.fragment.js +7 -6
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/iblVoxelGrid.fragment.d.ts +1 -0
- package/Shaders/iblVoxelGrid.fragment.js +33 -5
- package/Shaders/iblVoxelGrid.fragment.js.map +1 -1
- package/Shaders/lod3D.fragment.d.ts +5 -0
- package/Shaders/lod3D.fragment.js +13 -0
- package/Shaders/lod3D.fragment.js.map +1 -0
- package/Shaders/openpbr.fragment.d.ts +3 -1
- package/Shaders/openpbr.fragment.js +74 -8
- package/Shaders/openpbr.fragment.js.map +1 -1
- package/Shaders/openpbr.vertex.js +11 -5
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +5 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +3 -2
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js +101 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +44 -19
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +39 -13
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +14 -34
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +5 -3
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrSubsurfaceLayerData.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrSubsurfaceLayerData.js +35 -0
- package/ShadersWGSL/ShadersInclude/openpbrSubsurfaceLayerData.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js +68 -0
- package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +15 -4
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +2 -2
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentReflectionDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentReflectionDeclaration.js +39 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentReflectionDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -28
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.d.ts +11 -0
- package/ShadersWGSL/geometry.fragment.js +103 -1
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.d.ts +1 -0
- package/ShadersWGSL/geometry.vertex.js +47 -3
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +14 -7
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.d.ts +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +8 -8
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -1
- package/ShadersWGSL/lod3D.fragment.d.ts +5 -0
- package/ShadersWGSL/lod3D.fragment.js +13 -0
- package/ShadersWGSL/lod3D.fragment.js.map +1 -0
- package/ShadersWGSL/openpbr.fragment.d.ts +3 -1
- package/ShadersWGSL/openpbr.fragment.js +75 -9
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +6 -0
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/XR/webXRSessionManager.js +7 -5
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +4 -0
- package/scene.d.ts +7 -0
- package/scene.js +13 -0
- package/scene.js.map +1 -1
- package/Shaders/iblVoxelGrid3dDebug.fragment.js +0 -24
- package/Shaders/iblVoxelGrid3dDebug.fragment.js.map +0 -1
- package/Shaders/iblVoxelSlabDebug.fragment.js +0 -13
- package/Shaders/iblVoxelSlabDebug.fragment.js.map +0 -1
- package/Shaders/iblVoxelSlabDebug.vertex.js +0 -11
- package/Shaders/iblVoxelSlabDebug.vertex.js.map +0 -1
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js +0 -23
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js +0 -14
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.d.ts +0 -5
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +0 -12
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneUboDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/sceneUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;CAKd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"sceneUboDeclaration\";\nconst shader = `layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;mat4 projection;vec4 vEyePosition;};\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const sceneUboDeclaration = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"sceneUboDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/sceneUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;CAKd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"sceneUboDeclaration\";\nconst shader = `layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;mat4 projection;vec4 vEyePosition;mat4 inverseProjection;};\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const sceneUboDeclaration = { name, shader };\n"]}
|
|
@@ -3,8 +3,20 @@ import "./ShadersInclude/mrtFragmentDeclaration.js";
|
|
|
3
3
|
import "./ShadersInclude/bumpFragmentMainFunctions.js";
|
|
4
4
|
import "./ShadersInclude/bumpFragmentFunctions.js";
|
|
5
5
|
import "./ShadersInclude/helperFunctions.js";
|
|
6
|
+
import "./ShadersInclude/pbrFragmentReflectionDeclaration.js";
|
|
7
|
+
import "./ShadersInclude/sceneFragmentDeclaration.js";
|
|
8
|
+
import "./ShadersInclude/sceneUboDeclaration.js";
|
|
9
|
+
import "./ShadersInclude/pbrBRDFFunctions.js";
|
|
10
|
+
import "./ShadersInclude/openpbrDielectricReflectance.js";
|
|
11
|
+
import "./ShadersInclude/pbrIBLFunctions.js";
|
|
12
|
+
import "./ShadersInclude/reflectionFunction.js";
|
|
13
|
+
import "./ShadersInclude/openpbrGeometryInfo.js";
|
|
14
|
+
import "./ShadersInclude/openpbrIblFunctions.js";
|
|
15
|
+
import "./ShadersInclude/samplerFragmentDeclaration.js";
|
|
6
16
|
import "./ShadersInclude/clipPlaneFragment.js";
|
|
7
17
|
import "./ShadersInclude/bumpFragment.js";
|
|
18
|
+
import "./ShadersInclude/openpbrSubsurfaceLayerData.js";
|
|
19
|
+
import "./ShadersInclude/openpbrTransmissionLayerData.js";
|
|
8
20
|
/** @internal */
|
|
9
21
|
export declare const geometryPixelShader: {
|
|
10
22
|
name: string;
|
|
@@ -5,8 +5,20 @@ import "./ShadersInclude/mrtFragmentDeclaration.js";
|
|
|
5
5
|
import "./ShadersInclude/bumpFragmentMainFunctions.js";
|
|
6
6
|
import "./ShadersInclude/bumpFragmentFunctions.js";
|
|
7
7
|
import "./ShadersInclude/helperFunctions.js";
|
|
8
|
+
import "./ShadersInclude/pbrFragmentReflectionDeclaration.js";
|
|
9
|
+
import "./ShadersInclude/sceneFragmentDeclaration.js";
|
|
10
|
+
import "./ShadersInclude/sceneUboDeclaration.js";
|
|
11
|
+
import "./ShadersInclude/pbrBRDFFunctions.js";
|
|
12
|
+
import "./ShadersInclude/openpbrDielectricReflectance.js";
|
|
13
|
+
import "./ShadersInclude/pbrIBLFunctions.js";
|
|
14
|
+
import "./ShadersInclude/reflectionFunction.js";
|
|
15
|
+
import "./ShadersInclude/openpbrGeometryInfo.js";
|
|
16
|
+
import "./ShadersInclude/openpbrIblFunctions.js";
|
|
17
|
+
import "./ShadersInclude/samplerFragmentDeclaration.js";
|
|
8
18
|
import "./ShadersInclude/clipPlaneFragment.js";
|
|
9
19
|
import "./ShadersInclude/bumpFragment.js";
|
|
20
|
+
import "./ShadersInclude/openpbrSubsurfaceLayerData.js";
|
|
21
|
+
import "./ShadersInclude/openpbrTransmissionLayerData.js";
|
|
10
22
|
const name = "geometryPixelShader";
|
|
11
23
|
const shader = `#extension GL_EXT_draw_buffers : require
|
|
12
24
|
#if defined(BUMP) || !defined(NORMAL)
|
|
@@ -19,7 +31,7 @@ varying mat4 vWorldView;varying vec3 vNormalW;
|
|
|
19
31
|
varying vec3 vNormalV;
|
|
20
32
|
#endif
|
|
21
33
|
varying vec4 vViewPos;
|
|
22
|
-
#if defined(POSITION) || defined(BUMP)
|
|
34
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
23
35
|
varying vec3 vPositionW;
|
|
24
36
|
#endif
|
|
25
37
|
#if defined(VELOCITY) || defined(VELOCITY_LINEAR)
|
|
@@ -66,6 +78,33 @@ uniform sampler2D diffuseSampler;
|
|
|
66
78
|
#include<bumpFragmentMainFunctions>
|
|
67
79
|
#include<bumpFragmentFunctions>
|
|
68
80
|
#include<helperFunctions>
|
|
81
|
+
#ifdef IRRADIANCE
|
|
82
|
+
#include<pbrFragmentReflectionDeclaration>
|
|
83
|
+
#ifdef REFLECTION
|
|
84
|
+
#ifdef USEIRRADIANCEMAP
|
|
85
|
+
#include<__decl__sceneFragment>
|
|
86
|
+
uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionDominantDirection;
|
|
87
|
+
#include<pbrBRDFFunctions>
|
|
88
|
+
#include<openpbrDielectricReflectance>
|
|
89
|
+
#include<pbrIBLFunctions>
|
|
90
|
+
#include<reflectionFunction>
|
|
91
|
+
#include<openpbrGeometryInfo>
|
|
92
|
+
#include<openpbrIblFunctions>
|
|
93
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
94
|
+
varying vec3 vEnvironmentIrradiance;
|
|
95
|
+
#endif
|
|
96
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
97
|
+
uniform sampler2D iblShadowSampler;uniform vec2 shadowTextureSize;
|
|
98
|
+
#endif
|
|
99
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
100
|
+
uniform float vSubsurfaceWeight;
|
|
101
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
|
|
102
|
+
uniform float vSubsurfaceScatterAnisotropy;uniform float vTransmissionWeight;
|
|
103
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
|
|
104
|
+
uniform float vTransmissionScatterAnisotropy;
|
|
105
|
+
#endif
|
|
106
|
+
#endif
|
|
107
|
+
#endif
|
|
69
108
|
void main() {
|
|
70
109
|
#include<clipPlaneFragment>
|
|
71
110
|
#ifdef ALPHATEST
|
|
@@ -156,6 +195,68 @@ reflectivity.a*=glossiness;
|
|
|
156
195
|
#endif
|
|
157
196
|
gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
|
|
158
197
|
#endif
|
|
198
|
+
#ifdef IRRADIANCE
|
|
199
|
+
vec3 irradiance=vec3(0.0);float irradiance_alpha=1.0;
|
|
200
|
+
#ifdef REFLECTION
|
|
201
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
202
|
+
vec3 vSubsurfaceColor=vec3(1.0);float vSubsurfaceRadius=0.0;vec3 vSubsurfaceRadiusScale=vec3(1.0);
|
|
203
|
+
#include<openpbrSubsurfaceLayerData>
|
|
204
|
+
float vTransmissionDepth=1.0;vec3 vTransmissionColor=vec3(1.0);vec3 vTransmissionScatter=vec3(0.0);float vTransmissionDispersionScale=0.0;float vTransmissionDispersionAbbeNumber=0.0;
|
|
205
|
+
#include<openpbrTransmissionLayerData>
|
|
206
|
+
#endif
|
|
207
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
208
|
+
#ifdef COLORED_IBL_SHADOWS
|
|
209
|
+
vec3 iblShadowValue=texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).rgb;
|
|
210
|
+
#else
|
|
211
|
+
vec3 iblShadowValue=vec3(texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).r);
|
|
212
|
+
#endif
|
|
213
|
+
#endif
|
|
214
|
+
#if defined(USEIRRADIANCEMAP)
|
|
215
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
216
|
+
float bendAmount=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);bendAmount=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);vec3 viewVector=normalize(vEyePosition.xyz-vPositionW.xyz);vec3 bentNormal=mix(normalOutput,viewVector,bendAmount*dot(normalOutput,viewVector));
|
|
217
|
+
#else
|
|
218
|
+
vec3 bentNormal=normalOutput;
|
|
219
|
+
#endif
|
|
220
|
+
irradiance=sampleIrradiance(
|
|
221
|
+
bentNormal
|
|
222
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
223
|
+
,vEnvironmentIrradiance
|
|
224
|
+
#endif
|
|
225
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
226
|
+
,reflectionMatrix
|
|
227
|
+
#endif
|
|
228
|
+
#ifdef USEIRRADIANCEMAP
|
|
229
|
+
,irradianceSampler
|
|
230
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
231
|
+
,vReflectionDominantDirection
|
|
232
|
+
#endif
|
|
233
|
+
#endif
|
|
234
|
+
#ifdef REALTIME_FILTERING
|
|
235
|
+
,vReflectionFilteringInfo
|
|
236
|
+
#ifdef IBL_CDF_FILTERING
|
|
237
|
+
,icdfSampler
|
|
238
|
+
#endif
|
|
239
|
+
#endif
|
|
240
|
+
,vReflectionInfos
|
|
241
|
+
,vViewPos.xyz
|
|
242
|
+
,1.0
|
|
243
|
+
,vec3(1.0)
|
|
244
|
+
);
|
|
245
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
246
|
+
irradiance=vEnvironmentIrradiance;
|
|
247
|
+
#endif
|
|
248
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
249
|
+
irradiance*=iblShadowValue;
|
|
250
|
+
#endif
|
|
251
|
+
#ifndef BUMP
|
|
252
|
+
vec2 uvOffset=vec2(0.0);
|
|
253
|
+
#endif
|
|
254
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
255
|
+
irradiance_alpha=min(subsurface_weight+transmission_weight,1.0);
|
|
256
|
+
#endif
|
|
257
|
+
#endif
|
|
258
|
+
gl_FragData[IRRADIANCE_INDEX]=vec4(irradiance,irradiance_alpha);
|
|
259
|
+
#endif
|
|
159
260
|
}
|
|
160
261
|
`;
|
|
161
262
|
// Sideeffect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/geometry.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,yCAAyC,CAAC;AACjD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,+BAA+B,CAAC;AAEvC,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqJd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/mrtFragmentDeclaration\";\nimport \"./ShadersInclude/bumpFragmentMainFunctions\";\nimport \"./ShadersInclude/bumpFragmentFunctions\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/bumpFragment\";\n\nconst name = \"geometryPixelShader\";\nconst shader = `#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;varying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#if defined(VELOCITY) || defined(VELOCITY_LINEAR)\nvarying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY)\n#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nuniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;\n#else\n#ifdef METALLIC_TEXTURE\nuniform sampler2D metallicSampler;varying vec2 vMetallicUV;\n#endif\n#ifdef ROUGHNESS_TEXTURE\nuniform sampler2D roughnessSampler;varying vec2 vRoughnessUV;\n#endif\n#endif\n#ifdef ALBEDOTEXTURE\nvarying vec2 vAlbedoUV;uniform sampler2D albedoSampler;\n#endif\n#ifdef REFLECTIVITYCOLOR\nuniform vec3 reflectivityColor;\n#endif\n#ifdef ALBEDOCOLOR\nuniform vec3 albedoColor;\n#endif\n#ifdef METALLIC\nuniform float metallic;\n#endif\n#if defined(ROUGHNESS) || defined(GLOSSINESS)\nuniform float glossiness;\n#endif\n#endif\n#if defined(ALPHATEST) && defined(NEED_UV)\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<mrtFragmentDeclaration>[SCENE_MRT_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<helperFunctions>\nvoid main() {\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\n#ifdef NORMAL_WORLDSPACE\nnormalOutput=normalW;\n#else\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#endif\n#elif defined(HAS_NORMAL_ATTRIBUTE)\nnormalOutput=normalize(vNormalV);\n#elif defined(POSITION)\nnormalOutput=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#ifdef ENCODE_NORMAL\nnormalOutput=normalOutput*0.5+0.5;\n#endif\n#ifdef DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#ifdef SCREENSPACE_DEPTH\ngl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef VELOCITY_LINEAR\nvec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -\n(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#ifdef METALLICWORKFLOW\nfloat metal=1.0;float roughness=1.0;\n#ifdef ORMTEXTURE\nmetal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;\n#else\n#ifdef METALLIC_TEXTURE\nmetal*=texture2D(metallicSampler,vMetallicUV).r;\n#endif\n#ifdef ROUGHNESS_TEXTURE\nroughness*=texture2D(roughnessSampler,vRoughnessUV).r;\n#endif\n#endif\n#ifdef METALLIC\nmetal*=metallic;\n#endif\n#ifdef ROUGHNESS\nroughness*=(1.0-glossiness); \n#endif\nreflectivity.a-=roughness;vec3 color=vec3(1.0);\n#ifdef ALBEDOTEXTURE\ncolor=texture2D(albedoSampler,vAlbedoUV).rgb;\n#ifdef GAMMAALBEDO\ncolor=toLinearSpace(color);\n#endif\n#endif\n#ifdef ALBEDOCOLOR\ncolor*=albedoColor.xyz;\n#endif\nreflectivity.rgb=mix(vec3(0.04),color,metal);\n#else\n#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nreflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#ifdef GAMMAREFLECTIVITYTEXTURE\nreflectivity.rgb=toLinearSpace(reflectivity.rgb);\n#endif\n#else \n#ifdef REFLECTIVITYCOLOR\nreflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;\n#endif\n#endif\n#ifdef GLOSSINESSS\nreflectivity.a*=glossiness; \n#endif\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const geometryPixelShader = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"geometry.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/geometry.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,yCAAyC,CAAC;AACjD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2CAA2C,CAAC;AACnD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,+CAA+C,CAAC;AACvD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,6CAA6C,CAAC;AACrD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,+BAA+B,CAAC;AACvC,OAAO,6CAA6C,CAAC;AACrD,OAAO,+CAA+C,CAAC;AAEvD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Od,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/mrtFragmentDeclaration\";\nimport \"./ShadersInclude/bumpFragmentMainFunctions\";\nimport \"./ShadersInclude/bumpFragmentFunctions\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/pbrFragmentReflectionDeclaration\";\nimport \"./ShadersInclude/sceneFragmentDeclaration\";\nimport \"./ShadersInclude/sceneUboDeclaration\";\nimport \"./ShadersInclude/pbrBRDFFunctions\";\nimport \"./ShadersInclude/openpbrDielectricReflectance\";\nimport \"./ShadersInclude/pbrIBLFunctions\";\nimport \"./ShadersInclude/reflectionFunction\";\nimport \"./ShadersInclude/openpbrGeometryInfo\";\nimport \"./ShadersInclude/openpbrIblFunctions\";\nimport \"./ShadersInclude/samplerFragmentDeclaration\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/bumpFragment\";\nimport \"./ShadersInclude/openpbrSubsurfaceLayerData\";\nimport \"./ShadersInclude/openpbrTransmissionLayerData\";\n\nconst name = \"geometryPixelShader\";\nconst shader = `#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;varying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)\nvarying vec3 vPositionW;\n#endif\n#if defined(VELOCITY) || defined(VELOCITY_LINEAR)\nvarying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY)\n#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nuniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;\n#else\n#ifdef METALLIC_TEXTURE\nuniform sampler2D metallicSampler;varying vec2 vMetallicUV;\n#endif\n#ifdef ROUGHNESS_TEXTURE\nuniform sampler2D roughnessSampler;varying vec2 vRoughnessUV;\n#endif\n#endif\n#ifdef ALBEDOTEXTURE\nvarying vec2 vAlbedoUV;uniform sampler2D albedoSampler;\n#endif\n#ifdef REFLECTIVITYCOLOR\nuniform vec3 reflectivityColor;\n#endif\n#ifdef ALBEDOCOLOR\nuniform vec3 albedoColor;\n#endif\n#ifdef METALLIC\nuniform float metallic;\n#endif\n#if defined(ROUGHNESS) || defined(GLOSSINESS)\nuniform float glossiness;\n#endif\n#endif\n#if defined(ALPHATEST) && defined(NEED_UV)\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<mrtFragmentDeclaration>[SCENE_MRT_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<helperFunctions>\n#ifdef IRRADIANCE\n#include<pbrFragmentReflectionDeclaration>\n#ifdef REFLECTION\n#ifdef USEIRRADIANCEMAP\n#include<__decl__sceneFragment>\nuniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionDominantDirection;\n#include<pbrBRDFFunctions>\n#include<openpbrDielectricReflectance>\n#include<pbrIBLFunctions>\n#include<reflectionFunction>\n#include<openpbrGeometryInfo>\n#include<openpbrIblFunctions>\n#elif defined(USESPHERICALFROMREFLECTIONMAP)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#ifdef IBL_SHADOW_TEXTURE\nuniform sampler2D iblShadowSampler;uniform vec2 shadowTextureSize;\n#endif\n#ifdef IRRADIANCE_SCATTER_MASK\nuniform float vSubsurfaceWeight;\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)\nuniform float vSubsurfaceScatterAnisotropy;uniform float vTransmissionWeight;\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)\nuniform float vTransmissionScatterAnisotropy;\n#endif\n#endif\n#endif\nvoid main() {\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\n#ifdef NORMAL_WORLDSPACE\nnormalOutput=normalW;\n#else\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#endif\n#elif defined(HAS_NORMAL_ATTRIBUTE)\nnormalOutput=normalize(vNormalV);\n#elif defined(POSITION)\nnormalOutput=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#ifdef ENCODE_NORMAL\nnormalOutput=normalOutput*0.5+0.5;\n#endif\n#ifdef DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#ifdef SCREENSPACE_DEPTH\ngl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef VELOCITY_LINEAR\nvec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -\n(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#ifdef METALLICWORKFLOW\nfloat metal=1.0;float roughness=1.0;\n#ifdef ORMTEXTURE\nmetal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;\n#else\n#ifdef METALLIC_TEXTURE\nmetal*=texture2D(metallicSampler,vMetallicUV).r;\n#endif\n#ifdef ROUGHNESS_TEXTURE\nroughness*=texture2D(roughnessSampler,vRoughnessUV).r;\n#endif\n#endif\n#ifdef METALLIC\nmetal*=metallic;\n#endif\n#ifdef ROUGHNESS\nroughness*=(1.0-glossiness); \n#endif\nreflectivity.a-=roughness;vec3 color=vec3(1.0);\n#ifdef ALBEDOTEXTURE\ncolor=texture2D(albedoSampler,vAlbedoUV).rgb;\n#ifdef GAMMAALBEDO\ncolor=toLinearSpace(color);\n#endif\n#endif\n#ifdef ALBEDOCOLOR\ncolor*=albedoColor.xyz;\n#endif\nreflectivity.rgb=mix(vec3(0.04),color,metal);\n#else\n#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)\nreflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#ifdef GAMMAREFLECTIVITYTEXTURE\nreflectivity.rgb=toLinearSpace(reflectivity.rgb);\n#endif\n#else \n#ifdef REFLECTIVITYCOLOR\nreflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;\n#endif\n#endif\n#ifdef GLOSSINESSS\nreflectivity.a*=glossiness; \n#endif\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n#ifdef IRRADIANCE\nvec3 irradiance=vec3(0.0);float irradiance_alpha=1.0;\n#ifdef REFLECTION\n#ifdef IRRADIANCE_SCATTER_MASK\nvec3 vSubsurfaceColor=vec3(1.0);float vSubsurfaceRadius=0.0;vec3 vSubsurfaceRadiusScale=vec3(1.0);\n#include<openpbrSubsurfaceLayerData>\nfloat vTransmissionDepth=1.0;vec3 vTransmissionColor=vec3(1.0);vec3 vTransmissionScatter=vec3(0.0);float vTransmissionDispersionScale=0.0;float vTransmissionDispersionAbbeNumber=0.0;\n#include<openpbrTransmissionLayerData>\n#endif\n#ifdef IBL_SHADOW_TEXTURE\n#ifdef COLORED_IBL_SHADOWS\nvec3 iblShadowValue=texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).rgb;\n#else\nvec3 iblShadowValue=vec3(texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).r);\n#endif\n#endif\n#if defined(USEIRRADIANCEMAP)\n#ifdef IRRADIANCE_SCATTER_MASK\nfloat bendAmount=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);bendAmount=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);vec3 viewVector=normalize(vEyePosition.xyz-vPositionW.xyz);vec3 bentNormal=mix(normalOutput,viewVector,bendAmount*dot(normalOutput,viewVector));\n#else\nvec3 bentNormal=normalOutput;\n#endif\nirradiance=sampleIrradiance(\nbentNormal\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n#endif\n,vReflectionInfos\n,vViewPos.xyz\n,1.0\n,vec3(1.0)\n);\n#elif defined(USESPHERICALFROMREFLECTIONMAP)\nirradiance=vEnvironmentIrradiance;\n#endif\n#ifdef IBL_SHADOW_TEXTURE\nirradiance*=iblShadowValue;\n#endif\n#ifndef BUMP\nvec2 uvOffset=vec2(0.0);\n#endif\n#ifdef IRRADIANCE_SCATTER_MASK\nirradiance_alpha=min(subsurface_weight+transmission_weight,1.0);\n#endif\n#endif\ngl_FragData[IRRADIANCE_INDEX]=vec4(irradiance,irradiance_alpha);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const geometryPixelShader = { name, shader };\n"]}
|
|
@@ -6,6 +6,7 @@ import "./ShadersInclude/instancesDeclaration.js";
|
|
|
6
6
|
import "./ShadersInclude/geometryVertexDeclaration.js";
|
|
7
7
|
import "./ShadersInclude/geometryUboDeclaration.js";
|
|
8
8
|
import "./ShadersInclude/clipPlaneVertexDeclaration.js";
|
|
9
|
+
import "./ShadersInclude/harmonicsFunctions.js";
|
|
9
10
|
import "./ShadersInclude/morphTargetsVertexGlobal.js";
|
|
10
11
|
import "./ShadersInclude/morphTargetsVertex.js";
|
|
11
12
|
import "./ShadersInclude/instancesVertex.js";
|
|
@@ -8,6 +8,7 @@ import "./ShadersInclude/instancesDeclaration.js";
|
|
|
8
8
|
import "./ShadersInclude/geometryVertexDeclaration.js";
|
|
9
9
|
import "./ShadersInclude/geometryUboDeclaration.js";
|
|
10
10
|
import "./ShadersInclude/clipPlaneVertexDeclaration.js";
|
|
11
|
+
import "./ShadersInclude/harmonicsFunctions.js";
|
|
11
12
|
import "./ShadersInclude/morphTargetsVertexGlobal.js";
|
|
12
13
|
import "./ShadersInclude/morphTargetsVertex.js";
|
|
13
14
|
import "./ShadersInclude/instancesVertex.js";
|
|
@@ -24,6 +25,20 @@ const shader = `precision highp float;
|
|
|
24
25
|
#include<instancesDeclaration>
|
|
25
26
|
#include<__decl__geometryVertex>
|
|
26
27
|
#include<clipPlaneVertexDeclaration>
|
|
28
|
+
#ifdef IRRADIANCE
|
|
29
|
+
#ifdef REFLECTION
|
|
30
|
+
uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionColor;
|
|
31
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
32
|
+
varying vec3 vEnvironmentIrradiance;
|
|
33
|
+
#ifdef SPHERICAL_HARMONICS
|
|
34
|
+
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
|
35
|
+
#else
|
|
36
|
+
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
|
37
|
+
#endif
|
|
38
|
+
#include<harmonicsFunctions>
|
|
39
|
+
#endif
|
|
40
|
+
#endif
|
|
41
|
+
#endif
|
|
27
42
|
attribute vec3 position;
|
|
28
43
|
#ifdef HAS_NORMAL_ATTRIBUTE
|
|
29
44
|
attribute vec3 normal;
|
|
@@ -45,6 +60,12 @@ varying vec2 vMetallicUV;uniform mat4 metallicMatrix;
|
|
|
45
60
|
#ifdef ROUGHNESS_TEXTURE
|
|
46
61
|
varying vec2 vRoughnessUV;uniform mat4 roughnessMatrix;
|
|
47
62
|
#endif
|
|
63
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
64
|
+
varying vec2 vSubsurfaceWeightUV;uniform mat4 subsurfaceWeightMatrix;
|
|
65
|
+
#endif
|
|
66
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
67
|
+
varying vec2 vTransmissionWeightUV;uniform mat4 transmissionWeightMatrix;
|
|
68
|
+
#endif
|
|
48
69
|
#ifdef UV1
|
|
49
70
|
attribute vec2 uv;
|
|
50
71
|
#endif
|
|
@@ -61,7 +82,7 @@ varying vec3 vNormalW;
|
|
|
61
82
|
varying vec3 vNormalV;
|
|
62
83
|
#endif
|
|
63
84
|
varying vec4 vViewPos;
|
|
64
|
-
#if defined(POSITION) || defined(BUMP)
|
|
85
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
65
86
|
varying vec3 vPositionW;
|
|
66
87
|
#endif
|
|
67
88
|
#if defined(VELOCITY) || defined(VELOCITY_LINEAR)
|
|
@@ -130,7 +151,7 @@ vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*ve
|
|
|
130
151
|
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
|
131
152
|
#endif
|
|
132
153
|
#endif
|
|
133
|
-
#if defined(POSITION) || defined(BUMP)
|
|
154
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
134
155
|
vPositionW=worldPos.xyz/worldPos.w;
|
|
135
156
|
#endif
|
|
136
157
|
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
|
@@ -158,6 +179,12 @@ vRoughnessUV=vec2(roughnessMatrix*vec4(uvUpdated,1.0,0.0));
|
|
|
158
179
|
#ifdef ALBEDO_UV1
|
|
159
180
|
vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
|
|
160
181
|
#endif
|
|
182
|
+
#ifdef SUBSURFACE_COLOR_UV1
|
|
183
|
+
vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uvUpdated,1.0,0.0));
|
|
184
|
+
#endif
|
|
185
|
+
#ifdef SUBSURFACE_WEIGHT_UV1
|
|
186
|
+
vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uvUpdated,1.0,0.0));
|
|
187
|
+
#endif
|
|
161
188
|
#endif
|
|
162
189
|
#ifdef UV2
|
|
163
190
|
#if defined(ALPHATEST) && defined(ALPHATEST_UV2)
|
|
@@ -181,9 +208,26 @@ vRoughnessUV=vec2(roughnessMatrix*vec4(uv2Updated,1.0,0.0));
|
|
|
181
208
|
#ifdef ALBEDO_UV2
|
|
182
209
|
vAlbedoUV=vec2(albedoMatrix*vec4(uv2Updated,1.0,0.0));
|
|
183
210
|
#endif
|
|
211
|
+
#ifdef SUBSURFACE_COLOR_UV2
|
|
212
|
+
vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uv2Updated,1.0,0.0));
|
|
213
|
+
#endif
|
|
214
|
+
#ifdef SUBSURFACE_WEIGHT_UV2
|
|
215
|
+
vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uv2Updated,1.0,0.0));
|
|
216
|
+
#endif
|
|
184
217
|
#endif
|
|
185
218
|
#endif
|
|
186
219
|
#include<bumpVertex>
|
|
220
|
+
#ifdef IRRADIANCE
|
|
221
|
+
#ifdef REFLECTION
|
|
222
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
223
|
+
vec3 reflectionVector=vec3(reflectionMatrix*vec4(normalUpdated,0.0)).xyz;
|
|
224
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
225
|
+
reflectionVector.z*=-1.0;
|
|
226
|
+
#endif
|
|
227
|
+
vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*vReflectionInfos.x;
|
|
228
|
+
#endif
|
|
229
|
+
#endif
|
|
230
|
+
#endif
|
|
187
231
|
}
|
|
188
232
|
`;
|
|
189
233
|
// Sideeffect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/geometry.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,gDAAgD,CAAC;AACxD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,4CAA4C,CAAC;AACpD,OAAO,yCAAyC,CAAC;AACjD,OAAO,6CAA6C,CAAC;AACrD,OAAO,2CAA2C,CAAC;AACnD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,8BAA8B,CAAC;AACtC,OAAO,uCAAuC,CAAC;AAC/C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6BAA6B,CAAC;AAErC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"geometry.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/geometry.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,gDAAgD,CAAC;AACxD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,4CAA4C,CAAC;AACpD,OAAO,yCAAyC,CAAC;AACjD,OAAO,6CAA6C,CAAC;AACrD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2CAA2C,CAAC;AACnD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,8BAA8B,CAAC;AACtC,OAAO,uCAAuC,CAAC;AAC/C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6BAA6B,CAAC;AAErC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoNd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/bonesDeclaration\";\nimport \"./ShadersInclude/bakedVertexAnimationDeclaration\";\nimport \"./ShadersInclude/morphTargetsVertexGlobalDeclaration\";\nimport \"./ShadersInclude/morphTargetsVertexDeclaration\";\nimport \"./ShadersInclude/instancesDeclaration\";\nimport \"./ShadersInclude/geometryVertexDeclaration\";\nimport \"./ShadersInclude/geometryUboDeclaration\";\nimport \"./ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"./ShadersInclude/harmonicsFunctions\";\nimport \"./ShadersInclude/morphTargetsVertexGlobal\";\nimport \"./ShadersInclude/morphTargetsVertex\";\nimport \"./ShadersInclude/instancesVertex\";\nimport \"./ShadersInclude/bonesVertex\";\nimport \"./ShadersInclude/bakedVertexAnimation\";\nimport \"./ShadersInclude/clipPlaneVertex\";\nimport \"./ShadersInclude/bumpVertex\";\n\nconst name = \"geometryVertexShader\";\nconst shader = `precision highp float;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\n#include<__decl__geometryVertex>\n#include<clipPlaneVertexDeclaration>\n#ifdef IRRADIANCE\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionColor;\n#ifdef USESPHERICALFROMREFLECTIONMAP\nvarying vec3 vEnvironmentIrradiance;\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;\n#endif\n#include<harmonicsFunctions>\n#endif\n#endif\n#endif\nattribute vec3 position;\n#ifdef HAS_NORMAL_ATTRIBUTE\nattribute vec3 normal;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;varying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;\n#endif\n#ifdef METALLIC_TEXTURE\nvarying vec2 vMetallicUV;uniform mat4 metallicMatrix;\n#endif\n#ifdef ROUGHNESS_TEXTURE\nvarying vec2 vRoughnessUV;uniform mat4 roughnessMatrix;\n#endif\n#ifdef SUBSURFACE_WEIGHT\nvarying vec2 vSubsurfaceWeightUV;uniform mat4 subsurfaceWeightMatrix;\n#endif\n#ifdef TRANSMISSION_WEIGHT\nvarying vec2 vTransmissionWeightUV;uniform mat4 transmissionWeightMatrix;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)\nvarying vec3 vPositionW;\n#endif\n#if defined(VELOCITY) || defined(VELOCITY_LINEAR)\nuniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef HAS_NORMAL_ATTRIBUTE\nvec3 normalUpdated=normal;\n#else\nvec3 normalUpdated=vec3(0.0,0.0,0.0);\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef UV2\nvec2 uv2Updated=uv2;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;mat3 normalWorld=mat3(finalWorld);vNormalW=normalize(normalWorld*normalUpdated);\n#else\n#ifdef NORMAL_WORLDSPACE\nvNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\n#endif\nvViewPos=view*worldPos;\n#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)\nvPositionW=worldPos.xyz/worldPos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#include<clipPlaneVertex>\n#ifdef NEED_UV\n#ifdef UV1\n#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uvUpdated;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#else\n#ifdef METALLIC_UV1\nvMetallicUV=vec2(metallicMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef ROUGHNESS_UV1\nvRoughnessUV=vec2(roughnessMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef ALBEDO_UV1\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef SUBSURFACE_COLOR_UV1\nvSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef SUBSURFACE_WEIGHT_UV1\nvSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0));\n#else\nvUV=uv2Updated;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2Updated,1.0,0.0));\n#else\n#ifdef METALLIC_UV2\nvMetallicUV=vec2(metallicMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef ROUGHNESS_UV2\nvRoughnessUV=vec2(roughnessMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#endif\n#ifdef ALBEDO_UV2\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef SUBSURFACE_COLOR_UV2\nvSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#ifdef SUBSURFACE_WEIGHT_UV2\nvSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uv2Updated,1.0,0.0));\n#endif\n#endif\n#endif\n#include<bumpVertex>\n#ifdef IRRADIANCE\n#ifdef REFLECTION\n#ifdef USESPHERICALFROMREFLECTIONMAP\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(normalUpdated,0.0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*vReflectionInfos.x;\n#endif\n#endif\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const geometryVertexShader = { name, shader };\n"]}
|
|
@@ -121,6 +121,9 @@ uniform vec3 noiseStrength;uniform sampler2D noiseSampler;
|
|
|
121
121
|
#ifdef ANIMATESHEET
|
|
122
122
|
uniform vec4 cellInfos;
|
|
123
123
|
#endif
|
|
124
|
+
#ifdef ATTRACTORS
|
|
125
|
+
uniform int attractorCount;uniform vec4 attractorPositionAndStrength[MAX_ATTRACTORS];
|
|
126
|
+
#endif
|
|
124
127
|
vec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}
|
|
125
128
|
vec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}
|
|
126
129
|
void main() {float newAge=age+timeDelta;
|
|
@@ -138,7 +141,7 @@ outAge=newAge-life;
|
|
|
138
141
|
#endif
|
|
139
142
|
outSeed=seed;
|
|
140
143
|
#ifdef SIZEGRADIENTS
|
|
141
|
-
|
|
144
|
+
vec2 sizeGradientRange=texture(sizeGradientSampler,vec2(0,0)).rg;outSize.x=sizeGradientRange.x+(sizeGradientRange.y-sizeGradientRange.x)*seed.y;
|
|
142
145
|
#else
|
|
143
146
|
outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;
|
|
144
147
|
#endif
|
|
@@ -223,10 +226,10 @@ outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;
|
|
|
223
226
|
#endif
|
|
224
227
|
} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;
|
|
225
228
|
#ifdef VELOCITYGRADIENTS
|
|
226
|
-
|
|
229
|
+
vec2 velocityGradientRange=texture(velocityGradientSampler,vec2(ageGradient,0)).rg;directionScale*=velocityGradientRange.x+(velocityGradientRange.y-velocityGradientRange.x)*seed.w;
|
|
227
230
|
#endif
|
|
228
231
|
#ifdef DRAGGRADIENTS
|
|
229
|
-
|
|
232
|
+
vec2 dragGradientRange=texture(dragGradientSampler,vec2(ageGradient,0)).rg;directionScale*=1.0-(dragGradientRange.x+(dragGradientRange.y-dragGradientRange.x)*seed.x);
|
|
230
233
|
#endif
|
|
231
234
|
#if defined(CUSTOMEMITTER)
|
|
232
235
|
outPosition=position+(direction-position)*ageGradient;
|
|
@@ -239,7 +242,7 @@ outLife=life;outSeed=seed;
|
|
|
239
242
|
outColor=color;
|
|
240
243
|
#endif
|
|
241
244
|
#ifdef SIZEGRADIENTS
|
|
242
|
-
|
|
245
|
+
vec2 sizeGradientRange=texture(sizeGradientSampler,vec2(ageGradient,0)).rg;outSize.x=sizeGradientRange.x+(sizeGradientRange.y-sizeGradientRange.x)*seed.y;outSize.yz=size.yz;
|
|
243
246
|
#else
|
|
244
247
|
outSize=size;
|
|
245
248
|
#endif
|
|
@@ -254,7 +257,10 @@ vec3 updatedDirection=direction+gravity*timeDelta;
|
|
|
254
257
|
vec4 clipSpace=(flowMapProjection*vec4(position,1.));vec3 ndcSpace=clipSpace.xyz/clipSpace.w;vec2 flowMapUV=ndcSpace.xy*0.5+0.5;vec4 flowMapValue=texture(flowMapSampler,flowMapUV);vec3 flowMapDirection=(flowMapValue.xyz*2.0-1.0)*flowMapValue.w;updatedDirection+=flowMapDirection*timeDelta*flowMapStrength;
|
|
255
258
|
#endif
|
|
256
259
|
#ifdef LIMITVELOCITYGRADIENTS
|
|
257
|
-
|
|
260
|
+
vec2 limitVelocityRange=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).rg;float limitVelocity=limitVelocityRange.x+(limitVelocityRange.y-limitVelocityRange.x)*seed.y;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}
|
|
261
|
+
#endif
|
|
262
|
+
#ifdef ATTRACTORS
|
|
263
|
+
{for (int i=0; i<attractorCount; i++) {vec3 toAttractor=attractorPositionAndStrength[i].xyz-outPosition;float distSq=dot(toAttractor,toAttractor)+1.0;updatedDirection+=(attractorPositionAndStrength[i].w/distSq)*normalize(toAttractor)*timeDelta;}}
|
|
258
264
|
#endif
|
|
259
265
|
outDirection=updatedDirection;
|
|
260
266
|
#ifdef NOISE
|
|
@@ -262,7 +268,7 @@ float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y
|
|
|
262
268
|
#endif
|
|
263
269
|
#endif
|
|
264
270
|
#ifdef ANGULARSPEEDGRADIENTS
|
|
265
|
-
|
|
271
|
+
vec2 angularSpeedRange=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).rg;float angularSpeed=angularSpeedRange.x+(angularSpeedRange.y-angularSpeedRange.x)*seed.z;outAngle=angle+angularSpeed*timeDelta;
|
|
266
272
|
#else
|
|
267
273
|
outAngle=vec2(angle.x+angle.y*timeDelta,angle.y);
|
|
268
274
|
#endif
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpuUpdateParticles.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/gpuUpdateParticles.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,gCAAgC,CAAC;AAC9C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoRZ,CAAC;AACJ,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"gpuUpdateParticlesVertexShader\";\nconst shader = `#version 300 es\n#define PI 3.14159\nuniform float currentCount;uniform float timeDelta;uniform float stopFactor;uniform float emitIndex;uniform float emitCount;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;uniform vec2 emitPower;uniform vec2 sizeRange;uniform vec4 scaleRange;\n#ifdef FLOWMAP\nuniform mat4 flowMapProjection;uniform float flowMapStrength;uniform sampler2D flowMapSampler;\n#endif\n#ifndef COLORGRADIENTS\nuniform vec4 color1;uniform vec4 color2;\n#endif\nuniform vec3 gravity;uniform sampler2D randomSampler;uniform sampler2D randomSampler2;uniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;uniform vec3 direction2;uniform vec3 minEmitBox;uniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;uniform float radiusRange;uniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;uniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;uniform float height;uniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;uniform float coneAngle;uniform vec2 height;\n#ifdef DIRECTEDCONEEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;in float life;in vec4 seed;in vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;in vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;out float outLife;out vec4 outSeed;out vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;out vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;uniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;uniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}\nvec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}\nvoid main() {float newAge=age+timeDelta;\n#ifdef EMITRATECTRL\nfloat particleIndex=float(gl_VertexID);float offsetFromEmitIndex=particleIndex-emitIndex;if (offsetFromEmitIndex<0.0) {offsetFromEmitIndex+=currentCount; }\nbool shouldEmit=offsetFromEmitIndex<emitCount && stopFactor != 0.;\n#else\nbool shouldEmit=newAge>=life && stopFactor != 0.;\n#endif\nif (shouldEmit) {vec3 newPosition;vec3 newDirection;vec4 randoms=getRandomVec4(seed.x);outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\n#ifdef EMITRATECTRL\noutAge=0.0;\n#else\noutAge=newAge-life;\n#endif\noutSeed=seed;\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=vec3(0,0,0);newDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;newDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float yPos=(randoms2.x-0.5)*height;float angle=randoms2.y*PI*2.;float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));float xPos=positionRadius*cos(angle);float zPos=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;newDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));newDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);float s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;h=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ); \nvec3 randoms3=getRandomVec3(seed.z);\n#ifdef DIRECTEDCONEEMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nif (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {newDirection=normalize(newPosition+directionRandomizer*randoms3); }\n#endif\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;outInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD \noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else \nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient; \noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\noutLife=life;outSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;outSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef FLOWMAP\nvec4 clipSpace=(flowMapProjection*vec4(position,1.));vec3 ndcSpace=clipSpace.xyz/clipSpace.w;vec2 flowMapUV=ndcSpace.xy*0.5+0.5;vec4 flowMapValue=texture(flowMapSampler,flowMapUV);vec3 flowMapDirection=(flowMapValue.xyz*2.0-1.0)*flowMapValue.w;updatedDirection+=flowMapDirection*timeDelta*flowMapStrength;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;outDirection=outDirection+force*timeDelta;outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;outAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;float dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;offsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;if (cellInfos.w==1.0) {ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);}\nelse {ratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const gpuUpdateParticlesVertexShader = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"gpuUpdateParticles.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/gpuUpdateParticles.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,gCAAgC,CAAC;AAC9C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0RZ,CAAC;AACJ,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"gpuUpdateParticlesVertexShader\";\nconst shader = `#version 300 es\n#define PI 3.14159\nuniform float currentCount;uniform float timeDelta;uniform float stopFactor;uniform float emitIndex;uniform float emitCount;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;uniform vec2 emitPower;uniform vec2 sizeRange;uniform vec4 scaleRange;\n#ifdef FLOWMAP\nuniform mat4 flowMapProjection;uniform float flowMapStrength;uniform sampler2D flowMapSampler;\n#endif\n#ifndef COLORGRADIENTS\nuniform vec4 color1;uniform vec4 color2;\n#endif\nuniform vec3 gravity;uniform sampler2D randomSampler;uniform sampler2D randomSampler2;uniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;uniform vec3 direction2;uniform vec3 minEmitBox;uniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;uniform float radiusRange;uniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;uniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;uniform float height;uniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;uniform float coneAngle;uniform vec2 height;\n#ifdef DIRECTEDCONEEMITTER\nuniform vec3 direction1;uniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;in float life;in vec4 seed;in vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;in vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;out float outLife;out vec4 outSeed;out vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;out vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;uniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;uniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\n#ifdef ATTRACTORS\nuniform int attractorCount;uniform vec4 attractorPositionAndStrength[MAX_ATTRACTORS];\n#endif\nvec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}\nvec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}\nvoid main() {float newAge=age+timeDelta;\n#ifdef EMITRATECTRL\nfloat particleIndex=float(gl_VertexID);float offsetFromEmitIndex=particleIndex-emitIndex;if (offsetFromEmitIndex<0.0) {offsetFromEmitIndex+=currentCount; }\nbool shouldEmit=offsetFromEmitIndex<emitCount && stopFactor != 0.;\n#else\nbool shouldEmit=newAge>=life && stopFactor != 0.;\n#endif\nif (shouldEmit) {vec3 newPosition;vec3 newDirection;vec4 randoms=getRandomVec4(seed.x);outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\n#ifdef EMITRATECTRL\noutAge=0.0;\n#else\noutAge=newAge-life;\n#endif\noutSeed=seed;\n#ifdef SIZEGRADIENTS \nvec2 sizeGradientRange=texture(sizeGradientSampler,vec2(0,0)).rg;outSize.x=sizeGradientRange.x+(sizeGradientRange.y-sizeGradientRange.x)*seed.y;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=vec3(0,0,0);newDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;newDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float yPos=(randoms2.x-0.5)*height;float angle=randoms2.y*PI*2.;float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));float xPos=positionRadius*cos(angle);float zPos=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;newDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));newDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);float s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;h=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ); \nvec3 randoms3=getRandomVec3(seed.z);\n#ifdef DIRECTEDCONEEMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nif (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {newDirection=normalize(newPosition+directionRandomizer*randoms3); }\n#endif\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;outInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD \noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else \nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\nvec2 velocityGradientRange=texture(velocityGradientSampler,vec2(ageGradient,0)).rg;directionScale*=velocityGradientRange.x+(velocityGradientRange.y-velocityGradientRange.x)*seed.w;\n#endif\n#ifdef DRAGGRADIENTS\nvec2 dragGradientRange=texture(dragGradientSampler,vec2(ageGradient,0)).rg;directionScale*=1.0-(dragGradientRange.x+(dragGradientRange.y-dragGradientRange.x)*seed.x);\n#endif\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient; \noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\noutLife=life;outSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\nvec2 sizeGradientRange=texture(sizeGradientSampler,vec2(ageGradient,0)).rg;outSize.x=sizeGradientRange.x+(sizeGradientRange.y-sizeGradientRange.x)*seed.y;outSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef FLOWMAP\nvec4 clipSpace=(flowMapProjection*vec4(position,1.));vec3 ndcSpace=clipSpace.xyz/clipSpace.w;vec2 flowMapUV=ndcSpace.xy*0.5+0.5;vec4 flowMapValue=texture(flowMapSampler,flowMapUV);vec3 flowMapDirection=(flowMapValue.xyz*2.0-1.0)*flowMapValue.w;updatedDirection+=flowMapDirection*timeDelta*flowMapStrength;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nvec2 limitVelocityRange=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).rg;float limitVelocity=limitVelocityRange.x+(limitVelocityRange.y-limitVelocityRange.x)*seed.y;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}\n#endif\n#ifdef ATTRACTORS\n{for (int i=0; i<attractorCount; i++) {vec3 toAttractor=attractorPositionAndStrength[i].xyz-outPosition;float distSq=dot(toAttractor,toAttractor)+1.0;updatedDirection+=(attractorPositionAndStrength[i].w/distSq)*normalize(toAttractor)*timeDelta;}}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;outDirection=outDirection+force*timeDelta;outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nvec2 angularSpeedRange=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).rg;float angularSpeed=angularSpeedRange.x+(angularSpeedRange.y-angularSpeedRange.x)*seed.z;outAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;float dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;offsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;if (cellInfos.w==1.0) {ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);}\nelse {ratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const gpuUpdateParticlesVertexShader = { name, shader };\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
import "./ShadersInclude/helperFunctions.js";
|
|
3
4
|
const name = "iblShadowVoxelTracingPixelShader";
|
|
4
5
|
const shader = `precision highp sampler2D;precision highp sampler3D;
|
|
5
|
-
#
|
|
6
|
+
#include<helperFunctions>
|
|
6
7
|
varying vec2 vUV;
|
|
7
8
|
#define DISABLE_UNIFORMITY_ANALYSIS
|
|
8
9
|
uniform sampler2D depthSampler;uniform sampler2D worldNormalSampler;uniform sampler2D blueNoiseSampler;uniform sampler2D icdfSampler;uniform sampler3D voxelGridSampler;
|
|
@@ -21,7 +22,6 @@ uniform vec4 sssParameters;
|
|
|
21
22
|
#define SSSmaxDistance sssParameters.z
|
|
22
23
|
#define SSSthickness sssParameters.w
|
|
23
24
|
uniform vec4 shadowOpacity;uniform mat4 projMtx;uniform mat4 viewMtx;uniform mat4 invProjMtx;uniform mat4 invViewMtx;uniform mat4 wsNormalizationMtx;uniform mat4 invVPMtx;
|
|
24
|
-
#define PI 3.1415927
|
|
25
25
|
#define GOLD 0.618034
|
|
26
26
|
struct AABB3f {vec3 m_min;vec3 m_max;};struct Ray {vec3 orig;vec3 dir;vec3 dir_rcp;float t_min;float t_max;};Ray make_ray(const vec3 origin,const vec3 direction,const float tmin,
|
|
27
27
|
const float tmax) {Ray ray;ray.orig=origin;ray.dir=direction;ray.dir_rcp=1.0f/direction;ray.t_min=tmin;ray.t_max=tmax;return ray;}
|
|
@@ -31,10 +31,7 @@ out float distance_near,out float distance_far) {vec3 tbot=ray.dir_rcp*(aabb.m_m
|
|
|
31
31
|
struct VoxelMarchDiagnosticInfo {float heat;ivec3 voxel_intersect_coords;};
|
|
32
32
|
#endif
|
|
33
33
|
uint hash(uint i) {i ^= i>>16u;i*=0x7FEB352Du;i ^= i>>15u;i*=0x846CA68Bu;i ^= i>>16u;return i;}
|
|
34
|
-
float uint2float(uint i) {return uintBitsToFloat(0x3F800000u | (i>>9u))-1.0;}
|
|
35
34
|
vec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}
|
|
36
|
-
vec2 plasticSequence(const uint rstate) {return vec2(uint2float(rstate*3242174889u),
|
|
37
|
-
uint2float(rstate*2447445414u));}
|
|
38
35
|
float goldenSequence(const uint rstate) {return uint2float(rstate*2654435769u);}
|
|
39
36
|
float distanceSquared(vec2 a,vec2 b) {vec2 diff=a-b;return dot(diff,diff);}
|
|
40
37
|
void genTB(const vec3 N,out vec3 T,out vec3 B) {float s=N.z<0.0 ? -1.0 : 1.0;float a=-1.0/(s+N.z);float b=N.x*N.y*a;T=vec3(1.0+s*N.x*N.x*a,s*b,-s*N.x);B=vec3(b,s+N.y*N.y*a,-N.y);}
|
|
@@ -123,7 +120,11 @@ return anyHitVoxels(ray_vs) ? 1.0f : 0.0f;
|
|
|
123
120
|
}
|
|
124
121
|
void main(void) {uint nbDirs=uint(SHADOWdirs);uint frameId=uint(SHADOWframe);float envRot=SHADOWenvRot;vec2 Resolution=vec2(textureSize(depthSampler,0));ivec2 currentPixel=ivec2(vUV*Resolution);uint GlobalIndex=(frameId*uint(Resolution.y)+uint(currentPixel.y)) *
|
|
125
122
|
uint(Resolution.x) +
|
|
126
|
-
uint(currentPixel.x);vec3 N=texelFetch(worldNormalSampler,currentPixel,0).xyz;
|
|
123
|
+
uint(currentPixel.x);vec3 N=texelFetch(worldNormalSampler,currentPixel,0).xyz;
|
|
124
|
+
#ifdef WORLD_NORMAL_UNSIGNED
|
|
125
|
+
N=N*vec3(2.0)-vec3(1.0);
|
|
126
|
+
#endif
|
|
127
|
+
if (length(N)<0.01) {glFragColor=vec4(1.0,1.0,0.0,1.0);return;}
|
|
127
128
|
float normalizedRotation=envRot/(2.0*PI);float depth=texelFetch(depthSampler,currentPixel,0).x;
|
|
128
129
|
#ifndef IS_NDC_HALF_ZRANGE
|
|
129
130
|
depth=depth*2.0-1.0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblShadowVoxelTracing.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/iblShadowVoxelTracing.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkLb,CAAC;AACH,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"iblShadowVoxelTracingPixelShader\";\nconst shader = `precision highp sampler2D;precision highp sampler3D;\n#define PI 3.1415927\nvarying vec2 vUV;\n#define DISABLE_UNIFORMITY_ANALYSIS\nuniform sampler2D depthSampler;uniform sampler2D worldNormalSampler;uniform sampler2D blueNoiseSampler;uniform sampler2D icdfSampler;uniform sampler3D voxelGridSampler;\n#ifdef COLOR_SHADOWS\nuniform samplerCube iblSampler;\n#endif\nuniform vec4 shadowParameters;\n#define SHADOWdirs shadowParameters.x\n#define SHADOWframe shadowParameters.y\n#define SHADOWenvRot shadowParameters.w\nuniform vec4 voxelBiasParameters;\n#define highestMipLevel voxelBiasParameters.z\nuniform vec4 sssParameters;\n#define SSSsamples sssParameters.x\n#define SSSstride sssParameters.y\n#define SSSmaxDistance sssParameters.z\n#define SSSthickness sssParameters.w\nuniform vec4 shadowOpacity;uniform mat4 projMtx;uniform mat4 viewMtx;uniform mat4 invProjMtx;uniform mat4 invViewMtx;uniform mat4 wsNormalizationMtx;uniform mat4 invVPMtx;\n#define PI 3.1415927\n#define GOLD 0.618034\nstruct AABB3f {vec3 m_min;vec3 m_max;};struct Ray {vec3 orig;vec3 dir;vec3 dir_rcp;float t_min;float t_max;};Ray make_ray(const vec3 origin,const vec3 direction,const float tmin,\nconst float tmax) {Ray ray;ray.orig=origin;ray.dir=direction;ray.dir_rcp=1.0f/direction;ray.t_min=tmin;ray.t_max=tmax;return ray;}\nbool ray_box_intersection(const in AABB3f aabb,const in Ray ray,\nout float distance_near,out float distance_far) {vec3 tbot=ray.dir_rcp*(aabb.m_min-ray.orig);vec3 ttop=ray.dir_rcp*(aabb.m_max-ray.orig);vec3 tmin=min(ttop,tbot);vec3 tmax=max(ttop,tbot);distance_near=max(ray.t_min,max(tmin.x,max(tmin.y,tmin.z)));distance_far=min(ray.t_max,min(tmax.x,min(tmax.y,tmax.z)));return distance_near<=distance_far;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nstruct VoxelMarchDiagnosticInfo {float heat;ivec3 voxel_intersect_coords;};\n#endif\nuint hash(uint i) {i ^= i>>16u;i*=0x7FEB352Du;i ^= i>>15u;i*=0x846CA68Bu;i ^= i>>16u;return i;}\nfloat uint2float(uint i) {return uintBitsToFloat(0x3F800000u | (i>>9u))-1.0;}\nvec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}\nvec2 plasticSequence(const uint rstate) {return vec2(uint2float(rstate*3242174889u),\nuint2float(rstate*2447445414u));}\nfloat goldenSequence(const uint rstate) {return uint2float(rstate*2654435769u);}\nfloat distanceSquared(vec2 a,vec2 b) {vec2 diff=a-b;return dot(diff,diff);}\nvoid genTB(const vec3 N,out vec3 T,out vec3 B) {float s=N.z<0.0 ? -1.0 : 1.0;float a=-1.0/(s+N.z);float b=N.x*N.y*a;T=vec3(1.0+s*N.x*N.x*a,s*b,-s*N.x);B=vec3(b,s+N.y*N.y*a,-N.y);}\nint stack[24]; \n#define PUSH(i) stack[stackLevel++]=i; \n#define POP() stack[--stackLevel] \n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nbool anyHitVoxels(const Ray ray_vs,\nout VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {\n#else\nbool anyHitVoxels(const Ray ray_vs) {\n#endif\nvec3 invD=ray_vs.dir_rcp;vec3 D=ray_vs.dir;vec3 O=ray_vs.orig;ivec3 negD=ivec3(lessThan(D,vec3(0,0,0)));int voxel0=negD.x | negD.y<<1 | negD.z<<2;vec3 t0=-O*invD,t1=(vec3(1.0)-O)*invD;int maxLod=int(highestMipLevel);int stackLevel=0;\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nuint steps=0u;\n#endif\nPUSH(maxLod<<24);while (stackLevel>0) {int elem=POP();ivec4 Coords =\nivec4(elem & 0xFF,elem>>8 & 0xFF,elem>>16 & 0xFF,elem>>24);if (Coords.w==0) {\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nvoxel_march_diagnostic_info.heat=float(steps)/24.0;\n#endif\nreturn true;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\n++steps;\n#endif\nfloat invRes=exp2(float(Coords.w-maxLod));vec3 bbmin=invRes*vec3(Coords.xyz+negD);vec3 bbmax=invRes*vec3(Coords.xyz-negD+ivec3(1));vec3 mint=mix(t0,t1,bbmin);vec3 maxt=mix(t0,t1,bbmax);vec3 midt=0.5*(mint+maxt);mint.x=max(0.0,mint.x);midt.x=max(0.0,midt.x);int nodeMask=int(\nround(texelFetch(voxelGridSampler,Coords.xyz,Coords.w).x*255.0));Coords.w--;int voxelBit=voxel0;Coords.xyz=(Coords.xyz<<1)+negD;int packedCoords =\nCoords.x | Coords.y<<8 | Coords.z<<16 | Coords.w<<24;if (max(mint.x,max(mint.y,mint.z))<min(midt.x,min(midt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(mint.y,mint.z))<min(maxt.x,min(midt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(midt.y,mint.z))<min(maxt.x,min(maxt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(midt.y,mint.z))<min(midt.x,min(maxt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x4;packedCoords ^= 0x10000;if (max(mint.x,max(midt.y,midt.z))<min(midt.x,min(maxt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(midt.y,midt.z))<min(maxt.x,min(maxt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(mint.y,midt.z))<min(maxt.x,min(midt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(mint.y,midt.z))<min(midt.x,min(midt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nvoxel_march_diagnostic_info.heat=float(steps)/24.0;\n#endif\nreturn false;}\nfloat linearizeDepth(float depth,float near,float far) {return (near*far)/(far-depth*(far-near));}\nfloat screenSpaceShadow(vec3 csOrigin,vec3 csDirection,vec2 csZBufferSize,\nfloat nearPlaneZ,float farPlaneZ,float noise) {\n#ifdef RIGHT_HANDED\nfloat csZDir=-1.0;\n#else \nfloat csZDir=1.0;\n#endif\nfloat ssSamples=SSSsamples;float ssMaxDist=SSSmaxDistance;float ssStride=SSSstride;float ssThickness=SSSthickness;float rayLength =\ncsZDir*(csOrigin.z+ssMaxDist*csDirection.z)<csZDir*nearPlaneZ\n? \n(nearPlaneZ-csOrigin.z)/csDirection.z\n: ssMaxDist;vec3 csEndPoint=csOrigin+rayLength*csDirection;vec4 H0=projMtx*vec4(csOrigin,1.0);vec4 H1=projMtx*vec4(csEndPoint,1.0);vec2 Z0=vec2(csOrigin.z ,1.0)/H0.w;vec2 Z1=vec2(csEndPoint.z,1.0)/H1.w;vec2 P0=csZBufferSize*(0.5*H0.xy*Z0.y+0.5);vec2 P1=csZBufferSize*(0.5*H1.xy*Z1.y+0.5);P1+=vec2(distanceSquared(P0,P1)<0.0001 ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)<abs(delta.y)) {permute=true;P0=P0.yx;P1=P1.yx;delta=delta.yx;}\nfloat stepDirection=sign(delta.x);float invdx=stepDirection/delta.x;vec2 dP=ssStride*vec2(stepDirection,invdx*delta.y);vec2 dZ=ssStride*invdx*(Z1-Z0);float opacity=0.0;vec2 P=P0+noise*dP;vec2 Z=Z0+noise*dZ;float end=P1.x*stepDirection;float rayZMax=csZDir*Z.x/Z.y;float sceneDepth=rayZMax;Z+=dZ;for (float stepCount=0.0;opacity<1.0 && P.x*stepDirection<end && sceneDepth>0.0 && stepCount<ssSamples;stepCount++,P+=dP,\nZ+=dZ) { \nivec2 coords=ivec2(permute ? P.yx : P);sceneDepth=texelFetch(depthSampler,coords,0).x;sceneDepth=linearizeDepth(sceneDepth,nearPlaneZ,farPlaneZ);sceneDepth=csZDir*sceneDepth;if (sceneDepth<=0.0) {break;}\nfloat rayZMin=rayZMax;rayZMax=csZDir*Z.x/Z.y;opacity+=max(opacity,step(rayZMax,sceneDepth+ssThickness)*step(sceneDepth,rayZMin));}\nreturn opacity;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nfloat voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,\nvec2 DitherNoise,\nout VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {\n#else\nfloat voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,\nvec2 DitherNoise) {\n#endif\nfloat vxResolution=float(textureSize(voxelGridSampler,0).x);vec3 T,B;genTB(wsDirection,T,B);vec2 DitherXY=sqrt(DitherNoise.x)*vec2(cos(2.0*PI*DitherNoise.y),\nsin(2.0*PI*DitherNoise.y));float sceneScale=wsNormalizationMtx[0][0];vec3 Dithering =\n(voxelBiasParameters.x*wsNormal+voxelBiasParameters.y*wsDirection +\nDitherXY.x*T+DitherXY.y*B) /\nvxResolution;vec3 O=0.5*wsOrigin+0.5+Dithering;Ray ray_vs=make_ray(O,wsDirection,0.0,10.0);AABB3f voxel_aabb;voxel_aabb.m_min=vec3(0);voxel_aabb.m_max=vec3(1);float near,far;if (!ray_box_intersection(voxel_aabb,ray_vs,near,far))\nreturn 0.0;ray_vs.t_min=max(ray_vs.t_min,near);ray_vs.t_max=min(ray_vs.t_max,far);\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nreturn anyHitVoxels(ray_vs,voxel_march_diagnostic_info) ? 1.0f : 0.0f;\n#else\nreturn anyHitVoxels(ray_vs) ? 1.0f : 0.0f;\n#endif\n}\nvoid main(void) {uint nbDirs=uint(SHADOWdirs);uint frameId=uint(SHADOWframe);float envRot=SHADOWenvRot;vec2 Resolution=vec2(textureSize(depthSampler,0));ivec2 currentPixel=ivec2(vUV*Resolution);uint GlobalIndex=(frameId*uint(Resolution.y)+uint(currentPixel.y)) *\nuint(Resolution.x) +\nuint(currentPixel.x);vec3 N=texelFetch(worldNormalSampler,currentPixel,0).xyz;if (length(N)<0.01) {glFragColor=vec4(1.0,1.0,0.0,1.0);return;}\nfloat normalizedRotation=envRot/(2.0*PI);float depth=texelFetch(depthSampler,currentPixel,0).x;\n#ifndef IS_NDC_HALF_ZRANGE\ndepth=depth*2.0-1.0;\n#endif\nvec2 temp=(vec2(currentPixel)+vec2(0.5))*2.0/Resolution-vec2(1.0);vec4 VP=invProjMtx*vec4(temp.x,-temp.y,depth,1.0);VP/=VP.w;N=normalize(N);vec3 noise=texelFetch(blueNoiseSampler,currentPixel & 0xFF,0).xyz;noise.z=fract(noise.z+goldenSequence(frameId*nbDirs));\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nfloat heat=0.0f;\n#endif\nfloat shadowAccum=0.001;float specShadowAccum=0.001;float sampleWeight=0.001;\n#ifdef COLOR_SHADOWS\nvec3 totalLight=vec3(0.001);vec3 shadowedLight=vec3(0.0);\n#endif\nfor (uint i=0u; i<nbDirs; i++) {uint dirId=nbDirs*GlobalIndex+i;vec4 L;vec2 T;{vec2 r=plasticSequence(frameId*nbDirs+i);r=fract(r+vec2(2.0)*abs(noise.xy-vec2(0.5)));T.x=textureLod(icdfSampler,vec2(r.x,0.0),0.0).x;T.y=textureLod(icdfSampler,vec2(T.x,r.y),0.0).y;L=vec4(uv_to_normal(vec2(T.x-normalizedRotation,T.y)),0);\n#ifndef RIGHT_HANDED\nL.z*=-1.0;\n#endif\n}\n#ifdef COLOR_SHADOWS\nvec3 lightDir=uv_to_normal(vec2(1.0-fract(T.x+0.25),T.y));vec3 ibl=textureLod(iblSampler,lightDir,0.0).xyz;float pdf=textureLod(icdfSampler,T,0.0).z;\n#endif\nfloat cosNL=dot(N,L.xyz);float opacity=0.0;if (cosNL>0.0) {vec4 VP2=VP;VP2.y*=-1.0;vec4 unormWP=invViewMtx*VP2;vec3 WP=(wsNormalizationMtx*unormWP).xyz;vec2 vxNoise=vec2(uint2float(hash(dirId*2u)),uint2float(hash(dirId*2u+1u)));\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nVoxelMarchDiagnosticInfo voxel_march_diagnostic_info;opacity=max(opacity,shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise,voxel_march_diagnostic_info));heat+=voxel_march_diagnostic_info.heat;\n#else\nopacity =\nmax(opacity,shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise));\n#endif\nvec3 VL=(viewMtx*L).xyz;\n#ifdef RIGHT_HANDED\nfloat nearPlaneZ=-projMtx[3][2]/(projMtx[2][2]-1.0); \nfloat farPlaneZ=-projMtx[3][2]/(projMtx[2][2]+1.0);\n#else\nfloat nearPlaneZ=-projMtx[3][2]/(projMtx[2][2]+1.0); \nfloat farPlaneZ=-projMtx[3][2]/(projMtx[2][2]-1.0);\n#endif\nfloat ssShadow=shadowOpacity.y *\nscreenSpaceShadow(VP2.xyz,VL,Resolution,nearPlaneZ,farPlaneZ,\nabs(2.0*noise.z-1.0));opacity=max(opacity,ssShadow);\n#ifdef COLOR_SHADOWS\nvec3 light=pdf<1e-6 ? vec3(0.0) : vec3(cosNL)/vec3(pdf)*ibl;shadowedLight+=light*opacity;totalLight+=light;\n#else\nfloat rcos=(1.0-cosNL);shadowAccum+=(1.0-opacity*(1.0-pow(rcos,8.0)));sampleWeight+=1.0;vec3 VR=-(viewMtx*vec4(reflect(-L.xyz,N),0.0)).xyz;specShadowAccum+=max(1.0-(opacity*pow(VR.z,8.0)),0.0);\n#endif\n}\nnoise.z=fract(noise.z+GOLD);}\n#ifdef COLOR_SHADOWS\nvec3 shadow=(totalLight-shadowedLight)/totalLight;float maxShadow=max(max(shadow.x,max(shadow.y,shadow.z)),1.0);glFragColor=vec4(shadow/maxShadow,1.0);\n#else\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\ngl_FragColor=vec4(shadowAccum/float(sampleWeight),\nspecShadowAccum/float(sampleWeight),heat/float(sampleWeight),1.0);\n#else\ngl_FragColor=vec4(shadowAccum/float(sampleWeight),specShadowAccum/float(sampleWeight),0.0,1.0);\n#endif\n#endif\n}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const iblShadowVoxelTracingPixelShader = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"iblShadowVoxelTracing.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/iblShadowVoxelTracing.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkLb,CAAC;AACH,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/helperFunctions\";\n\nconst name = \"iblShadowVoxelTracingPixelShader\";\nconst shader = `precision highp sampler2D;precision highp sampler3D;\n#include<helperFunctions>\nvarying vec2 vUV;\n#define DISABLE_UNIFORMITY_ANALYSIS\nuniform sampler2D depthSampler;uniform sampler2D worldNormalSampler;uniform sampler2D blueNoiseSampler;uniform sampler2D icdfSampler;uniform sampler3D voxelGridSampler;\n#ifdef COLOR_SHADOWS\nuniform samplerCube iblSampler;\n#endif\nuniform vec4 shadowParameters;\n#define SHADOWdirs shadowParameters.x\n#define SHADOWframe shadowParameters.y\n#define SHADOWenvRot shadowParameters.w\nuniform vec4 voxelBiasParameters;\n#define highestMipLevel voxelBiasParameters.z\nuniform vec4 sssParameters;\n#define SSSsamples sssParameters.x\n#define SSSstride sssParameters.y\n#define SSSmaxDistance sssParameters.z\n#define SSSthickness sssParameters.w\nuniform vec4 shadowOpacity;uniform mat4 projMtx;uniform mat4 viewMtx;uniform mat4 invProjMtx;uniform mat4 invViewMtx;uniform mat4 wsNormalizationMtx;uniform mat4 invVPMtx;\n#define GOLD 0.618034\nstruct AABB3f {vec3 m_min;vec3 m_max;};struct Ray {vec3 orig;vec3 dir;vec3 dir_rcp;float t_min;float t_max;};Ray make_ray(const vec3 origin,const vec3 direction,const float tmin,\nconst float tmax) {Ray ray;ray.orig=origin;ray.dir=direction;ray.dir_rcp=1.0f/direction;ray.t_min=tmin;ray.t_max=tmax;return ray;}\nbool ray_box_intersection(const in AABB3f aabb,const in Ray ray,\nout float distance_near,out float distance_far) {vec3 tbot=ray.dir_rcp*(aabb.m_min-ray.orig);vec3 ttop=ray.dir_rcp*(aabb.m_max-ray.orig);vec3 tmin=min(ttop,tbot);vec3 tmax=max(ttop,tbot);distance_near=max(ray.t_min,max(tmin.x,max(tmin.y,tmin.z)));distance_far=min(ray.t_max,min(tmax.x,min(tmax.y,tmax.z)));return distance_near<=distance_far;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nstruct VoxelMarchDiagnosticInfo {float heat;ivec3 voxel_intersect_coords;};\n#endif\nuint hash(uint i) {i ^= i>>16u;i*=0x7FEB352Du;i ^= i>>15u;i*=0x846CA68Bu;i ^= i>>16u;return i;}\nvec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}\nfloat goldenSequence(const uint rstate) {return uint2float(rstate*2654435769u);}\nfloat distanceSquared(vec2 a,vec2 b) {vec2 diff=a-b;return dot(diff,diff);}\nvoid genTB(const vec3 N,out vec3 T,out vec3 B) {float s=N.z<0.0 ? -1.0 : 1.0;float a=-1.0/(s+N.z);float b=N.x*N.y*a;T=vec3(1.0+s*N.x*N.x*a,s*b,-s*N.x);B=vec3(b,s+N.y*N.y*a,-N.y);}\nint stack[24]; \n#define PUSH(i) stack[stackLevel++]=i; \n#define POP() stack[--stackLevel] \n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nbool anyHitVoxels(const Ray ray_vs,\nout VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {\n#else\nbool anyHitVoxels(const Ray ray_vs) {\n#endif\nvec3 invD=ray_vs.dir_rcp;vec3 D=ray_vs.dir;vec3 O=ray_vs.orig;ivec3 negD=ivec3(lessThan(D,vec3(0,0,0)));int voxel0=negD.x | negD.y<<1 | negD.z<<2;vec3 t0=-O*invD,t1=(vec3(1.0)-O)*invD;int maxLod=int(highestMipLevel);int stackLevel=0;\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nuint steps=0u;\n#endif\nPUSH(maxLod<<24);while (stackLevel>0) {int elem=POP();ivec4 Coords =\nivec4(elem & 0xFF,elem>>8 & 0xFF,elem>>16 & 0xFF,elem>>24);if (Coords.w==0) {\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nvoxel_march_diagnostic_info.heat=float(steps)/24.0;\n#endif\nreturn true;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\n++steps;\n#endif\nfloat invRes=exp2(float(Coords.w-maxLod));vec3 bbmin=invRes*vec3(Coords.xyz+negD);vec3 bbmax=invRes*vec3(Coords.xyz-negD+ivec3(1));vec3 mint=mix(t0,t1,bbmin);vec3 maxt=mix(t0,t1,bbmax);vec3 midt=0.5*(mint+maxt);mint.x=max(0.0,mint.x);midt.x=max(0.0,midt.x);int nodeMask=int(\nround(texelFetch(voxelGridSampler,Coords.xyz,Coords.w).x*255.0));Coords.w--;int voxelBit=voxel0;Coords.xyz=(Coords.xyz<<1)+negD;int packedCoords =\nCoords.x | Coords.y<<8 | Coords.z<<16 | Coords.w<<24;if (max(mint.x,max(mint.y,mint.z))<min(midt.x,min(midt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(mint.y,mint.z))<min(maxt.x,min(midt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(midt.y,mint.z))<min(maxt.x,min(maxt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(midt.y,mint.z))<min(midt.x,min(maxt.y,midt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x4;packedCoords ^= 0x10000;if (max(mint.x,max(midt.y,midt.z))<min(midt.x,min(maxt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(midt.y,midt.z))<min(maxt.x,min(maxt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(mint.y,midt.z))<min(maxt.x,min(midt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(mint.y,midt.z))<min(midt.x,min(midt.y,maxt.z)) &&\n(1<<voxelBit & nodeMask) != 0)\nPUSH(packedCoords);}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nvoxel_march_diagnostic_info.heat=float(steps)/24.0;\n#endif\nreturn false;}\nfloat linearizeDepth(float depth,float near,float far) {return (near*far)/(far-depth*(far-near));}\nfloat screenSpaceShadow(vec3 csOrigin,vec3 csDirection,vec2 csZBufferSize,\nfloat nearPlaneZ,float farPlaneZ,float noise) {\n#ifdef RIGHT_HANDED\nfloat csZDir=-1.0;\n#else \nfloat csZDir=1.0;\n#endif\nfloat ssSamples=SSSsamples;float ssMaxDist=SSSmaxDistance;float ssStride=SSSstride;float ssThickness=SSSthickness;float rayLength =\ncsZDir*(csOrigin.z+ssMaxDist*csDirection.z)<csZDir*nearPlaneZ\n? \n(nearPlaneZ-csOrigin.z)/csDirection.z\n: ssMaxDist;vec3 csEndPoint=csOrigin+rayLength*csDirection;vec4 H0=projMtx*vec4(csOrigin,1.0);vec4 H1=projMtx*vec4(csEndPoint,1.0);vec2 Z0=vec2(csOrigin.z ,1.0)/H0.w;vec2 Z1=vec2(csEndPoint.z,1.0)/H1.w;vec2 P0=csZBufferSize*(0.5*H0.xy*Z0.y+0.5);vec2 P1=csZBufferSize*(0.5*H1.xy*Z1.y+0.5);P1+=vec2(distanceSquared(P0,P1)<0.0001 ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)<abs(delta.y)) {permute=true;P0=P0.yx;P1=P1.yx;delta=delta.yx;}\nfloat stepDirection=sign(delta.x);float invdx=stepDirection/delta.x;vec2 dP=ssStride*vec2(stepDirection,invdx*delta.y);vec2 dZ=ssStride*invdx*(Z1-Z0);float opacity=0.0;vec2 P=P0+noise*dP;vec2 Z=Z0+noise*dZ;float end=P1.x*stepDirection;float rayZMax=csZDir*Z.x/Z.y;float sceneDepth=rayZMax;Z+=dZ;for (float stepCount=0.0;opacity<1.0 && P.x*stepDirection<end && sceneDepth>0.0 && stepCount<ssSamples;stepCount++,P+=dP,\nZ+=dZ) { \nivec2 coords=ivec2(permute ? P.yx : P);sceneDepth=texelFetch(depthSampler,coords,0).x;sceneDepth=linearizeDepth(sceneDepth,nearPlaneZ,farPlaneZ);sceneDepth=csZDir*sceneDepth;if (sceneDepth<=0.0) {break;}\nfloat rayZMin=rayZMax;rayZMax=csZDir*Z.x/Z.y;opacity+=max(opacity,step(rayZMax,sceneDepth+ssThickness)*step(sceneDepth,rayZMin));}\nreturn opacity;}\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nfloat voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,\nvec2 DitherNoise,\nout VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {\n#else\nfloat voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,\nvec2 DitherNoise) {\n#endif\nfloat vxResolution=float(textureSize(voxelGridSampler,0).x);vec3 T,B;genTB(wsDirection,T,B);vec2 DitherXY=sqrt(DitherNoise.x)*vec2(cos(2.0*PI*DitherNoise.y),\nsin(2.0*PI*DitherNoise.y));float sceneScale=wsNormalizationMtx[0][0];vec3 Dithering =\n(voxelBiasParameters.x*wsNormal+voxelBiasParameters.y*wsDirection +\nDitherXY.x*T+DitherXY.y*B) /\nvxResolution;vec3 O=0.5*wsOrigin+0.5+Dithering;Ray ray_vs=make_ray(O,wsDirection,0.0,10.0);AABB3f voxel_aabb;voxel_aabb.m_min=vec3(0);voxel_aabb.m_max=vec3(1);float near,far;if (!ray_box_intersection(voxel_aabb,ray_vs,near,far))\nreturn 0.0;ray_vs.t_min=max(ray_vs.t_min,near);ray_vs.t_max=min(ray_vs.t_max,far);\n#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nreturn anyHitVoxels(ray_vs,voxel_march_diagnostic_info) ? 1.0f : 0.0f;\n#else\nreturn anyHitVoxels(ray_vs) ? 1.0f : 0.0f;\n#endif\n}\nvoid main(void) {uint nbDirs=uint(SHADOWdirs);uint frameId=uint(SHADOWframe);float envRot=SHADOWenvRot;vec2 Resolution=vec2(textureSize(depthSampler,0));ivec2 currentPixel=ivec2(vUV*Resolution);uint GlobalIndex=(frameId*uint(Resolution.y)+uint(currentPixel.y)) *\nuint(Resolution.x) +\nuint(currentPixel.x);vec3 N=texelFetch(worldNormalSampler,currentPixel,0).xyz;\n#ifdef WORLD_NORMAL_UNSIGNED\nN=N*vec3(2.0)-vec3(1.0);\n#endif\nif (length(N)<0.01) {glFragColor=vec4(1.0,1.0,0.0,1.0);return;}\nfloat normalizedRotation=envRot/(2.0*PI);float depth=texelFetch(depthSampler,currentPixel,0).x;\n#ifndef IS_NDC_HALF_ZRANGE\ndepth=depth*2.0-1.0;\n#endif\nvec2 temp=(vec2(currentPixel)+vec2(0.5))*2.0/Resolution-vec2(1.0);vec4 VP=invProjMtx*vec4(temp.x,-temp.y,depth,1.0);VP/=VP.w;N=normalize(N);vec3 noise=texelFetch(blueNoiseSampler,currentPixel & 0xFF,0).xyz;noise.z=fract(noise.z+goldenSequence(frameId*nbDirs));\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nfloat heat=0.0f;\n#endif\nfloat shadowAccum=0.001;float specShadowAccum=0.001;float sampleWeight=0.001;\n#ifdef COLOR_SHADOWS\nvec3 totalLight=vec3(0.001);vec3 shadowedLight=vec3(0.0);\n#endif\nfor (uint i=0u; i<nbDirs; i++) {uint dirId=nbDirs*GlobalIndex+i;vec4 L;vec2 T;{vec2 r=plasticSequence(frameId*nbDirs+i);r=fract(r+vec2(2.0)*abs(noise.xy-vec2(0.5)));T.x=textureLod(icdfSampler,vec2(r.x,0.0),0.0).x;T.y=textureLod(icdfSampler,vec2(T.x,r.y),0.0).y;L=vec4(uv_to_normal(vec2(T.x-normalizedRotation,T.y)),0);\n#ifndef RIGHT_HANDED\nL.z*=-1.0;\n#endif\n}\n#ifdef COLOR_SHADOWS\nvec3 lightDir=uv_to_normal(vec2(1.0-fract(T.x+0.25),T.y));vec3 ibl=textureLod(iblSampler,lightDir,0.0).xyz;float pdf=textureLod(icdfSampler,T,0.0).z;\n#endif\nfloat cosNL=dot(N,L.xyz);float opacity=0.0;if (cosNL>0.0) {vec4 VP2=VP;VP2.y*=-1.0;vec4 unormWP=invViewMtx*VP2;vec3 WP=(wsNormalizationMtx*unormWP).xyz;vec2 vxNoise=vec2(uint2float(hash(dirId*2u)),uint2float(hash(dirId*2u+1u)));\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\nVoxelMarchDiagnosticInfo voxel_march_diagnostic_info;opacity=max(opacity,shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise,voxel_march_diagnostic_info));heat+=voxel_march_diagnostic_info.heat;\n#else\nopacity =\nmax(opacity,shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise));\n#endif\nvec3 VL=(viewMtx*L).xyz;\n#ifdef RIGHT_HANDED\nfloat nearPlaneZ=-projMtx[3][2]/(projMtx[2][2]-1.0); \nfloat farPlaneZ=-projMtx[3][2]/(projMtx[2][2]+1.0);\n#else\nfloat nearPlaneZ=-projMtx[3][2]/(projMtx[2][2]+1.0); \nfloat farPlaneZ=-projMtx[3][2]/(projMtx[2][2]-1.0);\n#endif\nfloat ssShadow=shadowOpacity.y *\nscreenSpaceShadow(VP2.xyz,VL,Resolution,nearPlaneZ,farPlaneZ,\nabs(2.0*noise.z-1.0));opacity=max(opacity,ssShadow);\n#ifdef COLOR_SHADOWS\nvec3 light=pdf<1e-6 ? vec3(0.0) : vec3(cosNL)/vec3(pdf)*ibl;shadowedLight+=light*opacity;totalLight+=light;\n#else\nfloat rcos=(1.0-cosNL);shadowAccum+=(1.0-opacity*(1.0-pow(rcos,8.0)));sampleWeight+=1.0;vec3 VR=-(viewMtx*vec4(reflect(-L.xyz,N),0.0)).xyz;specShadowAccum+=max(1.0-(opacity*pow(VR.z,8.0)),0.0);\n#endif\n}\nnoise.z=fract(noise.z+GOLD);}\n#ifdef COLOR_SHADOWS\nvec3 shadow=(totalLight-shadowedLight)/totalLight;float maxShadow=max(max(shadow.x,max(shadow.y,shadow.z)),1.0);glFragColor=vec4(shadow/maxShadow,1.0);\n#else\n#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION\ngl_FragColor=vec4(shadowAccum/float(sampleWeight),\nspecShadowAccum/float(sampleWeight),heat/float(sampleWeight),1.0);\n#else\ngl_FragColor=vec4(shadowAccum/float(sampleWeight),specShadowAccum/float(sampleWeight),0.0,1.0);\n#endif\n#endif\n}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const iblShadowVoxelTracingPixelShader = { name, shader };\n"]}
|