I made a Depth of Field post-effect. We’re not gonna use it on a project, so I’m sharing it here.
I had trouble finding a DoF post effect for my needs. The forum posts I saw either pointed to the built-in PlayCanvas engine Render Pass DoF or a 10 year old PostEffect implementation. And PlayCanvas didn’t have a DoF PostEffect in the examples.
This one is mainly based off the PlayCanvas engine implementation that uses render passes, which iirc is inspired by a Google Filament example.
The script is far from perfect, I mashed things together. So, expect bugs and less-than-optimal logic. In “Screen Center” focus mode, it uses a raycast to decide which object to focus. Which means for that mode you need Ammo.js and objects with rigid body on them to focus. There’s probably a better way to do that without Ammo.
That one seems nice, probably better overall. I was initially using that one, but the engine didn’t like me combining that DoF using render passes + other post effects on the same camera, so I had to switch to purely PostEffect scripts.
Is there documentation on Render Passes vs PostEffects? I was looking around trying to figure out if PostEffects are getting deprecated or if one was preferred over the other, but I didn’t find anything.