From f4c0187ebd2ec5c4df7ff41a3bc7ceb0efc782a5 Mon Sep 17 00:00:00 2001 From: Juan Hoyos <84806689+HoyosJuan@users.noreply.github.com> Date: Tue, 16 Jan 2024 14:18:17 -0500 Subject: [PATCH 1/2] Update package.json --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7db2d25b3..3d5be7091 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "ts-jest": "^27.0.3", "ts-node": "^10.0.0", "typescript": "^4.3.2", - "web-ifc": "0.0.46" + "web-ifc": "0.0.46", + "mapbox-gl": "^2.15.0" }, "dependencies": { "@popperjs/core": "2.11.8", @@ -49,7 +50,6 @@ "dexie": "^3.2.3", "dxf-writer": "^1.18.4", "earcut": "^2.2.4", - "mapbox-gl": "^2.15.0", "n8ao": "^1.5.1", "openbim-clay": "0.0.5", "postprocessing": "^6.31.0", @@ -59,6 +59,7 @@ "unzipit": "^1.4.3" }, "peerDependencies": { + "mapbox-gl": "^2.15.0", "bim-fragment": "1.3.1", "three": "0.152.2", "web-ifc": "0.0.46" From a5fe1d6e6d6dc137d6523cda10e22ecb3ea03f41 Mon Sep 17 00:00:00 2001 From: Juan Hoyos Date: Tue, 16 Jan 2024 14:22:45 -0500 Subject: [PATCH 2/2] Updated package.json --- package.json | 6 +- resources/openbim-components.js | 349 +++++++++++--------------------- yarn.lock | 1 + 3 files changed, 120 insertions(+), 236 deletions(-) diff --git a/package.json b/package.json index 3d5be7091..59086ea6e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "eslint-plugin-import": "^2.23.4", "eslint-plugin-prettier": "^3.4.0", "jest": "^27.0.4", + "mapbox-gl": "^2.15.0", "node-fetch": "^3.3.2", "prettier": "^2.3.1", "rollup": "^3.2.3", @@ -41,8 +42,7 @@ "ts-jest": "^27.0.3", "ts-node": "^10.0.0", "typescript": "^4.3.2", - "web-ifc": "0.0.46", - "mapbox-gl": "^2.15.0" + "web-ifc": "0.0.46" }, "dependencies": { "@popperjs/core": "2.11.8", @@ -59,8 +59,8 @@ "unzipit": "^1.4.3" }, "peerDependencies": { - "mapbox-gl": "^2.15.0", "bim-fragment": "1.3.1", + "mapbox-gl": "^2.15.0", "three": "0.152.2", "web-ifc": "0.0.46" } diff --git a/resources/openbim-components.js b/resources/openbim-components.js index b4a78be46..49e0e2342 100644 --- a/resources/openbim-components.js +++ b/resources/openbim-components.js @@ -1,5 +1,5 @@ import * as THREE$1 from 'https://unpkg.com/three@0.152.2/build/three.module.js'; -import { Vector3 as Vector3$1, Matrix4, Object3D, Vector2 as Vector2$1, BufferAttribute as BufferAttribute$1, Plane, Line3, Triangle, Sphere, BackSide, DoubleSide, Box3, FrontSide, Mesh, Ray, Raycaster, Quaternion as Quaternion$1, Euler, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line as Line$2, SphereGeometry, TorusGeometry, PlaneGeometry, Color, PropertyBinding, InterpolateLinear, Source, NoColorSpace, MathUtils, RGBAFormat, InterpolateDiscrete, Scene, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, RepeatWrapping, MirroredRepeatWrapping, SRGBColorSpace, InstancedMesh, OrthographicCamera, ShaderMaterial, UniformsUtils, WebGLRenderTarget, Clock, REVISION, HalfFloatType, DepthTexture, UnsignedInt248Type, UnsignedIntType, DepthStencilFormat, DepthFormat, DataTexture, WebGLMultipleRenderTargets, RedFormat, FloatType, EventDispatcher as EventDispatcher$1, MOUSE, TOUCH, Spherical, UniformsLib, ShaderLib, InstancedBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, WireframeGeometry, Vector4 } from 'https://unpkg.com/three@0.152.2/build/three.module.js'; +import { Vector3 as Vector3$1, Matrix4, Object3D, Vector2 as Vector2$1, BufferAttribute as BufferAttribute$1, Plane, Line3, Triangle, Sphere, BackSide, DoubleSide, Box3, FrontSide, Mesh, Ray, Raycaster, Quaternion as Quaternion$1, Euler, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line as Line$2, SphereGeometry, TorusGeometry, PlaneGeometry, Color, PropertyBinding, InterpolateLinear, Source, NoColorSpace, MathUtils, RGBAFormat, InterpolateDiscrete, Scene, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, RepeatWrapping, MirroredRepeatWrapping, SRGBColorSpace, InstancedMesh, OrthographicCamera, ShaderMaterial, UniformsUtils, WebGLRenderTarget, Clock, REVISION, DepthTexture, UnsignedIntType, DepthFormat, DataTexture, WebGLMultipleRenderTargets, RedFormat, FloatType, HalfFloatType, EventDispatcher as EventDispatcher$1, MOUSE, TOUCH, Spherical, UniformsLib, ShaderLib, InstancedBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, WireframeGeometry, Vector4 } from 'https://unpkg.com/three@0.152.2/build/three.module.js'; /** * Components are the building blocks of this library. Everything is a @@ -22930,7 +22930,7 @@ class RenderPass extends Pass { } /** - * postprocessing v6.33.3 build Mon Oct 30 2023 + * postprocessing v6.33.1 build Tue Sep 19 2023 * https://github.com/pmndrs/postprocessing * Copyright 2015-2023 Raoul van RĂ¼schen * @license Zlib @@ -23021,6 +23021,9 @@ const $1ed45968c1160c3c$export$c9b263b9a17dffd7 = { "samples": { value: [] }, + "samplesR": { + value: [] + }, "bluenoise": { value: null }, @@ -23069,6 +23072,7 @@ uniform vec3 cameraPos; uniform vec2 resolution; uniform float time; uniform vec3[SAMPLES] samples; +uniform float[SAMPLES] samplesR; uniform float radius; uniform float distanceFalloff; uniform float near; @@ -23150,14 +23154,6 @@ uniform sampler2D bluenoise; return normalize(cross(dpdx, dpdy)); } -mat3 makeRotationZ(float theta) { - float c = cos(theta); - float s = sin(theta); - return mat3(c, - s, 0, - s, c, 0, - 0, 0, 1); - } - void main() { vec4 diffuse = texture2D(sceneDiffuse, vUv); float depth = texture2D(sceneDepth, vUv).x; @@ -23166,22 +23162,29 @@ void main() { return; } vec3 worldPos = getWorldPos(depth, vUv); + // vec3 normal = texture2D(sceneNormal, vUv).rgb;//computeNormal(worldPos, vUv); #ifdef HALFRES vec3 normal = texture2D(sceneNormal, vUv).rgb; #else vec3 normal = computeNormal(worldPos, vUv); #endif vec4 noise = texture2D(bluenoise, gl_FragCoord.xy / 128.0); - vec3 helperVec = vec3(0.0, 1.0, 0.0); - if (dot(helperVec, normal) > 0.99) { - helperVec = vec3(1.0, 0.0, 0.0); - } - vec3 tangent = normalize(cross(helperVec, normal)); - vec3 bitangent = cross(normal, tangent); - mat3 tbn = mat3(tangent, bitangent, normal) * makeRotationZ(noise.r * 2.0 * 3.1415962) ; - + vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0); + vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal)); + vec3 bitangent = cross(normal, tangent); + mat3 tbn = mat3(tangent, bitangent, normal); float occluded = 0.0; float totalWeight = 0.0; + /* float radiusScreen = distance( + worldPos, + getWorldPos(depth, vUv + + vec2(48.0, 0.0) / resolution) + );/*vUv.x < 0.5 ? radius : min(distance( + worldPos, + getWorldPos(depth, vUv + + vec2(100.0, 0.0) / resolution) + ), radius); + float distanceFalloffScreen = radiusScreen * 0.2;*/ float radiusToUse = screenSpaceRadius ? distance( worldPos, getWorldPos(depth, vUv + @@ -23189,53 +23192,44 @@ void main() { ) : radius; float distanceFalloffToUse =screenSpaceRadius ? radiusToUse * distanceFalloff - : radiusToUse * distanceFalloff * 0.2; - float bias = (min( - 0.1, - distanceFalloffToUse * 0.1 - ) / near) * fwidth(distance(worldPos, cameraPos)) / radiusToUse; - float phi = 1.61803398875; - float offsetMove = 0.0; - float offsetMoveInv = 1.0 / FSAMPLES; + : distanceFalloff; + float bias = (0.1 / near) * fwidth(distance(worldPos, cameraPos)) / radiusToUse; for(float i = 0.0; i < FSAMPLES; i++) { - vec3 sampleDirection = tbn * samples[int(i)]; - - float moveAmt = fract(noise.g + offsetMove); - offsetMove += offsetMoveInv; - + vec3 sampleDirection = + tbn * + samples[int(i)]; + ; + float moveAmt = samplesR[int(mod(i + noise.a * FSAMPLES, FSAMPLES))]; vec3 samplePos = worldPos + radiusToUse * moveAmt * sampleDirection; vec4 offset = projMat * vec4(samplePos, 1.0); offset.xyz /= offset.w; offset.xyz = offset.xyz * 0.5 + 0.5; - - vec2 diff = gl_FragCoord.xy - floor(offset.xy * resolution); - // From Rabbid76's hbao - vec2 clipRangeCheck = step(vec2(0.0),offset.xy) * step(offset.xy, vec2(1.0)); - float sampleDepth = textureLod(sceneDepth, offset.xy, 0.0).x; - - #ifdef LOGDEPTH - - float distSample = linearize_depth_log(sampleDepth, near, far); - - #else - - float distSample = ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far); - - #endif - - float distWorld = ortho ? linearize_depth_ortho(offset.z, near, far) : linearize_depth(offset.z, near, far); - - float rangeCheck = smoothstep(0.0, 1.0, distanceFalloffToUse / (abs(distSample - distWorld))); - - float sampleValid = (clipRangeCheck.x * clipRangeCheck.y); - occluded += rangeCheck * float(sampleDepth != depth) * float(distSample + bias < distWorld) * step( - 1.0, - dot(diff, diff) - ) * sampleValid; - - totalWeight += sampleValid; + float sampleDepth = textureLod(sceneDepth, offset.xy, 0.0).x; + /*float distSample = logDepth ? linearize_depth_log(sampleDepth, near, far) + (ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far));*/ + #ifdef LOGDEPTH + float distSample = linearize_depth_log(sampleDepth, near, far); + #else + float distSample = ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far); + #endif + float distWorld = ortho ? linearize_depth_ortho(offset.z, near, far) : linearize_depth(offset.z, near, far); + float rangeCheck = smoothstep(0.0, 1.0, distanceFalloffToUse / (abs(distSample - distWorld))); + vec2 diff = gl_FragCoord.xy - ( offset.xy * resolution); + float weight = dot(sampleDirection, normal); + occluded += rangeCheck * weight * + (distSample + bias + < distWorld ? 1.0 : 0.0) * ( + (dot( + diff, + diff + + ) < 1.0 || (sampleDepth == depth) || ( + offset.x < 0.0 || offset.x > 1.0 || offset.y < 0.0 || offset.y > 1.0 + ) ? 0.0 : 1.0) + ); + totalWeight += weight; } - float occ = clamp(1.0 - occluded / (totalWeight == 0.0 ? 1.0 : totalWeight), 0.0, 1.0); + float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0); gl_FragColor = vec4(0.5 + 0.5 * normal, occ); }` }; @@ -23253,18 +23247,6 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = { "tDiffuse": { value: null }, - "transparencyDWFalse": { - value: null - }, - "transparencyDWTrue": { - value: null - }, - "transparencyDWTrueDepth": { - value: null - }, - "transparencyAware": { - value: false - }, "projMat": { value: new Matrix4() }, @@ -23356,9 +23338,6 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = { uniform sampler2D sceneDiffuse; uniform highp sampler2D sceneDepth; uniform highp sampler2D downsampledDepth; - uniform highp sampler2D transparencyDWFalse; - uniform highp sampler2D transparencyDWTrue; - uniform highp sampler2D transparencyDWTrueDepth; uniform sampler2D tDiffuse; uniform sampler2D blueNoise; uniform vec2 resolution; @@ -23376,7 +23355,6 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = { uniform bool fog; uniform bool fogExp; uniform bool colorMultiply; - uniform bool transparencyAware; uniform float fogDensity; uniform float fogNear; uniform float fogFar; @@ -23495,7 +23473,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = { vec4 sampleInfo = texelFetch(tDiffuse, p, 0); vec3 normalSample = sampleInfo.xyz * 2.0 - 1.0; vec3 worldPosSample = getWorldPos(sampleDepth, pUv); - float tangentPlaneDist = abs(dot(worldPosSample - worldPos, normal)); + float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal)); float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0); float weight = rangeCheck; totalWeight += weight; @@ -23532,16 +23510,6 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = { fogFactor = smoothstep( fogNear, fogFar, fogDepth ); } } - if (transparencyAware) { - float transparencyDWOff = texture2D(transparencyDWFalse, vUv).a; - float transparencyDWOn = texture2D(transparencyDWTrue, vUv).a; - float adjustmentFactorOff = transparencyDWOff; - float adjustmentFactorOn = (1.0 - transparencyDWOn) * ( - texture2D(transparencyDWTrueDepth, vUv).r == texture2D(sceneDepth, vUv).r ? 1.0 : 0.0 - ); - float adjustmentFactor = max(adjustmentFactorOff, adjustmentFactorOn); - finalAo = mix(finalAo, 1.0, adjustmentFactor); - } finalAo = mix(finalAo, 1.0, fogFactor); vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply)); if (renderMode == 0.0) { @@ -23748,8 +23716,8 @@ const $e52378cd0f5a973d$export$57856b59f317262e = { vec2(worldRadius, 0.0) / resolution) ) : worldRadius; float distanceFalloffToUse =screenSpaceRadius ? - radiusToUse * distanceFalloff - : radiusToUse * distanceFalloff * 0.2; + radiusToUse * distanceFalloff + : distanceFalloff; for(int i = 0; i < NUM_SAMPLES; i++) { @@ -23759,7 +23727,7 @@ const $e52378cd0f5a973d$export$57856b59f317262e = { vec3 normalSample = dataSample.rgb * 2.0 - 1.0; float dSample = texture2D(sceneDepth, uv + offset).x; vec3 worldPosSample = getWorldPos(dSample, uv + offset); - float tangentPlaneDist = abs(dot(worldPosSample - worldPos, normal)); + float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal)); float rangeCheck = dSample == 1.0 ? 0.0 :exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0) * (1.0 - abs(occSample - baseOcc)); occlusion += occSample * rangeCheck; count += rangeCheck; @@ -23906,6 +23874,47 @@ const $26aca173e0984d99$export$1efdf491687cd442 = { gNormal = vec4(computeNormal( getWorldPos(samples[chosenIndex], uvSamples[chosenIndex]), uvSamples[chosenIndex] ), 0.0); + /* float[] samples = float[4](depth00, depth10, depth01, depth11); + float c = 0.25 * (depth00 + depth10 + depth01 + depth11); + float[] distances = float[4](depth00, depth10, depth01, depth11); + float maxDistance = max(max(distances[0], distances[1]), max(distances[2], distances[3])); + + int remaining[3]; + int rejected[3]; + int i, j, k; + + for(i = 0, j = 0, k = 0; i < 4; ++i) { + if (distances[i] < maxDistance) { + remaining[j++] = i; + } else { + rejected[k++] = i; + } + } + for(;j < 3;++j) { + remaining[j] = rejected[--k]; + } + vec3 s = vec3( + samples[remaining[0]], + samples[remaining[1]], + samples[remaining[2]] + ); + c = (s.x + s.y + s.z) / 3.0; + + distances[0] = abs(c - s.x); + distances[1] = abs(c - s.y); + distances[2] = abs(c - s.z); + + float minDistance = min(min(distances[0], distances[1]), distances[2]); + + for(i = 0; i < 3; ++i) { + if (distances[i] == minDistance) { + break; + } + }*/ + /* gl_FragColor = vec4(samples[remaining[i]], 0.0, 0.0, 0.0); + gNormal = vec4(computeNormal( + getWorldPos(samples[remaining[i]], uvSamples[remaining[i]]), uvSamples[remaining[i]] + ), 0.0);*/ }` }; @@ -23995,9 +24004,7 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { halfRes: false, depthAwareUpsampling: true, autoRenderBeauty: true, - colorMultiply: true, - transparencyAware: false, - stencil: false + colorMultiply: true }, { set: (target, propName, value)=>{ const oldProp = target[propName]; @@ -24011,46 +24018,21 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { this.setSize(this.width, this.height); } if (propName === "depthAwareUpsampling" && oldProp !== value) this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer); - if (propName === "transparencyAware" && oldProp !== value) { - this.autoDetectTransparency = false; - this.configureTransparencyTarget(); - } - if (propName === "stencil" && oldProp !== value) { - /* this.beautyRenderTarget.stencilBuffer = value; - this.beautyRenderTarget.depthTexture.format = value ? THREE.DepthStencilFormat : THREE.DepthFormat; - this.beautyRenderTarget.depthTexture.type = value ? THREE.UnsignedInt248Type : THREE.UnsignedIntType; - this.beautyRenderTarget.depthTexture.needsUpdate = true; - this.beautyRenderTarget.needsUpdate = true;*/ this.beautyRenderTarget.dispose(); - this.beautyRenderTarget = new WebGLRenderTarget(this.width, this.height, { - minFilter: LinearFilter, - magFilter: NearestFilter, - type: HalfFloatType, - format: RGBAFormat, - stencilBuffer: value - }); - this.beautyRenderTarget.depthTexture = new DepthTexture(this.width, this.height, value ? UnsignedInt248Type : UnsignedIntType); - this.beautyRenderTarget.depthTexture.format = value ? DepthStencilFormat : DepthFormat; - } return true; } }); /** @type {THREE.Vector3[]} */ this.samples = []; + /** @type {number[]} */ this.samplesR = []; /** @type {THREE.Vector2[]} */ this.samplesDenoise = []; - this.autoDetectTransparency = true; + this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer); + this.configureSampleDependentPasses(); + this.configureHalfResTargets(); this.beautyRenderTarget = new WebGLRenderTarget(this.width, this.height, { minFilter: LinearFilter, - magFilter: NearestFilter, - type: HalfFloatType, - format: RGBAFormat, - stencilBuffer: false + magFilter: NearestFilter }); this.beautyRenderTarget.depthTexture = new DepthTexture(this.width, this.height, UnsignedIntType); this.beautyRenderTarget.depthTexture.format = DepthFormat; - this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer); - this.configureSampleDependentPasses(); - this.configureHalfResTargets(); - this.detectTransparency(); - this.configureTransparencyTarget(); this.writeTargetInternal = new WebGLRenderTarget(this.width, this.height, { minFilter: LinearFilter, magFilter: LinearFilter, @@ -24103,110 +24085,13 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { } } } - detectTransparency() { - if (this.autoDetectTransparency) { - let isTransparency = false; - this.scene.traverse((obj)=>{ - if (obj.material && obj.material.transparent) isTransparency = true; - }); - this.configuration.transparencyAware = isTransparency; - } - } - configureTransparencyTarget() { - if (this.configuration.transparencyAware) { - this.transparencyRenderTargetDWFalse = new WebGLRenderTarget(this.width, this.height, { - minFilter: LinearFilter, - magFilter: NearestFilter, - type: HalfFloatType, - format: RGBAFormat - }); - this.transparencyRenderTargetDWTrue = new WebGLRenderTarget(this.width, this.height, { - minFilter: LinearFilter, - magFilter: NearestFilter, - type: HalfFloatType, - format: RGBAFormat - }); - this.transparencyRenderTargetDWTrue.depthTexture = new DepthTexture(this.width, this.height, UnsignedIntType); - this.depthCopyPass = new ($e4ca8dcb0218f846$export$dcd670d73db751f5)(new ShaderMaterial({ - uniforms: { - depthTexture: { - value: this.beautyRenderTarget.depthTexture - } - }, - vertexShader: /* glsl */ ` - varying vec2 vUv; - void main() { - vUv = uv; - gl_Position = vec4(position, 1); - }`, - fragmentShader: /* glsl */ ` - uniform sampler2D depthTexture; - varying vec2 vUv; - void main() { - gl_FragDepth = texture2D(depthTexture, vUv).r + 0.00001; - gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); - } - ` - })); - } else { - if (this.transparencyRenderTargetDWFalse) { - this.transparencyRenderTargetDWFalse.dispose(); - this.transparencyRenderTargetDWFalse = null; - } - if (this.transparencyRenderTargetDWTrue) { - this.transparencyRenderTargetDWTrue.dispose(); - this.transparencyRenderTargetDWTrue = null; - } - if (this.depthCopyPass) { - this.depthCopyPass.dispose(); - this.depthCopyPass = null; - } - } - } - renderTransparency(renderer) { - const oldBackground = this.scene.background; - const oldClearColor = renderer.getClearColor(new Color()); - const oldClearAlpha = renderer.getClearAlpha(); - const oldVisibility = new Map(); - const oldAutoClearDepth = renderer.autoClearDepth; - this.scene.traverse((obj)=>{ - oldVisibility.set(obj, obj.visible); - }); - // Override the state - this.scene.background = null; - renderer.autoClearDepth = false; - renderer.setClearColor(new Color(0, 0, 0), 0); - this.depthCopyPass.material.uniforms.depthTexture.value = this.beautyRenderTarget.depthTexture; - // Render out transparent objects WITHOUT depth write - renderer.setRenderTarget(this.transparencyRenderTargetDWFalse); - this.scene.traverse((obj)=>{ - if (obj.material) obj.visible = oldVisibility.get(obj) && obj.material.transparent && !obj.material.depthWrite && !obj.userData.treatAsOpaque; - }); - renderer.clear(true, true, true); - this.depthCopyPass.render(renderer); - renderer.render(this.scene, this.camera); - // Render out transparent objects WITH depth write - renderer.setRenderTarget(this.transparencyRenderTargetDWTrue); - this.scene.traverse((obj)=>{ - if (obj.material) obj.visible = oldVisibility.get(obj) && obj.material.transparent && obj.material.depthWrite && !obj.userData.treatAsOpaque; - }); - renderer.clear(true, true, true); - this.depthCopyPass.render(renderer); - renderer.render(this.scene, this.camera); - // Restore - this.scene.traverse((obj)=>{ - obj.visible = oldVisibility.get(obj); - }); - renderer.setClearColor(oldClearColor, oldClearAlpha); - this.scene.background = oldBackground; - renderer.autoClearDepth = oldAutoClearDepth; - } configureSampleDependentPasses() { this.configureAOPass(this.configuration.logarithmicDepthBuffer); this.configureDenoisePass(this.configuration.logarithmicDepthBuffer); } configureAOPass(logarithmicDepthBuffer = false) { this.samples = this.generateHemisphereSamples(this.configuration.aoSamples); + this.samplesR = this.generateHemisphereSamplesR(this.configuration.aoSamples); const e = { ...($1ed45968c1160c3c$export$c9b263b9a17dffd7) }; @@ -24249,7 +24134,7 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { const points = []; for(let k = 0; k < n; k++){ const theta = 2.399963 * k; - let r = Math.sqrt(k + 0.5) / Math.sqrt(n); + const r = Math.sqrt(k + 0.5) / Math.sqrt(n); const x = r * Math.cos(theta); const y = r * Math.sin(theta); // Project to hemisphere @@ -24258,6 +24143,15 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { } return points; } + /** + * + * @param {number} n + * @returns {number[]} + */ generateHemisphereSamplesR(n) { + let samplesR = []; + for(let i = 0; i < n; i++)samplesR.push((i + 1) / n); + return samplesR; + } /** * * @param {number} numSamples @@ -24285,10 +24179,6 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { this.writeTargetInternal.setSize(width * c, height * c); this.readTargetInternal.setSize(width * c, height * c); if (this.configuration.halfRes) this.depthDownsampleTarget.setSize(width * c, height * c); - if (this.configuration.transparencyAware) { - this.transparencyRenderTargetDWFalse.setSize(width, height); - this.transparencyRenderTargetDWTrue.setSize(width, height); - } } render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) { if (renderer.capabilities.logarithmicDepthBuffer !== this.configuration.logarithmicDepthBuffer) { @@ -24297,7 +24187,6 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { this.configureDenoisePass(this.configuration.logarithmicDepthBuffer); this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer); } - this.detectTransparency(); let gl; let ext; let timerQuery; @@ -24312,7 +24201,6 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { if (this.configuration.autoRenderBeauty) { renderer.setRenderTarget(this.beautyRenderTarget); renderer.render(this.scene, this.camera); - if (this.configuration.transparencyAware) this.renderTransparency(renderer); } if (this.debugMode) { timerQuery = gl.createQuery(); @@ -24347,6 +24235,7 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { this.effectShaderQuad.material.uniforms["resolution"].value = this.configuration.halfRes ? this._r.clone().multiplyScalar(0.5).floor() : this._r; this.effectShaderQuad.material.uniforms["time"].value = performance.now() / 1000; this.effectShaderQuad.material.uniforms["samples"].value = this.samples; + this.effectShaderQuad.material.uniforms["samplesR"].value = this.samplesR; this.effectShaderQuad.material.uniforms["bluenoise"].value = this.bluenoise; this.effectShaderQuad.material.uniforms["radius"].value = trueRadius; this.effectShaderQuad.material.uniforms["distanceFalloff"].value = this.configuration.distanceFalloff; @@ -24390,12 +24279,6 @@ class $05f6997e4b65da14$export$2d57db20b5eb5e0a extends (Pass) { // Now, we have the blurred AO in writeTargetInternal // End the blur // Start the composition - if (this.configuration.transparencyAware) { - this.effectCompositerQuad.material.uniforms["transparencyDWFalse"].value = this.transparencyRenderTargetDWFalse.texture; - this.effectCompositerQuad.material.uniforms["transparencyDWTrue"].value = this.transparencyRenderTargetDWTrue.texture; - this.effectCompositerQuad.material.uniforms["transparencyDWTrueDepth"].value = this.transparencyRenderTargetDWTrue.depthTexture; - this.effectCompositerQuad.material.uniforms["transparencyAware"].value = true; - } this.effectCompositerQuad.material.uniforms["sceneDiffuse"].value = this.beautyRenderTarget.texture; this.effectCompositerQuad.material.uniforms["sceneDepth"].value = this.beautyRenderTarget.depthTexture; this.effectCompositerQuad.material.uniforms["near"].value = this.camera.near; diff --git a/yarn.lock b/yarn.lock index 04ee50fc6..b5ead5758 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6087,6 +6087,7 @@ __metadata: web-ifc: 0.0.46 peerDependencies: bim-fragment: 1.3.1 + mapbox-gl: ^2.15.0 three: 0.152.2 web-ifc: 0.0.46 languageName: unknown