- Home /
Is it possible to have 2 cameras, 1st with mask to reveal 2nd underneath?
Hello! I was wondering if it's possible with Unity to have 2 different cameras, both rendering a similar scene, and then mask the first camera with a texture to display the 2nd camera underneath.
Basically, I have a concept for a game where I'd ideally like to have spots on the camera pass by as the player travels through the world, and I'd like the world to be displayed differently in those spots. My idea for this was to have 2 nearly identical scenes with cameras, and then somehow mask the main camera displaying the background camera underneath with a slightly different scene.
With an ideal solution, I'd like to be able to modify the mask on the fly and perhaps animate the mask so I could have moving "holes" in the camera showing the alternate view. Is there a tutorial or example like what I'm describing anywhere to get me started?
Thanks!
Edit: By "scenes" I didn't mean actual Unity scenes, I meant it in the general sense. I'd like to have 2 different setups of the same game level in one unity scene, and then have the cameras sort of blend together in the way I described above.
you can't render two scene at once... but you can have two cameras, and you can add scenes together.
Sorry, I sort of worded that incorrectly. By scenes I didn't mean like actual Unity scenes, I meant different places in one scene. Different setups of the same game level.
blend together two scenes? does the camera fade into one another? is this mask mesh? a component? is it the culling mask of the camera?
$$anonymous$$aybe a picture will explain my question. Here's a roughly thrown together example of what I want to achieve:
ok now i know. nice game btw... Ratchet and clank: Crack in Time did this once as well i think, i guess you seen the $$anonymous$$i map tutorials. you could place a script on the mask that randomizes its rotation, position and scale. giving it the illusion of animating/distortion. as for.. wait is that sonic? anyway.. to make it follow just get sonics position on camera 1's screen space, then convert to world space using camera 2, this would be the mask position for it to follow sonic/
Answer by karljj1 · Nov 28, 2013 at 07:11 PM
You could render the top view to a texture then combine it with a mask texture which would just be a circle (the area shown) and the rest full alpha. Then draw the combined texture as a GUI texture on the top. Probably best to push the drawing to a shader but as a quick test this should work.
Edit:
Also take a look at stencils. Could be a nice way to do it:
http://docs.unity3d.com/Documentation/Components/SL-Stencil.html
Your answer
Follow this Question
Related Questions
Shader: Mask Without a Texture? 2 Answers
Uniform Texture, Rendering Problem 0 Answers
Why is my picture distorted? 0 Answers
Saving Texture at Run time and Reusing it 0 Answers
transparent shader objects disappear on certain camera angles 6 Answers