|
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.
(comments are locked)
|
|
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. @yoyo: thanks for your feedback. If you can remember the bugreport id, you could post it here just for reference ;)
Jul 31 '12 at 12:06 PM
Bunny83
link added
Jul 31 '12 at 04:14 PM
yoyo
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 ;) )
Jul 31 '12 at 09:51 PM
Bunny83
Heh, thanks. I just found a workaround, which I've added to the answer.
Jul 31 '12 at 09:56 PM
yoyo
(comments are locked)
|
|
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. 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?
Jul 27 '12 at 10:51 PM
yoyo
(comments are locked)
|
