pmndrs / react-postprocessing

📬 postprocessing for react-three-fiber
https://docs.pmnd.rs/react-postprocessing
MIT License
1.1k stars 101 forks source link

Depth of field performance #88

Open samuelcelko opened 3 years ago

samuelcelko commented 3 years ago

Hey there, been wondering if anyone else has had performance issues after applying depth of field to a scene. Code below.

<DepthOfField focusDistance={0} focalLength={0.015} bokehScale={1} height={900} />

FPS just tanks after putting this in. Tried to mess with the settings but nothing seems to be helping. Does anyone have any suggestions on how to make the performance better?

Thanks!

talentlessguy commented 3 years ago

Did you try to use DOF directly from postporcessing?

also did FPS drop in react dev mode or in prod?

in dev it might re-apply the same effect so you have multiple DOFs so that's why FPS might drop

dongho-shin commented 1 year ago

I think this would be problem DepthOfField.tsx in line 23 https://github.com/pmndrs/react-postprocessing/blob/master/src/effects/DepthOfField.tsx

image

every props or camera changes, DepthOfEffect instance has created in useMemo so it causes memory leak