做个记录
SetShaderPassEnabled 这个函数作用与名称相当不符。。。
材质球调用开关LightMode的tag可以达到开关当前pass的作用,尤其是在需要多个pass都渲染的情况!
shader中的需要有LightMode的tag
Tags{ "LightMode" = "ForwardBase" }
c#代码调用
material.SetShaderPassEnabled("ForwardBase", false);
下面是官方文档中SetShaderPassEnabled 函数说明
Enables or disables a Shader pass on a per-Material level.
By default, all Shader passes are enabled. This function allows a Material to treat a specific Shader pass (as indicated by LightMode pass tag) as if it does not exist in the Shader. For example, if the Shader has a "refraction" pass but you only want to enable it on Materials that have a refraction Texture assigned, pass "refraction" as passName
and false for enabled
for Materials without a refraction Texture assigned.
下面是官方文档中LightMode tag
LightMode tag
LightMode tag defines Pass’ role in the lighting pipeline. See render pipeline for details. These tags are rarely used manually; most often shaders
that need to interact with lighting are written as Surface Shaders
and then all those details are taken care of.
Possible values for LightMode tag are:
- Always: Always rendered; no lighting is applied.
- ForwardBase: Used in Forward rendering
, ambient, main directional light, vertex/SH lights and lightmaps
are applied. - ForwardAdd: Used in Forward rendering; additive per-pixel lights are applied, one pass per light.
- Deferred: Used in Deferred Shading
; renders g-buffer. - ShadowCaster: Renders object depth into the shadowmap or a depth texture.
- MotionVectors: Used to calculate per-object motion vectors.
- PrepassBase: Used in legacy Deferred Lighting, renders normals and specular exponent.
- PrepassFinal: Used in legacy Deferred Lighting, renders final color by combining textures, lighting and emission.
- Vertex: Used in legacy Vertex Lit rendering when object is not lightmapped; all vertex lights are applied.
- VertexLMRGBM: Used in legacy Vertex Lit rendering when object is lightmapped; on platforms where lightmap is RGBM encoded (PC & console).
- VertexLM: Used in legacy Vertex Lit rendering when object is lightmapped; on platforms where lightmap is double-LDR encoded (mobile platforms).