作者使用Untiy介绍了许多使用深度缓存来实现的特效,能够帮助建立3D深度缓存的概念SPECIAL EFFECISSIGGRAPH2011KunitWhat are special effects?hy are some effects they"special?How to enable them in UnityNOk, so here we see a lightmapped scene(running deferred), so let's just define"special effects", for the purpose of this talk, as the result of this image图subtracted from this image. this results inthis. As you can see, we're mostly adding things to the color buffer, so let's just say for now that doing special effects is adding stuff to the color buffer at some later point inrenderingT○○LS○ F TRADEDepending on what you needseveral options in Unity to add stuff to the screen(Multi-pass) shadersSurface shaders or oldschool CG vertex/pixelarticle systemsCamera. OnRenderlmage(Camera○ nPostrender0Graphics. DrawMesh(), DrawMesh NOwOalso, Mono Behaviour. OnWillRenderObjecto for visibility determinationThere are several ways to create effects in unity, all depending on the kind of effect you want to getscreen. Furthermore, DrawMesh Now()and DrawMesh( are very useful for drawing selected objects a second time(when shader passes won't be enough), also stuff to theYour tools of trade in Unity for making effects are the following: the multi-pass shader system, along with the on Renderlmage and onPostRender functions to adeOnWill renderobject is good to find out if an object is seen by a camera or notAB○UTB∪ FFERSSIGGRAPH2011KunitLet's talk about various buffers that are available in Unity, which are either part of the rendering or can be easily createdDEPTHDEPTHDistance from the cameran[O,门rangeNonlinear distributionPrecision: 24 or 6 bitsHow to get it?° Just ask for itcamera. depth lextureMode- Depth lextureMode Depthit's just there when running deferredThe depth buffer is storing the distance from camera's near clip plane The values are in the [0; 1]range with nonlinear distribution. The precision is usually 24 or 16 bitsHow do you get it? Just ask for it by setting camera. depth Texture Mode to Depth then the depth buffer will be available as Camera TextureUnity is hiding the burden of getting the depth buffer from you. We are binding the buffer when possible or rendering the scene with a replacement shader when it's not