Skip to content

Commit 087a34c

Browse files
committed
add codys dof fix
1 parent 5fc5406 commit 087a34c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/effects/DepthOfField.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DepthOfFieldEffect } from 'postprocessing'
1+
import { DepthOfFieldEffect, MaskFunction } from 'postprocessing'
22
import { Ref, forwardRef, useMemo, useLayoutEffect, useContext } from 'react'
33
import { ReactThreeFiber, useThree } from '@react-three/fiber'
44
import { type DepthPackingStrategies, type Texture, Vector3 } from 'three'
@@ -20,7 +20,13 @@ export const DepthOfField = forwardRef(function DepthOfField(
2020
) {
2121
const invalidate = useThree((state) => state.invalidate)
2222
const { camera } = useContext(EffectComposerContext)
23-
const effect = useMemo(() => new DepthOfFieldEffect(camera, props), [camera, props])
23+
const effect = useMemo(() => {
24+
const effect = new DepthOfFieldEffect(camera, props)
25+
// Temporary fix that restores DOF 6.21.3 behavior, everything since then lets shapes leak through the blur
26+
const maskMaterial = (effect as any).maskPass.getFullscreenMaterial()
27+
maskMaterial.maskFunction = MaskFunction.MULTIPLY_RGB_SET_ALPHA
28+
return effect
29+
}, [camera, props])
2430
useLayoutEffect(() => {
2531
if (target && typeof target !== 'number') {
2632
const vec: Vector3 =

0 commit comments

Comments
 (0)