Skip to content

Commit

Permalink
add codys dof fix
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed May 1, 2023
1 parent 5fc5406 commit 087a34c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/effects/DepthOfField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DepthOfFieldEffect } from 'postprocessing'
import { DepthOfFieldEffect, MaskFunction } from 'postprocessing'
import { Ref, forwardRef, useMemo, useLayoutEffect, useContext } from 'react'
import { ReactThreeFiber, useThree } from '@react-three/fiber'
import { type DepthPackingStrategies, type Texture, Vector3 } from 'three'
Expand All @@ -20,7 +20,13 @@ export const DepthOfField = forwardRef(function DepthOfField(
) {
const invalidate = useThree((state) => state.invalidate)
const { camera } = useContext(EffectComposerContext)
const effect = useMemo(() => new DepthOfFieldEffect(camera, props), [camera, props])
const effect = useMemo(() => {
const effect = new DepthOfFieldEffect(camera, props)
// Temporary fix that restores DOF 6.21.3 behavior, everything since then lets shapes leak through the blur
const maskMaterial = (effect as any).maskPass.getFullscreenMaterial()
maskMaterial.maskFunction = MaskFunction.MULTIPLY_RGB_SET_ALPHA
return effect
}, [camera, props])
useLayoutEffect(() => {
if (target && typeof target !== 'number') {
const vec: Vector3 =
Expand Down

0 comments on commit 087a34c

Please sign in to comment.