Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by yoyo · Jul 27, 2012 at 09:55 PM · cameraflashdepth

Does Flash Export support "Depth Only" camera clear?

We have a multi-layered Unity scene that uses several different cameras -- a 2D background GUI layer, a 3D viewport containing a model, and then a viewport overlay containing labels with 3D lines pointing into the 3D model.

The background layer uses a camera that does a solid colour clear, then the viewport cameras each use CameraClearFlags.Depth, to clear and reuse the depth buffer.

This works great in the Editor, but when we export to Flash it seems that camera depth clear is not supported -- it appears to do a solid colour clear. The result is that when we turn on the labels, the 3D model disappears and is covered up by the background colour of the label camera.

I can think of some possible workarounds, but first of all, should CameraClearFlags.Depth work in Flash?

EDIT: I created a simple test case for this and it does not show the problem. Continuing to investigate, will update this question if I learn anything new.

Comment
Add comment
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

2 Replies

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

Answer by yoyo · Jul 31, 2012 at 03:31 AM

After some investigation with a simple test scene, it seems CameraClearFlags.Depth does work in Flash -- but only if the viewport of the camera fills the entire screen. If the viewport fills a portion of the screen then setting depth-only clear will clear the camera to the background colour (wiping out everything rendered to that region by previously rendered cameras).

This is in Unity 3.5.2. I haven't tested other versions. I filed a bug report.

EDIT: Until this bug is fixed, here's a workaround ...

Add the following shader to your project. It will set the depth buffer without touching the colour of any pixels. Create a material using this shader and attach it to a plane behind all the geometry viewed by your overlay camera. This plane will be drawn first, filling the depth buffer and allowing the contents of the overlay camera to be drawn with a "fresh" depth buffer.

 Shader "Custom/DepthClear"
 {
     SubShader
     {
         Tags {"Queue"="Background-1"}
 
         Pass
         {
             ZWrite On
             ZTest Always
             AlphaTest Off
             Cull Off
             Blend Zero One
             ColorMask 0
         }
     } 
     FallBack "Diffuse"
 }
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 Bunny83 · Jul 31, 2012 at 12:06 PM 0
Share

@yoyo: thanks for your feedback. If you can remember the bugreport id, you could post it here just for reference ;)

avatar image yoyo · Jul 31, 2012 at 04:14 PM 1
Share

link added

avatar image Bunny83 · Jul 31, 2012 at 09:51 PM 0
Share

I took the liberty and mark your answer ;)

(it's funny, when you mark your own answer you don't get karma, but when i mark yours you get karma ;) )

avatar image yoyo · Jul 31, 2012 at 09:56 PM 0
Share

Heh, thanks. I just found a workaround, which I've added to the answer.

avatar image
0

Answer by Bunny83 · Jul 27, 2012 at 10:29 PM

I don't see a good reason why it shouldn't work. Are you sure you have the correct camera-depth (order) setup?

If it really doesn't work, i would call it a bug.

Comment
Add comment · Show 1 · 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 yoyo · Jul 27, 2012 at 10:51 PM 0
Share

The depth stacking order seems correct in the inspector and works properly in the editor. Only in the Flash build is there a problem. Guess I should file a bug?

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

6 People are following this question.

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

Related Questions

Culling Mask with Depth Occlusion 1 Answer

Camera --> get Depth as Texture (Best Gray) 2 Answers

How to make a FLASH 4 Answers

Camera --> get Depth as Texture (Best Gray) 1 Answer

Fog/color tint shader for orthographic camera 0 Answers


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