summit/frontend/node_modules/three-stdlib/postprocessing/SAOPass.cjs.map

1 line
23 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"SAOPass.cjs","sources":["../../src/postprocessing/SAOPass.js"],"sourcesContent":["import {\n AddEquation,\n Color,\n CustomBlending,\n DepthTexture,\n DstAlphaFactor,\n DstColorFactor,\n HalfFloatType,\n MeshDepthMaterial,\n MeshNormalMaterial,\n NearestFilter,\n NoBlending,\n RGBADepthPacking,\n ShaderMaterial,\n UniformsUtils,\n UnsignedShortType,\n Vector2,\n WebGLRenderTarget,\n ZeroFactor,\n} from 'three'\nimport { Pass, FullScreenQuad } from './Pass'\nimport { SAOShader } from '../shaders/SAOShader'\nimport { DepthLimitedBlurShader } from '../shaders/DepthLimitedBlurShader'\nimport { BlurShaderUtils } from '../shaders/DepthLimitedBlurShader'\nimport { CopyShader } from '../shaders/CopyShader'\nimport { UnpackDepthRGBAShader } from '../shaders/UnpackDepthRGBAShader'\n\n/**\n * SAO implementation inspired from bhouston previous SAO work\n */\nconst SAOPass = /* @__PURE__ */ (() => {\n class SAOPass extends Pass {\n static OUTPUT = {\n Beauty: 1,\n Default: 0,\n SAO: 2,\n Depth: 3,\n Normal: 4,\n }\n\n constructor(scene, camera, useDepthTexture = false, useNormals = false, resolution = new Vector2(256, 256)) {\n super()\n\n this.scene = scene\n this.camera = camera\n\n this.clear = true\n this.needsSwap = false\n\n this.supportsDepthTextureExtension = useDepthTexture\n this.supportsNormalTexture = useNormals\n\n this.originalClearColor = new Color()\n this._oldClearColor = new Color()\n this.oldClearAlpha = 1\n\n this.params = {\n output: 0,\n saoBias: 0.5,\n saoIntensity: 0.18,\n saoScale: 1,\n saoKernelRadius: 100,\n saoMinResolution: 0,\n saoBlur: true,\n saoBlurRadius: 8,\n saoBlurStdDev: 4,\n saoBlurDepthCutoff: 0.01,\n }\n\n this.resolution = new Vector2(resolution.x, resolution.y)\n\n this.saoRenderTarget = new WebGLRenderTarget(this.resolution.x, this.resolution.y, { type: HalfFloatType })\n this.blurIntermediateRenderTarget = this.saoRenderTarget.clone()\n this.beautyRenderTarget = this.saoRenderTarget.clone()\n\n this.normalRenderTarget = new WebGLRenderTarget(this.resolution.x, this.resolution.y, {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n type: HalfFloatType,\n })\n this.depthRenderTarget = this.normalRenderTarget.clone()\n\n let depthTexture\n\n if (this.supportsDepthTextureExtension) {\n depthTexture = new DepthTexture()\n depthTexture.type = UnsignedShortType\n\n this.beautyRenderTarget.depthTexture = depthTexture\n this.beautyRenderTarget.depthBuffer = true\n }\n\n this.depthMaterial = new MeshDepthMaterial()\n this.depthMaterial.depthPacking = RGBADepthPacking\n this.depthMaterial.blending = NoBlending\n\n this.normalMaterial = new MeshNormalMaterial()\n this.normalMaterial.blending = NoBlending\n\n this.saoMaterial = new ShaderMaterial({\n defines: Object.assign({}, SAOShader.defines),\n fragmentShader: SAOShader.fragmentShader,\n vertexShader: SAOShader.vertexShader,\n uniforms: UniformsUtils.clone(SAOShader.uniforms),\n })\n this.saoMaterial.extensions.derivatives = true\n this.saoMaterial.defines['DEPTH_PACKING'] = this.supportsDepthTextureExtension ? 0 : 1\n this.saoMaterial.defines['NORMAL_TEXTURE'] = this.supportsNormalTexture ? 1 : 0\n this.saoMaterial.defines['PERSPECTIVE_CAMERA'] = this.camera.isPerspectiveCamera ? 1 : 0\n this.saoMaterial.uniforms['tDepth'].value = this.supportsDepthTextureExtension\n ? depthTexture\n : this.depthRenderTarget.texture\n this.saoMaterial.uniforms['tNormal'].value = this.normalRenderTarget.texture\n this.saoMaterial.uniforms['size'].value.set(this.resolution.x, this.resolution.y)\n this.saoMaterial.uniforms['cameraInverseProjectionMatrix'].value.copy(this.camera.projectionMatrixInverse)\n this.saoMaterial.uniforms['cameraProje