By default, unity determines which object will be rendered first, based on the distance between the object and the camera. Objects in the distance are rendered first, and objects that are rendered will be obscured by the objects that are rendered.
Unity provides some default render queues, such as Background = 1000, which is first rendered, and then Geometry = 2000, which are typically created in the editor in the Geometry render queue.
There is a scene in which there are two sphere, a little farther, a little nearer.
So it is certain that some of the more recent ones will obscure the distance, which is a natural phenomenon. A little more than the first rendering.
But sometimes, what do you do when you need to show a distant object to the upper level of an object that is closer to the point?
As mentioned above, the objects created in the editor are in the Geometry = 2000 layer, and the smaller the render queue, the lower the rendering queue, so as long as you reduce the object of the near point of the rendering queues, let him first render it.
Build the scene, add two Sphere, one near, one far away.
Transfer from Http://blog.csdn.net/huutu http://www.thisisgame.com.cn
First look at the default display
Create a new Material, create a new Shader, and follow the steps below to modify the default Shader.
1, in the Tags module to declare the object's render queue, the default object is Geometry, now want to let near a point of the object to render first, then let the render queue reduced, here set to Geometry-20
Tags {"Rendertype" = "Opaque" "Queue" = "Geometry-20"}
2. Add the Zwrite Off tag under tags{} to tell Unity that we want to control the order in which objects are displayed, without writing to the depth cache of the rendering.
Tags {"Rendertype" = "Opaque" "Queue" = "Geometry-20"}zwrite Off
Just modify these two places.
The following is the full shader code
Shader "Cookbookshaders/chapt6-3/queue" {Properties {_maintex ("Base (RGB)", 2D) = "White" {}}subshader {Tags {"Rendertyp E "=" Opaque "" Queue "=" Geometry-20 "}zwrite offlod 200cgprogram#pragma surface surf lambertsampler2d _maintex;struct Input {float2 Uv_maintex;}; void Surf (Input in, InOut surfaceoutput o) {half4 c = tex2d (_maintex, In.uv_maintex); O. Albedo = C.rgb;o. Alpha = C.A;} ENDCG} FallBack "Diffuse"}
Select the new Shader in the Material, and then drag the material to a point near the Sphere body, you will find the original near a point of the Sphere is a little farther Sphere covered!
Unity provides a number of default render queues.
Background: Background, first rendered, used for sky boxes, etc. Render Queue Value =1000
Geometry: Geometry, default render queue, for most objects, opaque geometry Use this queue, render queue values =2000
Alphatest: Transparency test, the geometry used for alpha testing, the object that renders the alpha test after the geometry is rendered is more efficient, so put it behind the Geometry and render the queue value = 2450
Transparent: Transparent, in the order of the back-to-front, any object that is alpha-mixed, that is, a shader that does not write a depth buffer, should be rendered here, such as glass and particle effects, rendering queue values =3000
Overlay: Overlay for overlay effect, any object used for final rendering should use this queue, such as lens flare. Render Queue Value =4000
Declaring the Zwrite tag tells Unity that we want to rewrite the object's render depth order, we give it a new value for its render queue, so the simple setting zwrite is off.
Sample Project Package Download:
http://pan.baidu.com/s/1cKA0ma
Unity Shaders and Effects Cookbook (6-3) modifying render queue Queues to modify render order