Skip to content

Commit f8f2b56

Browse files
zjm-metameta-codesync[bot]
authored andcommitted
fix(core): Fix the depth occlusion when developer explicitly set material.transparent=true.
Summary: Softserve developer found that their app’s occlusion system failed for partially occluded materials because they set `transparent: false, opacity: 1`, overriding IWSDK’s `transparent: true` setup. **Root Cause:** - Depth occlusion relies on alpha modulation (`diffuseColor.a *= occlusion_value`), which only works if `material.transparent` is true. - External code setting `transparent = false` (e.g., after placement animations) breaks occlusion, making occluded geometry fully opaque. **Fix:** - Discard fragments with `occlusion_value < 0.01` to always remove fully occluded geometry, regardless of the transparent flag. - Soft edges remain when alpha blending is active; otherwise, edges degrade gracefully to hard. Reviewed By: felixtrz Differential Revision: D94739128 fbshipit-source-id: deb3221423b2f63130261eba30c727ad31007ecc
1 parent e26c7a1 commit f8f2b56

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

examples/depth-occlusion/src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,12 @@ World.create(document.getElementById('scene-container'), {
218218
// Register the depth sensing system with occlusion enabled
219219
world
220220
.registerSystem(DepthSensingSystem, {
221-
enableDepthTexture: true,
222-
enableOcclusion: true,
223-
useFloat32: true,
224-
blurRadius: 20.0,
221+
configData: {
222+
enableDepthTexture: true,
223+
enableOcclusion: true,
224+
useFloat32: true,
225+
blurRadius: 20.0,
226+
},
225227
})
226228
.registerComponent(DepthOccludable);
227229

packages/core/src/depth/depth-sensing-system.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ export class DepthSensingSystem extends createSystem(
254254
' occlusion_value += OcclusionGetSample(depthUV, texelSize * vec2( 0.866, -0.5));',
255255
' occlusion_value /= 13.0;',
256256
' }',
257+
' if (occlusion_value < 0.01) {',
258+
' discard;',
259+
' }',
257260
' diffuseColor.a *= occlusion_value;',
258261
'}',
259262
].join('\n'),

0 commit comments

Comments
 (0)