- Home /
How to use 2 Cameras in FPS
Right, I'm not sure if this is possible so please, if I'm barking up the wrong tree let me know :)
I want some objects on my screen to blur whilst others stay as normal. So I think I read somewhere that you can create 2 cameras, one with a blur effect on and culling anything in the scene that you dont want to blur.
Is this right?
So I've duplicated my main camera and made it so that it just sees the objects I want to blur. But I can't work out how to look through both cameras at the same time. Is this possible?
Thanks
Edit - I have got the two cameras at different depths. However I only seem to see through whichever one is higher, and not two at the same time. i.e. I see either the objects that are blurry or the objects that aren't
Answer by taoa · Apr 30, 2010 at 02:59 PM
-=PRO ONLY SOLUTION=-
By "I've duplicated my main camera and made it so that it just sees the objects I want to blur" I assume you mean you've put all the objects you want blurred in a 'Blur' layer. I also suppose you have set your 'Blur' camera to render Nothing except objects of the 'Blur' layer, and your main camera to render Everything except the same objects.
So you're properly set :)
Now the 'tricky' bit (not so tricky, you'll see ;) ):
You cannot get both cameras to render freely. One will be render all over the other camera's own render, depending on the order in which they render (decided by the 'depth' property of the cameras, the lower the sooner). The trick is, to your 'Blur' camera, attach a little script that will create at start (and every time the screen resolution gets changed) a RenderTexture of the screen resolution size, and assign it to the camera's targetTexture property. Set the camera's clear colour to fully transparent (and I suggest black for the rest), and then to the MAIN camera, attach a script (if there isn't one already) inside which you'll implement the OnRenderImage function which will render full screen the Blur camera's target texture with you blur effect on.
And you're done.
Except you'll probably have some occlusion issues because of the non blurred objects not rendered in your blur camera.
I'll let you sort this out, it's getting complicated ^_^
Cool, I don't totally understand this yet but I will have a go at working it out in an hour or so and hopefully I will figure it out. Thanks for your help :)
Answer by Pure Phase · Apr 30, 2010 at 02:51 PM
OK I have worked this out now, you need to set clear flags to depth only.
However, this has not produced the effect that I thought it would. I wanted it to only blur the things it could see, but it just blurs everything. Is there another way of doing this at all?