Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
8
Question by coryl · Jun 04, 2011 at 10:13 PM · cameracameras

How does Clear Flags on cameras work?

Hi there, I'm new to Unity. I'm working on the Walker Brothers tutorial for creating a 2D mario clone.

I'm a bit confused as to how the Clear Flags field works on a camera. The options are: - Skybox, Solid Color, Depth Only, and Don't Clear

My current scene is just mario, the platform and a few blocks above him.

If I switch to "Skybox", everything is clear and fine, the background cast is a sky. Same thing with "Solid Color".

If I select "Depth Only", objects in the scene begin repeating themselves (for example, walking mario around will leave several frozen copies of him trailing, kind of like a graphics glitch. Is there a term for this?). The same thing happens for "Don't Clear".

Can anyone help explain to me whats going on in laymans terms? I tried reading the manual (http://unity3d.com/support/documentation/Components/class-Camera.html) but I didn't quite get it. Any help in explaining how Clear flags on cameras works is appreciated. Thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kamran-bigdely · Apr 18, 2016 at 06:18 PM 0
Share

I'm a seasoned programmer but still could not understand the Unity $$anonymous$$anual. It's not written properly.

2 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Eric5h5 · Jun 04, 2011 at 10:27 PM

You would only use Depth Only if you have more than one camera. You can use this for layering cameras, where you use Depth Only on the top camera, so the background areas would have the bottom camera show through. Don't Clear is rarely used for anything. http://unity3d.com/support/documentation/Components/class-Camera.html

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image coryl · Jun 04, 2011 at 10:37 PM 0
Share

Hi Eric, thanks for your reply. Can you clarify what a top/bottom camera is? $$anonymous$$y scene indeed has multiple cameras, one for background (clouds, hills), one for foreground (mario, platform, blocks). The background cameras are using culling mask to filter the layers, and are set to Skybox on Clear Flags.

avatar image Eric5h5 · Jun 04, 2011 at 10:41 PM 0
Share

@coryl: a camera that has a higher depth is on top of a camera with a lower depth. In your case you'd want Depth Only for the top camera, and Skybox for the background camera.

avatar image andresp · Feb 22, 2012 at 11:56 AM 0
Share

what is the pratical difference between Depth Only and Don't Clear?

avatar image Eric5h5 · Feb 22, 2012 at 07:20 PM 0
Share

The camera docs explain it: http://unity3d.com/support/documentation/$$anonymous$$anual/Cameras.html (scroll down a ways).

avatar image
26

Answer by a-daniel · Jan 20, 2018 at 01:21 AM

@coryl

A camera in Unity holds info about the displayed object's colors and depths. In this case, depth info means the game world distance from the displayed object to the camera.

When a camera renders an image it can get rid of all or just some of the old image information and then displays the new image on top of what's left. Depending on what clear flags you select, the camera gets rid of different info.


  • The skybox clear flag means that when the camera renders a new frame, it clears everything from the old frame and it displays the new image on top of a skybox.

  • The solid color clear flag means that when the camera renders a new frame, it clears everything from the old frame and it displays the new image on top of a solid color.

  • The depth only clear flag means that when the camera renders a new frame, it clears only the depth information from the old frame and it keeps the color information on top of which displays the new frame. This means that the old frame can still show but it doesn't have depth information, meaning the new objects to be displayed can't be shown as intersected or obstructed by the old objects, because there's no information about how far the old objects are(depth info was cleared). So the new objects will be on top of the old ones, mandatory.


This has useful implications for example in FPS games, where you want to avoid, when getting very close to a wall, the gun going through the wall. This can be avoided by having two cameras , one displaying on top of the other(camera order selected by using Depth parameter; the bigger Depth camera displays on top of the other). The first camera should display only the environment(and use skybox or solid color clear flag) and the second camera should display only the gun(and use depth only clear flag) (obs. selective display of game objects is done by using the culling mask ). Because the gun camera clears the depth info of the image shown by the environment camera, the gun image will be shown in full, on top of the environment image, regardless if the gun intersects with the environment in the game world.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image anycolourulike · Nov 13, 2019 at 06:03 PM 0
Share

That's a really great summary & answer, thanks

avatar image DeepDeepWoe · Oct 05, 2021 at 03:05 AM 0
Share

Would you please explain the Don't Clear flag? Like what are the rules of intersection or obstruction when a new frame is rendered on the previous frame

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how can i moving from camera to other using a code? 1 Answer

How can I switch between two cameras ? 1 Answer

How to switch back a camera after an interval using a Trigger 0 Answers

Mouse position in camera view area 1 Answer

How to make camera position relative to a specific target. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges