- Home /
Using an overlay camera behind the main camera?
My game is 3D with a rather large city, so the clipping plane is set to 400. I have a 2D texture that surrounds the 3D city to make it appear as if there is more buildings in the distance, but because I want a shorter draw distance, you can never actually see the 2D texture due to the clipping plane's distance.
I attached a secondary camera to only render Depth Only and but the 2D texture on that camera. The problem with that is the second camera renders on top of the 3D buildings now, and if I change the Depth number, it doesn't render anything at all. So my problem is the 2D texture that should be behind the 3D buildings either doesn't exist at all because of the clipping plane, or it renders in front. Anyway to achieve the effect I want? Thank you.
Answer by BastianUrbach · Oct 12, 2018 at 12:26 PM
Use the Depth property of the Camera component to change which camera is drawn first (In your case, the camera that draws the background texture should have the lower value). Set Clear Flags on the camera that's drawn first to Skybox or Solid Color and for the other one (the main camera) to Depth only.
Answer by glennMediaMonks · Oct 12, 2018 at 02:43 PM
Ideally you would not use a second camera. Instead just use 1 camera and do the following: Make sure your background offcourse can be rendered by the first camera with the low draw distance, then let the background be rendered by a shader which will render the BG first (a low render queue like "background " / 1000 ), and make sure it does not write depth. this will make sure your bg is endered first and all your buildings are renderd ontop, meaning the gaps will stay the BG.
Your answer
Follow this Question
Related Questions
Convert from Image plane to World plane. Inverse perspective Mapping 1 Answer
Unity 2D Make An Object Disappear On Click 0 Answers
Switching from a cinematic cycle to the player camera 0 Answers
Problem at uploading apk in playstore 1 Answer
ClientRpc Function not being carried out on all clients in Unity3d c# 0 Answers