Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of "Don't Clear" in "Clear Flags" property of Camera

Tags:

unity3d

shader

In Unity's Camera component, there is a property Clear Flags which allows to choose from four options: Skybox, Solid Color, Depth Only and Don't Clear.

As documentation says:

Don’t clear

This mode does not clear either the color or the depth buffer. The result is that each frame is drawn over the next, resulting in a smear-looking effect. This isn’t typically used in games, and would more likely be used with a custom shader.

Note that on some GPUs (mostly mobile GPUs), not clearing the screen might result in the contents of it being undefined in the next frame. On some systems, the screen may contain the previous frame image, a solid black screen, or random colored pixels.


"This isn't typically used in games and would more likely be used with a custom shader"

So my question is :

How to use it in a custom shader and What effects can be achieved by using it?

Has anyone ever used it or has a good explanation about the basic concept.

Thanks

like image 872
Umair M Avatar asked Jul 22 '16 17:07

Umair M


People also ask

What is clear flag?

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.

What is camera depth in unity?

Description. Camera's depth in the camera rendering order. Cameras with lower depth are rendered before cameras with higher depth. Use this to control the order in which cameras are drawn if you have multiple cameras and some of them don't cover the full screen.


2 Answers

An idea would be those enemy encounter effects in Final Fantasy games. Look at the top edge of this gif to see the smearing effects of previous frames. This is probably combined with blur/rotation.

gif

like image 85
5argon Avatar answered Oct 04 '22 15:10

5argon


Thread question is a bit old, however I had this problem and solved it.

I've made a Screen Image Effect that reproduces this effect, you can see it here:

https://github.com/falconmick/ClearFlagsMobile

Hope this helps!

like image 44
Michael Crook Avatar answered Oct 04 '22 14:10

Michael Crook