three-stdlib 2.35.3 → 2.35.4
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/_polyfill/CapsuleGeometry.cjs +20 -17
- package/_polyfill/CapsuleGeometry.cjs.map +1 -1
- package/_polyfill/CapsuleGeometry.js +20 -17
- package/_polyfill/CapsuleGeometry.js.map +1 -1
- package/_polyfill/constants.cjs +1 -1
- package/_polyfill/constants.cjs.map +1 -1
- package/_polyfill/constants.js +1 -1
- package/_polyfill/constants.js.map +1 -1
- package/animation/AnimationClipCreator.cjs +13 -13
- package/animation/AnimationClipCreator.cjs.map +1 -1
- package/animation/AnimationClipCreator.js +13 -13
- package/animation/AnimationClipCreator.js.map +1 -1
- package/animation/CCDIKSolver.cjs +11 -11
- package/animation/CCDIKSolver.cjs.map +1 -1
- package/animation/CCDIKSolver.js +12 -12
- package/animation/CCDIKSolver.js.map +1 -1
- package/animation/MMDAnimationHelper.cjs +1 -1
- package/animation/MMDAnimationHelper.cjs.map +1 -1
- package/animation/MMDAnimationHelper.js +1 -1
- package/animation/MMDAnimationHelper.js.map +1 -1
- package/animation/MMDPhysics.cjs +4 -4
- package/animation/MMDPhysics.cjs.map +1 -1
- package/animation/MMDPhysics.js +4 -4
- package/animation/MMDPhysics.js.map +1 -1
- package/controls/ArcballControls.cjs +2 -2
- package/controls/ArcballControls.cjs.map +1 -1
- package/controls/ArcballControls.js +3 -3
- package/controls/ArcballControls.js.map +1 -1
- package/controls/FirstPersonControls.cjs +1 -1
- package/controls/FirstPersonControls.cjs.map +1 -1
- package/controls/FirstPersonControls.js +1 -1
- package/controls/FirstPersonControls.js.map +1 -1
- package/controls/OrbitControls.cjs +2 -2
- package/controls/OrbitControls.cjs.map +1 -1
- package/controls/OrbitControls.js +3 -3
- package/controls/OrbitControls.js.map +1 -1
- package/controls/PointerLockControls.cjs +2 -2
- package/controls/PointerLockControls.cjs.map +1 -1
- package/controls/PointerLockControls.js +3 -3
- package/controls/PointerLockControls.js.map +1 -1
- package/csm/CSM.cjs +4 -4
- package/csm/CSM.cjs.map +1 -1
- package/csm/CSM.js +5 -5
- package/csm/CSM.js.map +1 -1
- package/csm/CSMFrustum.cjs +1 -1
- package/csm/CSMFrustum.cjs.map +1 -1
- package/csm/CSMFrustum.js +2 -2
- package/csm/CSMFrustum.js.map +1 -1
- package/deprecated/Geometry.cjs +722 -715
- package/deprecated/Geometry.cjs.map +1 -1
- package/deprecated/Geometry.js +723 -716
- package/deprecated/Geometry.js.map +1 -1
- package/effects/AnaglyphEffect.cjs +2 -1
- package/effects/AnaglyphEffect.cjs.map +1 -1
- package/effects/AnaglyphEffect.js +3 -2
- package/effects/AnaglyphEffect.js.map +1 -1
- package/effects/OutlineEffect.cjs +2 -1
- package/effects/OutlineEffect.cjs.map +1 -1
- package/effects/OutlineEffect.js +3 -2
- package/effects/OutlineEffect.js.map +1 -1
- package/effects/ParallaxBarrierEffect.cjs +2 -1
- package/effects/ParallaxBarrierEffect.cjs.map +1 -1
- package/effects/ParallaxBarrierEffect.js +3 -2
- package/effects/ParallaxBarrierEffect.js.map +1 -1
- package/exporters/DRACOExporter.cjs +133 -122
- package/exporters/DRACOExporter.cjs.map +1 -1
- package/exporters/DRACOExporter.d.ts +23 -21
- package/exporters/DRACOExporter.js +133 -122
- package/exporters/DRACOExporter.js.map +1 -1
- package/exporters/GLTFExporter.cjs +170 -167
- package/exporters/GLTFExporter.cjs.map +1 -1
- package/exporters/GLTFExporter.js +170 -167
- package/exporters/GLTFExporter.js.map +1 -1
- package/geometries/LightningStrike.cjs +524 -515
- package/geometries/LightningStrike.cjs.map +1 -1
- package/geometries/LightningStrike.js +524 -515
- package/geometries/LightningStrike.js.map +1 -1
- package/geometries/RoundedBoxGeometry.cjs +1 -1
- package/geometries/RoundedBoxGeometry.cjs.map +1 -1
- package/geometries/RoundedBoxGeometry.js +2 -2
- package/geometries/RoundedBoxGeometry.js.map +1 -1
- package/helpers/RaycasterHelper.cjs +2 -2
- package/helpers/RaycasterHelper.cjs.map +1 -1
- package/helpers/RaycasterHelper.js +3 -3
- package/helpers/RaycasterHelper.js.map +1 -1
- package/helpers/VertexNormalsHelper.cjs +3 -3
- package/helpers/VertexNormalsHelper.cjs.map +1 -1
- package/helpers/VertexNormalsHelper.js +4 -4
- package/helpers/VertexNormalsHelper.js.map +1 -1
- package/helpers/VertexTangentsHelper.cjs +2 -2
- package/helpers/VertexTangentsHelper.cjs.map +1 -1
- package/helpers/VertexTangentsHelper.js +3 -3
- package/helpers/VertexTangentsHelper.js.map +1 -1
- package/interactive/InteractiveGroup.cjs +1 -1
- package/interactive/InteractiveGroup.cjs.map +1 -1
- package/interactive/InteractiveGroup.js +2 -2
- package/interactive/InteractiveGroup.js.map +1 -1
- package/interactive/SelectionBox.cjs +15 -15
- package/interactive/SelectionBox.cjs.map +1 -1
- package/interactive/SelectionBox.js +16 -16
- package/interactive/SelectionBox.js.map +1 -1
- package/libs/chevrotain.cjs +1 -1
- package/libs/chevrotain.cjs.map +1 -1
- package/libs/chevrotain.js +1 -1
- package/libs/chevrotain.js.map +1 -1
- package/libs/lottie.cjs +1 -1
- package/libs/lottie.cjs.map +1 -1
- package/libs/lottie.js +1 -1
- package/libs/lottie.js.map +1 -1
- package/libs/opentype.cjs +1 -1
- package/libs/opentype.cjs.map +1 -1
- package/libs/opentype.js +1 -1
- package/libs/opentype.js.map +1 -1
- package/lights/LightProbeGenerator.cjs +5 -5
- package/lights/LightProbeGenerator.cjs.map +1 -1
- package/lights/LightProbeGenerator.js +5 -5
- package/lights/LightProbeGenerator.js.map +1 -1
- package/lights/RectAreaLightUniformsLib.cjs +3 -3
- package/lights/RectAreaLightUniformsLib.cjs.map +1 -1
- package/lights/RectAreaLightUniformsLib.js +3 -3
- package/lights/RectAreaLightUniformsLib.js.map +1 -1
- package/lines/LineMaterial.cjs +2 -1
- package/lines/LineMaterial.cjs.map +1 -1
- package/lines/LineMaterial.js +3 -2
- package/lines/LineMaterial.js.map +1 -1
- package/lines/LineSegments2.cjs +13 -13
- package/lines/LineSegments2.cjs.map +1 -1
- package/lines/LineSegments2.js +14 -14
- package/lines/LineSegments2.js.map +1 -1
- package/lines/LineSegmentsGeometry.cjs +2 -2
- package/lines/LineSegmentsGeometry.cjs.map +1 -1
- package/lines/LineSegmentsGeometry.js +3 -3
- package/lines/LineSegmentsGeometry.js.map +1 -1
- package/lines/Wireframe.cjs +3 -3
- package/lines/Wireframe.cjs.map +1 -1
- package/lines/Wireframe.js +4 -4
- package/lines/Wireframe.js.map +1 -1
- package/loaders/BasisTextureLoader.cjs +441 -435
- package/loaders/BasisTextureLoader.cjs.map +1 -1
- package/loaders/BasisTextureLoader.js +441 -435
- package/loaders/BasisTextureLoader.js.map +1 -1
- package/loaders/EXRLoader.cjs +2 -1
- package/loaders/EXRLoader.cjs.map +1 -1
- package/loaders/EXRLoader.js +3 -2
- package/loaders/EXRLoader.js.map +1 -1
- package/loaders/FBXLoader.cjs +2 -2
- package/loaders/FBXLoader.cjs.map +1 -1
- package/loaders/FBXLoader.js +2 -2
- package/loaders/FBXLoader.js.map +1 -1
- package/loaders/FontLoader.cjs +2 -2
- package/loaders/FontLoader.cjs.map +1 -1
- package/loaders/FontLoader.d.ts +2 -2
- package/loaders/FontLoader.js +2 -2
- package/loaders/FontLoader.js.map +1 -1
- package/loaders/GLTFLoader.cjs +2 -2
- package/loaders/GLTFLoader.cjs.map +1 -1
- package/loaders/GLTFLoader.js +2 -2
- package/loaders/GLTFLoader.js.map +1 -1
- package/loaders/KTX2Loader.cjs +377 -374
- package/loaders/KTX2Loader.cjs.map +1 -1
- package/loaders/KTX2Loader.js +377 -374
- package/loaders/KTX2Loader.js.map +1 -1
- package/loaders/LDrawLoader.cjs +5 -4
- package/loaders/LDrawLoader.cjs.map +1 -1
- package/loaders/LDrawLoader.js +6 -5
- package/loaders/LDrawLoader.js.map +1 -1
- package/loaders/OBJLoader.cjs +5 -5
- package/loaders/OBJLoader.cjs.map +1 -1
- package/loaders/OBJLoader.js +6 -6
- package/loaders/OBJLoader.js.map +1 -1
- package/loaders/PRWMLoader.cjs +46 -43
- package/loaders/PRWMLoader.cjs.map +1 -1
- package/loaders/PRWMLoader.js +46 -43
- package/loaders/PRWMLoader.js.map +1 -1
- package/loaders/SVGLoader.cjs +1694 -1688
- package/loaders/SVGLoader.cjs.map +1 -1
- package/loaders/SVGLoader.js +1694 -1688
- package/loaders/SVGLoader.js.map +1 -1
- package/loaders/XLoader.cjs +1 -1
- package/loaders/XLoader.cjs.map +1 -1
- package/loaders/XLoader.js +1 -1
- package/loaders/XLoader.js.map +1 -1
- package/math/Capsule.cjs +3 -3
- package/math/Capsule.cjs.map +1 -1
- package/math/Capsule.js +3 -3
- package/math/Capsule.js.map +1 -1
- package/math/ColorConverter.cjs +9 -9
- package/math/ColorConverter.cjs.map +1 -1
- package/math/ColorConverter.js +9 -9
- package/math/ColorConverter.js.map +1 -1
- package/math/ConvexHull.cjs +53 -50
- package/math/ConvexHull.cjs.map +1 -1
- package/math/ConvexHull.js +53 -50
- package/math/ConvexHull.js.map +1 -1
- package/math/ImprovedNoise.cjs +1 -1
- package/math/ImprovedNoise.cjs.map +1 -1
- package/math/ImprovedNoise.js +1 -1
- package/math/ImprovedNoise.js.map +1 -1
- package/math/MeshSurfaceSampler.cjs +2 -2
- package/math/MeshSurfaceSampler.cjs.map +1 -1
- package/math/MeshSurfaceSampler.js +2 -2
- package/math/MeshSurfaceSampler.js.map +1 -1
- package/math/OBB.cjs +14 -14
- package/math/OBB.cjs.map +1 -1
- package/math/OBB.js +15 -15
- package/math/OBB.js.map +1 -1
- package/math/Octree.cjs +7 -7
- package/math/Octree.cjs.map +1 -1
- package/math/Octree.js +8 -8
- package/math/Octree.js.map +1 -1
- package/misc/ConvexObjectBreaker.cjs +271 -268
- package/misc/ConvexObjectBreaker.cjs.map +1 -1
- package/misc/ConvexObjectBreaker.js +272 -269
- package/misc/ConvexObjectBreaker.js.map +1 -1
- package/misc/Gyroscope.cjs +6 -6
- package/misc/Gyroscope.cjs.map +1 -1
- package/misc/Gyroscope.js +7 -7
- package/misc/Gyroscope.js.map +1 -1
- package/modifiers/CurveModifier.cjs +1 -1
- package/modifiers/CurveModifier.cjs.map +1 -1
- package/modifiers/CurveModifier.js +2 -2
- package/modifiers/CurveModifier.js.map +1 -1
- package/modifiers/SimplifyModifier.cjs +2 -2
- package/modifiers/SimplifyModifier.cjs.map +1 -1
- package/modifiers/SimplifyModifier.js +2 -2
- package/modifiers/SimplifyModifier.js.map +1 -1
- package/objects/BatchedMesh.cjs +2 -2
- package/objects/BatchedMesh.cjs.map +1 -1
- package/objects/BatchedMesh.js +3 -3
- package/objects/BatchedMesh.js.map +1 -1
- package/objects/GroundProjectedEnv.cjs +2 -1
- package/objects/GroundProjectedEnv.cjs.map +1 -1
- package/objects/GroundProjectedEnv.js +3 -2
- package/objects/GroundProjectedEnv.js.map +1 -1
- package/objects/Lensflare.cjs +209 -206
- package/objects/Lensflare.cjs.map +1 -1
- package/objects/Lensflare.js +209 -206
- package/objects/Lensflare.js.map +1 -1
- package/objects/Reflector.cjs +154 -146
- package/objects/Reflector.cjs.map +1 -1
- package/objects/Reflector.js +154 -146
- package/objects/Reflector.js.map +1 -1
- package/objects/ReflectorForSSRPass.cjs +183 -180
- package/objects/ReflectorForSSRPass.cjs.map +1 -1
- package/objects/ReflectorForSSRPass.js +183 -180
- package/objects/ReflectorForSSRPass.js.map +1 -1
- package/objects/Refractor.cjs +164 -161
- package/objects/Refractor.cjs.map +1 -1
- package/objects/Refractor.js +164 -161
- package/objects/Refractor.js.map +1 -1
- package/objects/ShadowMesh.cjs +1 -1
- package/objects/ShadowMesh.cjs.map +1 -1
- package/objects/ShadowMesh.js +2 -2
- package/objects/ShadowMesh.js.map +1 -1
- package/objects/Sky.cjs +35 -32
- package/objects/Sky.cjs.map +1 -1
- package/objects/Sky.d.ts +100 -6
- package/objects/Sky.js +35 -32
- package/objects/Sky.js.map +1 -1
- package/objects/Water.cjs +2 -1
- package/objects/Water.cjs.map +1 -1
- package/objects/Water.js +3 -2
- package/objects/Water.js.map +1 -1
- package/objects/Water2.cjs +143 -140
- package/objects/Water2.cjs.map +1 -1
- package/objects/Water2.js +143 -140
- package/objects/Water2.js.map +1 -1
- package/package.json +1 -1
- package/postprocessing/SAOPass.cjs +267 -264
- package/postprocessing/SAOPass.cjs.map +1 -1
- package/postprocessing/SAOPass.js +267 -264
- package/postprocessing/SAOPass.js.map +1 -1
- package/postprocessing/SSAOPass.cjs +253 -250
- package/postprocessing/SSAOPass.cjs.map +1 -1
- package/postprocessing/SSAOPass.js +253 -250
- package/postprocessing/SSAOPass.js.map +1 -1
- package/postprocessing/SSRPass.cjs +379 -376
- package/postprocessing/SSRPass.cjs.map +1 -1
- package/postprocessing/SSRPass.js +379 -376
- package/postprocessing/SSRPass.js.map +1 -1
- package/postprocessing/UnrealBloomPass.cjs +205 -202
- package/postprocessing/UnrealBloomPass.cjs.map +1 -1
- package/postprocessing/UnrealBloomPass.js +205 -202
- package/postprocessing/UnrealBloomPass.js.map +1 -1
- package/renderers/CSS2DRenderer.cjs +5 -5
- package/renderers/CSS2DRenderer.cjs.map +1 -1
- package/renderers/CSS2DRenderer.js +5 -5
- package/renderers/CSS2DRenderer.js.map +1 -1
- package/renderers/CSS3DRenderer.cjs +5 -5
- package/renderers/CSS3DRenderer.cjs.map +1 -1
- package/renderers/CSS3DRenderer.js +6 -6
- package/renderers/CSS3DRenderer.js.map +1 -1
- package/shaders/ACESFilmicToneMappingShader.cjs +71 -46
- package/shaders/ACESFilmicToneMappingShader.cjs.map +1 -1
- package/shaders/ACESFilmicToneMappingShader.js +71 -46
- package/shaders/ACESFilmicToneMappingShader.js.map +1 -1
- package/shaders/AfterimageShader.cjs +41 -22
- package/shaders/AfterimageShader.cjs.map +1 -1
- package/shaders/AfterimageShader.js +41 -22
- package/shaders/AfterimageShader.js.map +1 -1
- package/shaders/BasicShader.cjs +20 -6
- package/shaders/BasicShader.cjs.map +1 -1
- package/shaders/BasicShader.js +20 -6
- package/shaders/BasicShader.js.map +1 -1
- package/shaders/BleachBypassShader.cjs +46 -26
- package/shaders/BleachBypassShader.cjs.map +1 -1
- package/shaders/BleachBypassShader.js +46 -26
- package/shaders/BleachBypassShader.js.map +1 -1
- package/shaders/BlendShader.cjs +33 -19
- package/shaders/BlendShader.cjs.map +1 -1
- package/shaders/BlendShader.js +33 -19
- package/shaders/BlendShader.js.map +1 -1
- package/shaders/BokehShader.cjs +117 -90
- package/shaders/BokehShader.cjs.map +1 -1
- package/shaders/BokehShader.js +117 -90
- package/shaders/BokehShader.js.map +1 -1
- package/shaders/BokehShader2.cjs +333 -232
- package/shaders/BokehShader2.cjs.map +1 -1
- package/shaders/BokehShader2.js +333 -232
- package/shaders/BokehShader2.js.map +1 -1
- package/shaders/BrightnessContrastShader.cjs +38 -22
- package/shaders/BrightnessContrastShader.cjs.map +1 -1
- package/shaders/BrightnessContrastShader.js +38 -22
- package/shaders/BrightnessContrastShader.js.map +1 -1
- package/shaders/ColorCorrectionShader.cjs +35 -21
- package/shaders/ColorCorrectionShader.cjs.map +1 -1
- package/shaders/ColorCorrectionShader.js +35 -21
- package/shaders/ColorCorrectionShader.js.map +1 -1
- package/shaders/ColorifyShader.cjs +34 -19
- package/shaders/ColorifyShader.cjs.map +1 -1
- package/shaders/ColorifyShader.js +34 -19
- package/shaders/ColorifyShader.js.map +1 -1
- package/shaders/ConvolutionShader.cjs +43 -24
- package/shaders/ConvolutionShader.cjs.map +1 -1
- package/shaders/ConvolutionShader.js +43 -24
- package/shaders/ConvolutionShader.js.map +1 -1
- package/shaders/CopyShader.cjs +30 -16
- package/shaders/CopyShader.cjs.map +1 -1
- package/shaders/CopyShader.js +30 -16
- package/shaders/CopyShader.js.map +1 -1
- package/shaders/DOFMipMapShader.cjs +38 -21
- package/shaders/DOFMipMapShader.cjs.map +1 -1
- package/shaders/DOFMipMapShader.js +38 -21
- package/shaders/DOFMipMapShader.js.map +1 -1
- package/shaders/DepthLimitedBlurShader.cjs +98 -69
- package/shaders/DepthLimitedBlurShader.cjs.map +1 -1
- package/shaders/DepthLimitedBlurShader.js +98 -69
- package/shaders/DepthLimitedBlurShader.js.map +1 -1
- package/shaders/DigitalGlitch.cjs +70 -59
- package/shaders/DigitalGlitch.cjs.map +1 -1
- package/shaders/DigitalGlitch.js +70 -59
- package/shaders/DigitalGlitch.js.map +1 -1
- package/shaders/DotScreenShader.cjs +49 -28
- package/shaders/DotScreenShader.cjs.map +1 -1
- package/shaders/DotScreenShader.js +49 -28
- package/shaders/DotScreenShader.js.map +1 -1
- package/shaders/FXAAShader.cjs +1098 -1089
- package/shaders/FXAAShader.cjs.map +1 -1
- package/shaders/FXAAShader.js +1098 -1089
- package/shaders/FXAAShader.js.map +1 -1
- package/shaders/FilmShader.cjs +57 -29
- package/shaders/FilmShader.cjs.map +1 -1
- package/shaders/FilmShader.js +57 -29
- package/shaders/FilmShader.js.map +1 -1
- package/shaders/FocusShader.cjs +70 -43
- package/shaders/FocusShader.cjs.map +1 -1
- package/shaders/FocusShader.js +70 -43
- package/shaders/FocusShader.js.map +1 -1
- package/shaders/FreiChenShader.cjs +74 -53
- package/shaders/FreiChenShader.cjs.map +1 -1
- package/shaders/FreiChenShader.js +74 -53
- package/shaders/FreiChenShader.js.map +1 -1
- package/shaders/FresnelShader.cjs +55 -35
- package/shaders/FresnelShader.cjs.map +1 -1
- package/shaders/FresnelShader.js +55 -35
- package/shaders/FresnelShader.js.map +1 -1
- package/shaders/GammaCorrectionShader.cjs +33 -19
- package/shaders/GammaCorrectionShader.cjs.map +1 -1
- package/shaders/GammaCorrectionShader.js +33 -19
- package/shaders/GammaCorrectionShader.js.map +1 -1
- package/shaders/GodRaysShader.cjs +193 -116
- package/shaders/GodRaysShader.cjs.map +1 -1
- package/shaders/GodRaysShader.js +193 -116
- package/shaders/GodRaysShader.js.map +1 -1
- package/shaders/HalftoneShader.cjs +270 -192
- package/shaders/HalftoneShader.cjs.map +1 -1
- package/shaders/HalftoneShader.js +270 -192
- package/shaders/HalftoneShader.js.map +1 -1
- package/shaders/HorizontalTiltShiftShader.cjs +43 -27
- package/shaders/HorizontalTiltShiftShader.cjs.map +1 -1
- package/shaders/HorizontalTiltShiftShader.js +43 -27
- package/shaders/HorizontalTiltShiftShader.js.map +1 -1
- package/shaders/HueSaturationShader.cjs +47 -31
- package/shaders/HueSaturationShader.cjs.map +1 -1
- package/shaders/HueSaturationShader.js +47 -31
- package/shaders/HueSaturationShader.js.map +1 -1
- package/shaders/KaleidoShader.cjs +37 -24
- package/shaders/KaleidoShader.cjs.map +1 -1
- package/shaders/KaleidoShader.js +37 -24
- package/shaders/KaleidoShader.js.map +1 -1
- package/shaders/LuminosityHighPassShader.cjs +43 -24
- package/shaders/LuminosityHighPassShader.cjs.map +1 -1
- package/shaders/LuminosityHighPassShader.js +43 -24
- package/shaders/LuminosityHighPassShader.js.map +1 -1
- package/shaders/LuminosityShader.cjs +34 -17
- package/shaders/LuminosityShader.cjs.map +1 -1
- package/shaders/LuminosityShader.js +34 -17
- package/shaders/LuminosityShader.js.map +1 -1
- package/shaders/MirrorShader.cjs +39 -26
- package/shaders/MirrorShader.cjs.map +1 -1
- package/shaders/MirrorShader.js +39 -26
- package/shaders/MirrorShader.js.map +1 -1
- package/shaders/NormalMapShader.cjs +36 -21
- package/shaders/NormalMapShader.cjs.map +1 -1
- package/shaders/NormalMapShader.js +36 -21
- package/shaders/NormalMapShader.js.map +1 -1
- package/shaders/ParallaxShader.cjs +147 -97
- package/shaders/ParallaxShader.cjs.map +1 -1
- package/shaders/ParallaxShader.js +147 -97
- package/shaders/ParallaxShader.js.map +1 -1
- package/shaders/PixelShader.cjs +31 -18
- package/shaders/PixelShader.cjs.map +1 -1
- package/shaders/PixelShader.js +31 -18
- package/shaders/PixelShader.js.map +1 -1
- package/shaders/RGBShiftShader.cjs +33 -20
- package/shaders/RGBShiftShader.cjs.map +1 -1
- package/shaders/RGBShiftShader.js +33 -20
- package/shaders/RGBShiftShader.js.map +1 -1
- package/shaders/SAOShader.cjs +154 -117
- package/shaders/SAOShader.cjs.map +1 -1
- package/shaders/SAOShader.js +154 -117
- package/shaders/SAOShader.js.map +1 -1
- package/shaders/SMAAShader.cjs +358 -270
- package/shaders/SMAAShader.cjs.map +1 -1
- package/shaders/SMAAShader.js +358 -270
- package/shaders/SMAAShader.js.map +1 -1
- package/shaders/SSAOShader.cjs +236 -142
- package/shaders/SSAOShader.cjs.map +1 -1
- package/shaders/SSAOShader.js +236 -142
- package/shaders/SSAOShader.js.map +1 -1
- package/shaders/SSRShader.cjs +4 -4
- package/shaders/SSRShader.cjs.map +1 -1
- package/shaders/SSRShader.js +4 -4
- package/shaders/SSRShader.js.map +1 -1
- package/shaders/SepiaShader.cjs +36 -20
- package/shaders/SepiaShader.cjs.map +1 -1
- package/shaders/SepiaShader.js +36 -20
- package/shaders/SepiaShader.js.map +1 -1
- package/shaders/SobelOperatorShader.cjs +64 -37
- package/shaders/SobelOperatorShader.cjs.map +1 -1
- package/shaders/SobelOperatorShader.js +64 -37
- package/shaders/SobelOperatorShader.js.map +1 -1
- package/shaders/TechnicolorShader.cjs +29 -16
- package/shaders/TechnicolorShader.cjs.map +1 -1
- package/shaders/TechnicolorShader.js +29 -16
- package/shaders/TechnicolorShader.js.map +1 -1
- package/shaders/ToneMapShader.cjs +55 -35
- package/shaders/ToneMapShader.cjs.map +1 -1
- package/shaders/ToneMapShader.js +55 -35
- package/shaders/ToneMapShader.js.map +1 -1
- package/shaders/ToonShader.cjs +275 -165
- package/shaders/ToonShader.cjs.map +1 -1
- package/shaders/ToonShader.js +275 -165
- package/shaders/ToonShader.js.map +1 -1
- package/shaders/TriangleBlurShader.cjs +50 -27
- package/shaders/TriangleBlurShader.cjs.map +1 -1
- package/shaders/TriangleBlurShader.js +50 -27
- package/shaders/TriangleBlurShader.js.map +1 -1
- package/shaders/UnpackDepthRGBAShader.cjs +32 -17
- package/shaders/UnpackDepthRGBAShader.cjs.map +1 -1
- package/shaders/UnpackDepthRGBAShader.js +32 -17
- package/shaders/UnpackDepthRGBAShader.js.map +1 -1
- package/shaders/VerticalTiltShiftShader.cjs +43 -27
- package/shaders/VerticalTiltShiftShader.cjs.map +1 -1
- package/shaders/VerticalTiltShiftShader.js +43 -27
- package/shaders/VerticalTiltShiftShader.js.map +1 -1
- package/shaders/VignetteShader.cjs +43 -27
- package/shaders/VignetteShader.cjs.map +1 -1
- package/shaders/VignetteShader.js +43 -27
- package/shaders/VignetteShader.js.map +1 -1
- package/shaders/VolumeShader.cjs +264 -213
- package/shaders/VolumeShader.cjs.map +1 -1
- package/shaders/VolumeShader.js +264 -213
- package/shaders/VolumeShader.js.map +1 -1
- package/shaders/WaterRefractionShader.cjs +63 -35
- package/shaders/WaterRefractionShader.cjs.map +1 -1
- package/shaders/WaterRefractionShader.js +63 -35
- package/shaders/WaterRefractionShader.js.map +1 -1
- package/utils/GeometryCompressionUtils.cjs +2 -1
- package/utils/GeometryCompressionUtils.cjs.map +1 -1
- package/utils/GeometryCompressionUtils.js +3 -2
- package/utils/GeometryCompressionUtils.js.map +1 -1
- package/utils/RoughnessMipmapper.cjs +3 -3
- package/utils/RoughnessMipmapper.cjs.map +1 -1
- package/utils/RoughnessMipmapper.js +4 -4
- package/utils/RoughnessMipmapper.js.map +1 -1
- package/webxr/ARButton.cjs +109 -106
- package/webxr/ARButton.cjs.map +1 -1
- package/webxr/ARButton.d.ts +4 -3
- package/webxr/ARButton.js +109 -106
- package/webxr/ARButton.js.map +1 -1
- package/webxr/OculusHandPointerModel.cjs +2 -2
- package/webxr/OculusHandPointerModel.cjs.map +1 -1
- package/webxr/OculusHandPointerModel.js +2 -2
- package/webxr/OculusHandPointerModel.js.map +1 -1
- package/webxr/VRButton.cjs +98 -95
- package/webxr/VRButton.cjs.map +1 -1
- package/webxr/VRButton.d.ts +6 -5
- package/webxr/VRButton.js +98 -95
- package/webxr/VRButton.js.map +1 -1
- package/webxr/XRHandPrimitiveModel.cjs +2 -2
- package/webxr/XRHandPrimitiveModel.cjs.map +1 -1
- package/webxr/XRHandPrimitiveModel.js +3 -3
- package/webxr/XRHandPrimitiveModel.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SMAAShader.js","sources":["../../src/shaders/SMAAShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * WebGL port of Subpixel Morphological Antialiasing (SMAA) v2.8\n * Preset: SMAA 1x Medium (with color edge detection)\n * https://github.com/iryoku/smaa/releases/tag/v2.8\n */\n\nexport const SMAAEdgesShader = {\n defines: {\n SMAA_THRESHOLD: '0.1',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n resolution: { value: new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: [\n 'uniform vec2 resolution;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[ 3 ];',\n\n 'void SMAAEdgeDetectionVS( vec2 texcoord ) {',\n '\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );', // WebGL port note: Changed sign in W component\n '\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );', // WebGL port note: Changed sign in W component\n '\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 );', // WebGL port note: Changed sign in W component\n '}',\n\n 'void main() {',\n\n '\tvUv = uv;',\n\n '\tSMAAEdgeDetectionVS( vUv );',\n\n '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n '}',\n ].join('\\n'),\n\n fragmentShader: [\n 'uniform sampler2D tDiffuse;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[ 3 ];',\n\n 'vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {',\n '\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );',\n\n // Calculate color deltas:\n '\tvec4 delta;',\n '\tvec3 C = texture2D( colorTex, texcoord ).rgb;',\n\n '\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;',\n '\tvec3 t = abs( C - Cleft );',\n '\tdelta.x = max( max( t.r, t.g ), t.b );',\n\n '\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;',\n '\tt = abs( C - Ctop );',\n '\tdelta.y = max( max( t.r, t.g ), t.b );',\n\n // We do the usual threshold:\n '\tvec2 edges = step( threshold, delta.xy );',\n\n // Then discard if there is no edge:\n '\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )',\n '\t\tdiscard;',\n\n // Calculate right and bottom deltas:\n '\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;',\n '\tt = abs( C - Cright );',\n '\tdelta.z = max( max( t.r, t.g ), t.b );',\n\n '\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;',\n '\tt = abs( C - Cbottom );',\n '\tdelta.w = max( max( t.r, t.g ), t.b );',\n\n // Calculate the maximum delta in the direct neighborhood:\n '\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );',\n\n // Calculate left-left and top-top deltas:\n '\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;',\n '\tt = abs( C - Cleftleft );',\n '\tdelta.z = max( max( t.r, t.g ), t.b );',\n\n '\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;',\n '\tt = abs( C - Ctoptop );',\n '\tdelta.w = max( max( t.r, t.g ), t.b );',\n\n // Calculate the final maximum delta:\n '\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );',\n\n // Local contrast adaptation in action:\n '\tedges.xy *= step( 0.5 * maxDelta, delta.xy );',\n\n '\treturn vec4( edges, 0.0, 0.0 );',\n '}',\n\n 'void main() {',\n\n '\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );',\n\n '}',\n ].join('\\n'),\n}\n\nexport const SMAAWeightsShader = {\n defines: {\n SMAA_MAX_SEARCH_STEPS: '8',\n SMAA_AREATEX_MAX_DISTANCE: '16',\n SMAA_AREATEX_PIXEL_SIZE: '( 1.0 / vec2( 160.0, 560.0 ) )',\n SMAA_AREATEX_SUBTEX_SIZE: '( 1.0 / 7.0 )',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n tArea: { value: null },\n tSearch: { value: null },\n resolution: { value: new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: [\n 'uniform vec2 resolution;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[ 3 ];',\n 'varying vec2 vPixcoord;',\n\n 'void SMAABlendingWeightCalculationVS( vec2 texcoord ) {',\n '\tvPixcoord = texcoord / resolution;',\n\n // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n '\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 );', // WebGL port note: Changed sign in Y and W components\n '\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 );', // WebGL port note: Changed sign in Y and W components\n\n // And these for the searches, they indicate the ends of the loops:\n '\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );',\n\n '}',\n\n 'void main() {',\n\n '\tvUv = uv;',\n\n '\tSMAABlendingWeightCalculationVS( vUv );',\n\n '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n '}',\n ].join('\\n'),\n\n fragmentShader: [\n '#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )',\n\n 'uniform sampler2D tDiffuse;',\n 'uniform sampler2D tArea;',\n 'uniform sampler2D tSearch;',\n 'uniform vec2 resolution;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[3];',\n 'varying vec2 vPixcoord;',\n\n '#if __VERSION__ == 100',\n 'vec2 round( vec2 x ) {',\n '\treturn sign( x ) * floor( abs( x ) + 0.5 );',\n '}',\n '#endif',\n\n 'float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {',\n // Not required if searchTex accesses are set to point:\n // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n '\te.r = bias + e.r * scale;',\n '\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;',\n '}',\n\n 'float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {',\n /**\n * @PSEUDO_GATHER4\n * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n * sample between edge, thus fetching four edges in a row.\n * Sampling with different offsets in each direction allows to disambiguate\n * which edges are active from the four fetched ones.\n */\n '\tvec2 e = vec2( 0.0, 1.0 );',\n\n '\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {', // WebGL port note: Changed while to for\n '\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;',\n '\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;',\n '\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;',\n '\t}',\n\n // We correct the previous (-0.25, -0.125) offset we applied:\n '\ttexcoord.x += 0.25 * resolution.x;',\n\n // The searches are bias by 1, so adjust the coords accordingly:\n '\ttexcoord.x += resolution.x;',\n\n // Disambiguate the length added by the last step:\n '\ttexcoord.x += 2.0 * resolution.x;', // Undo last step\n '\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);',\n\n '\treturn texcoord.x;',\n '}',\n\n 'float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {',\n '\tvec2 e = vec2( 0.0, 1.0 );',\n\n '\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {', // WebGL port note: Changed while to for\n '\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;',\n '\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;',\n '\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;',\n '\t}',\n\n '\ttexcoord.x -= 0.25 * resolution.x;',\n '\ttexcoord.x -= resolution.x;',\n '\ttexcoord.x -= 2.0 * resolution.x;',\n '\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );',\n\n '\treturn texcoord.x;',\n '}',\n\n 'float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {',\n '\tvec2 e = vec2( 1.0, 0.0 );',\n\n '\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {', // WebGL port note: Changed while to for\n '\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;',\n '\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution;', // WebGL port note: Changed sign\n '\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;',\n '\t}',\n\n '\ttexcoord.y -= 0.25 * resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y -= resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y -= 2.0 * resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 );', // WebGL port note: Changed sign\n\n '\treturn texcoord.y;',\n '}',\n\n 'float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {',\n '\tvec2 e = vec2( 1.0, 0.0 );',\n\n '\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {', // WebGL port note: Changed while to for\n '\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;',\n '\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution;', // WebGL port note: Changed sign\n '\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;',\n '\t}',\n\n '\ttexcoord.y += 0.25 * resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y += resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y += 2.0 * resolution.y;', // WebGL port note: Changed sign\n '\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 );', // WebGL port note: Changed sign\n\n '\treturn texcoord.y;',\n '}',\n\n 'vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {',\n // Rounding prevents precision errors of bilinear filtering:\n '\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;',\n\n // We do a scale and bias for mapping to texel space:\n '\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );',\n\n // Move to proper place, according to the subpixel offset:\n '\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;',\n\n '\treturn texture2D( areaTex, texcoord, 0.0 ).rg;',\n '}',\n\n 'vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {',\n '\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );',\n\n '\tvec2 e = texture2D( edgesTex, texcoord ).rg;',\n\n '\tif ( e.g > 0.0 ) {', // Edge at north\n '\t\tvec2 d;',\n\n // Find the distance to the left:\n '\t\tvec2 coords;',\n '\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );',\n '\t\tcoords.y = offset[ 1 ].y;', // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n '\t\td.x = coords.x;',\n\n // Now fetch the left crossing edges, two at a time using bilinear\n // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n // discern what value each edge has:\n '\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;',\n\n // Find the distance to the right:\n '\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );',\n '\t\td.y = coords.x;',\n\n // We want the distances to be in pixel units (doing this here allow to\n // better interleave arithmetic and memory accesses):\n '\t\td = d / resolution.x - pixcoord.x;',\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n '\t\tvec2 sqrt_d = sqrt( abs( d ) );',\n\n // Fetch the right crossing edges:\n '\t\tcoords.y -= 1.0 * resolution.y;', // WebGL port note: Added\n '\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;',\n\n // Ok, we know how this pattern looks like, now it is time for getting\n // the actual area:\n '\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );',\n '\t}',\n\n '\tif ( e.r > 0.0 ) {', // Edge at west\n '\t\tvec2 d;',\n\n // Find the distance to the top:\n '\t\tvec2 coords;',\n\n '\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );',\n '\t\tcoords.x = offset[ 0 ].x;', // offset[1].x = texcoord.x - 0.25 * resolution.x;\n '\t\td.x = coords.y;',\n\n // Fetch the top crossing edges:\n '\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;',\n\n // Find the distance to the bottom:\n '\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );',\n '\t\td.y = coords.y;',\n\n // We want the distances to be in pixel units:\n '\t\td = d / resolution.y - pixcoord.y;',\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n '\t\tvec2 sqrt_d = sqrt( abs( d ) );',\n\n // Fetch the bottom crossing edges:\n '\t\tcoords.y -= 1.0 * resolution.y;', // WebGL port note: Added\n '\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;',\n\n // Get the area for this direction:\n '\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );',\n '\t}',\n\n '\treturn weights;',\n '}',\n\n 'void main() {',\n\n '\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );',\n\n '}',\n ].join('\\n'),\n}\n\nexport const SMAABlendShader = {\n uniforms: {\n tDiffuse: { value: null },\n tColor: { value: null },\n resolution: { value: new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: [\n 'uniform vec2 resolution;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[ 2 ];',\n\n 'void SMAANeighborhoodBlendingVS( vec2 texcoord ) {',\n '\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );', // WebGL port note: Changed sign in W component\n '\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );', // WebGL port note: Changed sign in W component\n '}',\n\n 'void main() {',\n\n '\tvUv = uv;',\n\n '\tSMAANeighborhoodBlendingVS( vUv );',\n\n '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n '}',\n ].join('\\n'),\n\n fragmentShader: [\n 'uniform sampler2D tDiffuse;',\n 'uniform sampler2D tColor;',\n 'uniform vec2 resolution;',\n\n 'varying vec2 vUv;',\n 'varying vec4 vOffset[ 2 ];',\n\n 'vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {',\n // Fetch the blending weights for current pixel:\n '\tvec4 a;',\n '\ta.xz = texture2D( blendTex, texcoord ).xz;',\n '\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;',\n '\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;',\n\n // Is there any blending weight with a value greater than 0.0?\n '\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {',\n '\t\treturn texture2D( colorTex, texcoord, 0.0 );',\n '\t} else {',\n // Up to 4 lines can be crossing a pixel (one through each edge). We\n // favor blending by choosing the line with the maximum weight for each\n // direction:\n '\t\tvec2 offset;',\n '\t\toffset.x = a.a > a.b ? a.a : -a.b;', // left vs. right\n '\t\toffset.y = a.g > a.r ? -a.g : a.r;', // top vs. bottom // WebGL port note: Changed signs\n\n // Then we go in the direction that has the maximum weight:\n '\t\tif ( abs( offset.x ) > abs( offset.y )) {', // horizontal vs. vertical\n '\t\t\toffset.y = 0.0;',\n '\t\t} else {',\n '\t\t\toffset.x = 0.0;',\n '\t\t}',\n\n // Fetch the opposite color and lerp by hand:\n '\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );',\n '\t\ttexcoord += sign( offset ) * resolution;',\n '\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );',\n '\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );',\n\n // WebGL port note: Added gamma correction\n '\t\tC.xyz = pow(C.xyz, vec3(2.2));',\n '\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));',\n '\t\tvec4 mixed = mix(C, Cop, s);',\n '\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));',\n\n '\t\treturn mixed;',\n '\t}',\n '}',\n\n 'void main() {',\n\n '\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );',\n\n '}',\n ].join('\\n'),\n}\n"],"names":[],"mappings":";AAQO,MAAM,kBAAkB;AAAA,EAC7B,SAAS;AAAA,IACP,gBAAgB;AAAA,EAClB;AAAA,EAEA,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAO,IAAI,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE;AAAA,EACtD;AAAA,EAEA,cA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IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IAEA;AAAA,IAEA;AAAA,EAAA,EACA,KAAK,IAAI;AACb;"}
|
|
1
|
+
{"version":3,"file":"SMAAShader.js","sources":["../../src/shaders/SMAAShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * WebGL port of Subpixel Morphological Antialiasing (SMAA) v2.8\n * Preset: SMAA 1x Medium (with color edge detection)\n * https://github.com/iryoku/smaa/releases/tag/v2.8\n */\n\nexport const SMAAEdgesShader = {\n defines: {\n SMAA_THRESHOLD: '0.1',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: /* glsl */ `\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n\n void SMAAEdgeDetectionVS( vec2 texcoord ) {\n \tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n \tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n \tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n }\n\n void main() {\n\n \tvUv = uv;\n\n \tSMAAEdgeDetectionVS( vUv );\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n\n vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n \tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n // Calculate color deltas:\n \tvec4 delta;\n \tvec3 C = texture2D( colorTex, texcoord ).rgb;\n\n \tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n \tvec3 t = abs( C - Cleft );\n \tdelta.x = max( max( t.r, t.g ), t.b );\n\n \tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n \tt = abs( C - Ctop );\n \tdelta.y = max( max( t.r, t.g ), t.b );\n\n // We do the usual threshold:\n \tvec2 edges = step( threshold, delta.xy );\n\n // Then discard if there is no edge:\n \tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n \t\tdiscard;\n\n // Calculate right and bottom deltas:\n \tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n \tt = abs( C - Cright );\n \tdelta.z = max( max( t.r, t.g ), t.b );\n\n \tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n \tt = abs( C - Cbottom );\n \tdelta.w = max( max( t.r, t.g ), t.b );\n\n // Calculate the maximum delta in the direct neighborhood:\n \tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n // Calculate left-left and top-top deltas:\n \tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n \tt = abs( C - Cleftleft );\n \tdelta.z = max( max( t.r, t.g ), t.b );\n\n \tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n \tt = abs( C - Ctoptop );\n \tdelta.w = max( max( t.r, t.g ), t.b );\n\n // Calculate the final maximum delta:\n \tmaxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n // Local contrast adaptation in action:\n \tedges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n \treturn vec4( edges, 0.0, 0.0 );\n }\n\n void main() {\n\n \tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n }\n `,\n}\n\nexport const SMAAWeightsShader = {\n defines: {\n SMAA_MAX_SEARCH_STEPS: '8',\n SMAA_AREATEX_MAX_DISTANCE: '16',\n SMAA_AREATEX_PIXEL_SIZE: '( 1.0 / vec2( 160.0, 560.0 ) )',\n SMAA_AREATEX_SUBTEX_SIZE: '( 1.0 / 7.0 )',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n tArea: { value: null },\n tSearch: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: /* glsl */ `\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n varying vec2 vPixcoord;\n\n void SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n \tvPixcoord = texcoord / resolution;\n\n // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n \tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n \tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n // And these for the searches, they indicate the ends of the loops:\n \tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n }\n\n void main() {\n\n \tvUv = uv;\n\n \tSMAABlendingWeightCalculationVS( vUv );\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n uniform sampler2D tDiffuse;\n uniform sampler2D tArea;\n uniform sampler2D tSearch;\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[3];\n varying vec2 vPixcoord;\n\n #if __VERSION__ == 100\n vec2 round( vec2 x ) {\n \treturn sign( x ) * floor( abs( x ) + 0.5 );\n }\n #endif\n\n float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n // Not required if searchTex accesses are set to point:\n // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n \te.r = bias + e.r * scale;\n \treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;\n }\n\n float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n /**\n * @PSEUDO_GATHER4\n * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n * sample between edge, thus fetching four edges in a row.\n * Sampling with different offsets in each direction allows to disambiguate\n * which edges are active from the four fetched ones.\n */\n \tvec2 e = vec2( 0.0, 1.0 );\n\n \tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n \t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n \t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;\n \t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n \t}\n\n // We correct the previous (-0.25, -0.125) offset we applied:\n \ttexcoord.x += 0.25 * resolution.x;\n\n // The searches are bias by 1, so adjust the coords accordingly:\n \ttexcoord.x += resolution.x;\n\n // Disambiguate the length added by the last step:\n \ttexcoord.x += 2.0 * resolution.x; // Undo last step\n \ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n \treturn texcoord.x;\n }\n\n float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n \tvec2 e = vec2( 0.0, 1.0 );\n\n \tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n \t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n \t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;\n \t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n \t}\n\n \ttexcoord.x -= 0.25 * resolution.x;\n \ttexcoord.x -= resolution.x;\n \ttexcoord.x -= 2.0 * resolution.x;\n \ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n \treturn texcoord.x;\n }\n\n float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n \tvec2 e = vec2( 1.0, 0.0 );\n\n \tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n \t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n \t\ttexcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n \t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n \t}\n\n \ttexcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y -= resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n \treturn texcoord.y;\n }\n\n float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n \tvec2 e = vec2( 1.0, 0.0 );\n\n \tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n \t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n \t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n \t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n \t}\n\n \ttexcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y += resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n \ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n \treturn texcoord.y;\n }\n\n vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n // Rounding prevents precision errors of bilinear filtering:\n \tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n // We do a scale and bias for mapping to texel space:\n \ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n // Move to proper place, according to the subpixel offset:\n \ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n \treturn texture2D( areaTex, texcoord, 0.0 ).rg;\n }\n\n vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n \tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n \tvec2 e = texture2D( edgesTex, texcoord ).rg;\n\n \tif ( e.g > 0.0 ) { // Edge at north\n \t\tvec2 d;\n\n // Find the distance to the left:\n \t\tvec2 coords;\n \t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n \t\tcoords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n \t\td.x = coords.x;\n\n // Now fetch the left crossing edges, two at a time using bilinear\n // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n // discern what value each edge has:\n \t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n // Find the distance to the right:\n \t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n \t\td.y = coords.x;\n\n // We want the distances to be in pixel units (doing this here allow to\n // better interleave arithmetic and memory accesses):\n \t\td = d / resolution.x - pixcoord.x;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n \t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n // Fetch the right crossing edges:\n \t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n \t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n // Ok, we know how this pattern looks like, now it is time for getting\n // the actual area:\n \t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n \t}\n\n \tif ( e.r > 0.0 ) { // Edge at west\n \t\tvec2 d;\n\n // Find the distance to the top:\n \t\tvec2 coords;\n\n \t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n \t\tcoords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n \t\td.x = coords.y;\n\n // Fetch the top crossing edges:\n \t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n // Find the distance to the bottom:\n \t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n \t\td.y = coords.y;\n\n // We want the distances to be in pixel units:\n \t\td = d / resolution.y - pixcoord.y;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n \t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n // Fetch the bottom crossing edges:\n \t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n \t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n // Get the area for this direction:\n \t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n \t}\n\n \treturn weights;\n }\n\n void main() {\n\n \tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n }\n `,\n}\n\nexport const SMAABlendShader = {\n uniforms: {\n tDiffuse: { value: null },\n tColor: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: /* glsl */ `\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 2 ];\n\n void SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n \tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n \tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n }\n\n void main() {\n\n \tvUv = uv;\n\n \tSMAANeighborhoodBlendingVS( vUv );\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform sampler2D tColor;\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 2 ];\n\n vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n // Fetch the blending weights for current pixel:\n \tvec4 a;\n \ta.xz = texture2D( blendTex, texcoord ).xz;\n \ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n \ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n // Is there any blending weight with a value greater than 0.0?\n \tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n \t\treturn texture2D( colorTex, texcoord, 0.0 );\n \t} else {\n // Up to 4 lines can be crossing a pixel (one through each edge). We\n // favor blending by choosing the line with the maximum weight for each\n // direction:\n \t\tvec2 offset;\n \t\toffset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n \t\toffset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n // Then we go in the direction that has the maximum weight:\n \t\tif ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n \t\t\toffset.y = 0.0;\n \t\t} else {\n \t\t\toffset.x = 0.0;\n \t\t}\n\n // Fetch the opposite color and lerp by hand:\n \t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );\n \t\ttexcoord += sign( offset ) * resolution;\n \t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n \t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n // WebGL port note: Added gamma correction\n \t\tC.xyz = pow(C.xyz, vec3(2.2));\n \t\tCop.xyz = pow(Cop.xyz, vec3(2.2));\n \t\tvec4 mixed = mix(C, Cop, s);\n \t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n \t\treturn mixed;\n \t}\n }\n\n void main() {\n\n \tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n }\n `,\n}\n"],"names":[],"mappings":";AAQO,MAAM,kBAAkB;AAAA,EAC7B,SAAS;AAAA,IACP,gBAAgB;AAAA,EAClB;AAAA,EAEA,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAuB,oBAAI,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE;AAAA,EACtE;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuD7B;"}
|
package/shaders/SSAOShader.cjs
CHANGED
|
@@ -14,102 +14,154 @@ const SSAOShader = {
|
|
|
14
14
|
kernel: { value: null },
|
|
15
15
|
cameraNear: { value: null },
|
|
16
16
|
cameraFar: { value: null },
|
|
17
|
-
resolution: { value: new THREE.Vector2() },
|
|
18
|
-
cameraProjectionMatrix: { value: new THREE.Matrix4() },
|
|
19
|
-
cameraInverseProjectionMatrix: { value: new THREE.Matrix4() },
|
|
17
|
+
resolution: { value: /* @__PURE__ */ new THREE.Vector2() },
|
|
18
|
+
cameraProjectionMatrix: { value: /* @__PURE__ */ new THREE.Matrix4() },
|
|
19
|
+
cameraInverseProjectionMatrix: { value: /* @__PURE__ */ new THREE.Matrix4() },
|
|
20
20
|
kernelRadius: { value: 8 },
|
|
21
21
|
minDistance: { value: 5e-3 },
|
|
22
22
|
maxDistance: { value: 0.05 }
|
|
23
23
|
},
|
|
24
|
-
vertexShader:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
24
|
+
vertexShader: (
|
|
25
|
+
/* glsl */
|
|
26
|
+
`
|
|
27
|
+
varying vec2 vUv;
|
|
28
|
+
|
|
29
|
+
void main() {
|
|
30
|
+
|
|
31
|
+
vUv = uv;
|
|
32
|
+
|
|
33
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
),
|
|
38
|
+
fragmentShader: (
|
|
39
|
+
/* glsl */
|
|
40
|
+
`
|
|
41
|
+
uniform sampler2D tDiffuse;
|
|
42
|
+
uniform sampler2D tNormal;
|
|
43
|
+
uniform sampler2D tDepth;
|
|
44
|
+
uniform sampler2D tNoise;
|
|
45
|
+
|
|
46
|
+
uniform vec3 kernel[ KERNEL_SIZE ];
|
|
47
|
+
|
|
48
|
+
uniform vec2 resolution;
|
|
49
|
+
|
|
50
|
+
uniform float cameraNear;
|
|
51
|
+
uniform float cameraFar;
|
|
52
|
+
uniform mat4 cameraProjectionMatrix;
|
|
53
|
+
uniform mat4 cameraInverseProjectionMatrix;
|
|
54
|
+
|
|
55
|
+
uniform float kernelRadius;
|
|
56
|
+
uniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference
|
|
57
|
+
uniform float maxDistance; // avoid the influence of fragments which are too far away
|
|
58
|
+
|
|
59
|
+
varying vec2 vUv;
|
|
60
|
+
|
|
61
|
+
#include <packing>
|
|
62
|
+
|
|
63
|
+
float getDepth( const in vec2 screenPosition ) {
|
|
64
|
+
|
|
65
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
float getLinearDepth( const in vec2 screenPosition ) {
|
|
70
|
+
|
|
71
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
72
|
+
|
|
73
|
+
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
|
74
|
+
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
|
75
|
+
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
76
|
+
|
|
77
|
+
#else
|
|
78
|
+
|
|
79
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
80
|
+
|
|
81
|
+
#endif
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
float getViewZ( const in float depth ) {
|
|
86
|
+
|
|
87
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
88
|
+
|
|
89
|
+
return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
|
|
90
|
+
|
|
91
|
+
#else
|
|
92
|
+
|
|
93
|
+
return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
|
|
94
|
+
|
|
95
|
+
#endif
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {
|
|
100
|
+
|
|
101
|
+
float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];
|
|
102
|
+
|
|
103
|
+
vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );
|
|
104
|
+
|
|
105
|
+
clipPosition *= clipW; // unprojection.
|
|
106
|
+
|
|
107
|
+
return ( cameraInverseProjectionMatrix * clipPosition ).xyz;
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
vec3 getViewNormal( const in vec2 screenPosition ) {
|
|
112
|
+
|
|
113
|
+
return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void main() {
|
|
118
|
+
|
|
119
|
+
float depth = getDepth( vUv );
|
|
120
|
+
float viewZ = getViewZ( depth );
|
|
121
|
+
|
|
122
|
+
vec3 viewPosition = getViewPosition( vUv, depth, viewZ );
|
|
123
|
+
vec3 viewNormal = getViewNormal( vUv );
|
|
124
|
+
|
|
125
|
+
vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
|
|
126
|
+
vec3 random = texture2D( tNoise, vUv * noiseScale ).xyz;
|
|
127
|
+
|
|
84
128
|
// compute matrix used to reorient a kernel vector
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
|
|
130
|
+
vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );
|
|
131
|
+
vec3 bitangent = cross( viewNormal, tangent );
|
|
132
|
+
mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );
|
|
133
|
+
|
|
134
|
+
float occlusion = 0.0;
|
|
135
|
+
|
|
136
|
+
for ( int i = 0; i < KERNEL_SIZE; i ++ ) {
|
|
137
|
+
|
|
138
|
+
vec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space
|
|
139
|
+
vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point
|
|
140
|
+
|
|
141
|
+
vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC
|
|
142
|
+
samplePointNDC /= samplePointNDC.w;
|
|
143
|
+
|
|
144
|
+
vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates
|
|
145
|
+
|
|
146
|
+
float realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture
|
|
147
|
+
float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value
|
|
148
|
+
float delta = sampleDepth - realDepth;
|
|
149
|
+
|
|
150
|
+
if ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion
|
|
151
|
+
|
|
152
|
+
occlusion += 1.0;
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );
|
|
159
|
+
|
|
160
|
+
gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
`
|
|
164
|
+
)
|
|
113
165
|
};
|
|
114
166
|
const SSAODepthShader = {
|
|
115
167
|
defines: {
|
|
@@ -120,62 +172,104 @@ const SSAODepthShader = {
|
|
|
120
172
|
cameraNear: { value: null },
|
|
121
173
|
cameraFar: { value: null }
|
|
122
174
|
},
|
|
123
|
-
vertexShader:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
vertexShader: (
|
|
176
|
+
/* glsl */
|
|
177
|
+
`
|
|
178
|
+
varying vec2 vUv;
|
|
179
|
+
|
|
180
|
+
void main() {
|
|
181
|
+
|
|
182
|
+
vUv = uv;
|
|
183
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
`
|
|
187
|
+
),
|
|
188
|
+
fragmentShader: (
|
|
189
|
+
/* glsl */
|
|
190
|
+
`
|
|
191
|
+
uniform sampler2D tDepth;
|
|
192
|
+
|
|
193
|
+
uniform float cameraNear;
|
|
194
|
+
uniform float cameraFar;
|
|
195
|
+
|
|
196
|
+
varying vec2 vUv;
|
|
197
|
+
|
|
198
|
+
#include <packing>
|
|
199
|
+
|
|
200
|
+
float getLinearDepth( const in vec2 screenPosition ) {
|
|
201
|
+
|
|
202
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
203
|
+
|
|
204
|
+
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
|
205
|
+
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
|
206
|
+
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
207
|
+
|
|
208
|
+
#else
|
|
209
|
+
|
|
210
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
211
|
+
|
|
212
|
+
#endif
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void main() {
|
|
217
|
+
|
|
218
|
+
float depth = getLinearDepth( vUv );
|
|
219
|
+
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
`
|
|
223
|
+
)
|
|
150
224
|
};
|
|
151
225
|
const SSAOBlurShader = {
|
|
152
226
|
uniforms: {
|
|
153
227
|
tDiffuse: { value: null },
|
|
154
|
-
resolution: { value: new THREE.Vector2() }
|
|
228
|
+
resolution: { value: /* @__PURE__ */ new THREE.Vector2() }
|
|
155
229
|
},
|
|
156
|
-
vertexShader:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
230
|
+
vertexShader: (
|
|
231
|
+
/* glsl */
|
|
232
|
+
`
|
|
233
|
+
varying vec2 vUv;
|
|
234
|
+
|
|
235
|
+
void main() {
|
|
236
|
+
|
|
237
|
+
vUv = uv;
|
|
238
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
`
|
|
242
|
+
),
|
|
243
|
+
fragmentShader: (
|
|
244
|
+
/* glsl */
|
|
245
|
+
`
|
|
246
|
+
uniform sampler2D tDiffuse;
|
|
247
|
+
|
|
248
|
+
uniform vec2 resolution;
|
|
249
|
+
|
|
250
|
+
varying vec2 vUv;
|
|
251
|
+
|
|
252
|
+
void main() {
|
|
253
|
+
|
|
254
|
+
vec2 texelSize = ( 1.0 / resolution );
|
|
255
|
+
float result = 0.0;
|
|
256
|
+
|
|
257
|
+
for ( int i = - 2; i <= 2; i ++ ) {
|
|
258
|
+
|
|
259
|
+
for ( int j = - 2; j <= 2; j ++ ) {
|
|
260
|
+
|
|
261
|
+
vec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;
|
|
262
|
+
result += texture2D( tDiffuse, vUv + offset ).r;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
`
|
|
272
|
+
)
|
|
179
273
|
};
|
|
180
274
|
exports.SSAOBlurShader = SSAOBlurShader;
|
|
181
275
|
exports.SSAODepthShader = SSAODepthShader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SSAOShader.cjs","sources":["../../src/shaders/SSAOShader.ts"],"sourcesContent":["import { Matrix4, Vector2 } from 'three'\n\n/**\n * References:\n * http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html\n * https://learnopengl.com/Advanced-Lighting/SSAO\n * https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl\n */\n\nexport const SSAOShader = {\n defines: {\n PERSPECTIVE_CAMERA: 1,\n KERNEL_SIZE: 32,\n },\n\n uniforms: {\n tDiffuse: { value: null },\n tNormal: { value: null },\n tDepth: { value: null },\n tNoise: { value: null },\n kernel: { value: null },\n cameraNear: { value: null },\n cameraFar: { value: null },\n resolution: { value: new Vector2() },\n cameraProjectionMatrix: { value: new Matrix4() },\n cameraInverseProjectionMatrix: { value: new Matrix4() },\n kernelRadius: { value: 8 },\n minDistance: { value: 0.005 },\n maxDistance: { value: 0.05 },\n },\n\n vertexShader:
|
|
1
|
+
{"version":3,"file":"SSAOShader.cjs","sources":["../../src/shaders/SSAOShader.ts"],"sourcesContent":["import { Matrix4, Vector2 } from 'three'\n\n/**\n * References:\n * http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html\n * https://learnopengl.com/Advanced-Lighting/SSAO\n * https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl\n */\n\nexport const SSAOShader = {\n defines: {\n PERSPECTIVE_CAMERA: 1,\n KERNEL_SIZE: 32,\n },\n\n uniforms: {\n tDiffuse: { value: null },\n tNormal: { value: null },\n tDepth: { value: null },\n tNoise: { value: null },\n kernel: { value: null },\n cameraNear: { value: null },\n cameraFar: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2() },\n cameraProjectionMatrix: { value: /* @__PURE__ */ new Matrix4() },\n cameraInverseProjectionMatrix: { value: /* @__PURE__ */ new Matrix4() },\n kernelRadius: { value: 8 },\n minDistance: { value: 0.005 },\n maxDistance: { value: 0.05 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform sampler2D tNormal;\n uniform sampler2D tDepth;\n uniform sampler2D tNoise;\n\n uniform vec3 kernel[ KERNEL_SIZE ];\n\n uniform vec2 resolution;\n\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n\n uniform float kernelRadius;\n uniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference\n uniform float maxDistance; // avoid the influence of fragments which are too far away\n\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth( const in vec2 screenPosition ) {\n\n \treturn texture2D( tDepth, screenPosition ).x;\n\n }\n\n float getLinearDepth( const in vec2 screenPosition ) {\n\n \t#if PERSPECTIVE_CAMERA == 1\n\n \t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n \t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n \t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n \t#else\n\n \t\treturn texture2D( tDepth, screenPosition ).x;\n\n \t#endif\n\n }\n\n float getViewZ( const in float depth ) {\n\n \t#if PERSPECTIVE_CAMERA == 1\n\n \t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\n \t#else\n\n \t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\n \t#endif\n\n }\n\n vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\n \tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\n \tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\n \tclipPosition *= clipW; // unprojection.\n\n \treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\n }\n\n vec3 getViewNormal( const in vec2 screenPosition ) {\n\n \treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\n }\n\n void main() {\n\n \tfloat depth = getDepth( vUv );\n \tfloat viewZ = getViewZ( depth );\n\n \tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );\n \tvec3 viewNormal = getViewNormal( vUv );\n\n vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );\n \tvec3 random = texture2D( tNoise, vUv * noiseScale ).xyz;\n\n // compute matrix used to reorient a kernel vector\n\n \tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );\n \tvec3 bitangent = cross( viewNormal, tangent );\n \tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );\n\n float occlusion = 0.0;\n\n for ( int i = 0; i < KERNEL_SIZE; i ++ ) {\n\n \t\tvec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space\n \t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point\n\n \t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC\n \t\tsamplePointNDC /= samplePointNDC.w;\n\n \t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n\n \t\tfloat realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture\n \t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value\n \t\tfloat delta = sampleDepth - realDepth;\n\n \t\tif ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion\n\n \t\t\tocclusion += 1.0;\n\n \t\t}\n\n \t}\n\n \tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );\n\n \tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );\n\n }\n `,\n}\n\nexport const SSAODepthShader = {\n defines: {\n PERSPECTIVE_CAMERA: 1,\n },\n\n uniforms: {\n tDepth: { value: null },\n cameraNear: { value: null },\n cameraFar: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDepth;\n\n uniform float cameraNear;\n uniform float cameraFar;\n\n varying vec2 vUv;\n\n #include <packing>\n\n float getLinearDepth( const in vec2 screenPosition ) {\n\n \t#if PERSPECTIVE_CAMERA == 1\n\n \t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n \t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n \t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n \t#else\n\n \t\treturn texture2D( tDepth, screenPosition ).x;\n\n \t#endif\n\n }\n\n void main() {\n\n \tfloat depth = getLinearDepth( vUv );\n \tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n }\n `,\n}\n\nexport const SSAOBlurShader = {\n uniforms: {\n tDiffuse: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2() },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n\n uniform vec2 resolution;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec2 texelSize = ( 1.0 / resolution );\n \tfloat result = 0.0;\n\n \tfor ( int i = - 2; i <= 2; i ++ ) {\n\n \t\tfor ( int j = - 2; j <= 2; j ++ ) {\n\n \t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;\n \t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;\n\n \t\t}\n\n \t}\n\n \tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );\n\n }\n `,\n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