- Home /
overlay perspective on orthographic camera
Hi all,
I've learned a lot about multiple cameras, and I think I've got it mostly figured out. There's one thing that has me stuck. I have 3 cameras in the scene, each for a specific purpose.
I have a perspective camera for my 3rd person character. (depth 0, clear skybox).
I have an orthographic camera for my HUD (depth 1, clear depth only).
I have another perspective camera for an item in the HUD (depth 2, clear depth only).
So I want to have cameras 2 and 3 in the same position, and place the 3d object as though it's in front of the HUD (in a thumbnail). The problem is that when camera 3 is perspective the orthographic camera 2 becomes invisible. I'm certain I've got everything setup right, as its only when i switch it to perspective that it disappears. I believe I have three options now:
make my HUD camera 2 a perspective that appears to be flat (everything needs to align perfectly).
somehow get my HUD to appear in between the gameplay and the 3d item. (maybe im missing something, this would be ideal).
Use something like a renderTexture to show the 3d objects over the HUD (this sounds bad and again, everything needs to align nicely).
Hopefully someone out there knows why my orthographic is hidden behind the perspective. Or another alternative...
Yeah, use 'don't clear' for the ones on top, not 'depth clear'.
Im looking into this also.. seems fine if they are all persp or all ortho it works, but if you mix cams it doesnt seem to, for me at least
I think I've tried every combination of clear flags. Still the only way I can make it work is for the top 2 cameras to be orthographic. $$anonymous$$akes no sense!
Could anyone please explain why it is impossible for perpsective camera to overlay an orthographic camera?
Hello everyone,
I'm struggling with this same issue in a project I'm working on. Did you ever find a solution to the problem?
I actually have a strange work around where when I start the scene initially the perspective camera is hidden behind the orthographic camera, but if I change the clear flag settings back and forth while the project is playing I can actually get the perspective camera to overlay properly. But no matter what settings I choose, I can't seem to get it to work from the get go! Hah!
Answer by squishyBit · Nov 11, 2011 at 05:55 AM
Might not be the case but are you sure you set the camera's clear flags to "don't clear" or "depth only"?
it cant be the clear flags if it works when both are orthographic, although it would seem the clear flags dont work when you have persp and ortho.
I'm going to use renderTextures for now until this can be sorted out
Could it have something to do with the rendering path? I might put together a test project so an expert can look into it
Answer by Stilghar · Nov 29, 2014 at 06:20 PM
Using forward rendering seems to work, not sure why it doesn't for the other rendering paths.
I just had a similar issue with 3 cameras. Background Camera(oath), $$anonymous$$ain Camera(perspect), Foreground Camera(ortho) and setting them to forward rendering path was the answer for me. Depth is bg camera = 1, main = 2, foreground = 3. That is important too. Now my cameras render properly. First the foreground cam, then main, and lastly background camera.
Setting the depth was my problem -- my depths were the same so it worked fine originally and when when I closed and re-opened unity, it didn't work. Thanks AT$$anonymous$$Ethan.
Your answer
Follow this Question
Related Questions
Editor Camera Perspective 1 Answer
Draw orthographic visuals (e.g. health bar) in perspective scene? 4 Answers
Using a perspective camera can an object act as if viewed by orthographic camera? 1 Answer
Camera 2D RPG in perspective 1 Answer
fluent animation from orthographic to perspective projection 2 Answers