I was just wondering how I could create a DOF effect within UNITY. I am using the “Blur effect” on my camera but everything in the scene get’s blurred (no suprise) so what would I need to do in order to get the front objects sharp and those objects that are far away blurred? Do I have to set up another camera? I know it’s possible to get that effect but I just don’t know how to get there. Any advise?
It does look pretty nice if adjusted properly. The idea of multiple blur strengths doesn’t work unfortunately. Cameras with overlapping view ports don’t seem to retain their separate image effects. The topmost camera’s image effects override the ones below it. You can however have two, or more, camera view ports side by side each with their own separate image effects.
No that works fine, sorry, I wasn’t entirely clear. I meant within the camera’s own view port the image effect will work fine, but if you’re using “depth only” to layer camera’s directly ontop of eachother only the topmost camera’s effects will show inside that view port rectangle.
Thanks for the advice aNTeNNa trEE but I can’t seem to get it right for some reason. Everything just looks blurred and I am having a hard time adjusting it. Could you possibly post a scene file with the cameras set up?
I’ve tried this as well, and the blur effects don’t appear to stack on my machine. I’d link to my web player, but it’s a work-in-progress for the Platformer Tutorial (not sure if Joe wants me a let it out yet).
I’ll cook a little scene up. Sometimes it doesn’t “stack” properly (the blur on the far camera just isn’t there). When this happens I restart Unity and it works fine.
Gary, I’ve wanted to see that 3rd person platformer for a while… really looking forward to seeing what you guys came up with.
webplayer of what it should look like…FPS controls.
The more I play with this effect the more I realize it’s very finicky… changing certain assets such as Materials will make it stop working and require a Unity restart.
Thanks a bunch aNTeNNa trEE! I guess the trick is “tweaking” the cameras. Odd that you have to restart UNITY when changing assets though…gotta check if that’s the same for me and if so…well I guess it’s a bug which needs to be reported
I checked out your scene and we’re doing pretty much the same thing. I tried having 3 cameras, 2 with different blurs, and they definitely don’t stack. Took your sceene and added a Glow to the child Camera, and as soon as that gets switched on, the blur goes away.
I chatted with Joachim about this shortly before the 1.5 release, and it sounds like it’s a bug. No biggie, the hacked DOF effect looks sweet. With a little more refinement (being able to render ZDepth to texture and using that to attenuate the DOF effect) you could use it to GREAT effect. I’ve added it to the Platformer tutorial level, but sadly that means no glow effects for now (I’ll just have to abuse Additive FX ;)).
I misunderstood you Gary. More than one effect on top of eachother never works right now. Let’s hope that’s a bug and not a limitation of how the image effects pipeline works. I meant sometimes even the one blur effect doesn’t show up.
The ZDepth is a good idea I posted about before and never heard anything back on. It would be great to have ZDepth and a real alpha mask to work with regarding image effects.
What kinds of blur can Unity Pro do? Can it do a linear blur? Radial blur out from the center? Can it blur the motion of moving objects while leaving other objects alone?
(I’m thinking of blurring textures to simulate speed in a future first-person game, but if I’m going to get Pro anyway and Pro can do that, then I wouldn’t bother.)
I found the Blur script pretty easy to manipulate… you can take out the Y direction to make it blur only along X for a linear effect. Radial blur might be slightly harder to script, but it’s all right there in simple XY coordinates ready to be tweaked. Motion blur is available and given enough iterations it looks very nice. The image effect scripts seem very straight forward (even with my limited coding skills) and I bet you could crank out any blur effect you want.
Being able to apply a certain image effect to a certain object requires layering cameras , but making only certain objects be affected by a motion blur is as simple enough as putting them in a separate layer (or it should be), and it might work better than the clipping planes discussed in this thread.