I want to write a multiPass shader.And I want to use Shader.EnableKeyword or Shader.DisableKeyword to control What pass I will use. How can i achieving it?
Depends on what you're trying to do. If you're rendering a mesh manually using GL, Graphics, or CommandBuffers you can use SetPass or the command buffer draw commands let you set a pass. https://docs.unity3d.com/ScriptReference/Material.SetPass.html https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.DrawMesh.html I don't think SetPass does anything for an object placed in the scene, but it might. I believe internally Unity is already doing these kinds of SetPass commands for rendering objects so it might blow away your setting, but it's worth a try.
Very thanks for your answer.But maybe you don't understand my mind.I write a shader.The shader contain 2 Pass.Sometines I want to use Pass 1 and 2 render,but sometimes I want to only use Pass 1 to render.How to switch the two situations?
you can only wait for Unity 5.6 if your second pass is not coupled with the first pass(something like selection outline), CommandBuffer.DrawRenderer is the way to go. for example you can use command buffer to add layered effect to a skinned mesh.