通道使用标签来告知它们期望何时以何种方式被渲染到渲染引擎。
Tags { "TagName1" = "Value1" "TagName2" = "Value2" }
指定 TagName1 具有 Value1,TagName2 具有 Value2。可根据需要添加任意数量的标签。
从根本上说,标签就是键/值对。在通道中,标签用于控制此通道在光照管线(环境光、顶点光照、像素光照等等)中具有哪个角色以及某些其他选项。请注意,以下由 Unity 识别的标签_必须_位于 Pass 部分中,不能在 SubShader 中!
LightMode 标签定义通道在光照管线中的角色。请参阅渲染管线以了解详细信息。很少手动使用这些标签;大部分情况下,需要与光照进行交互的着色器都先编写为表面着色器,然后再处理这些细节。
LightMode 标签的可能值:
一个通道可指示一些标志来更改渲染管线向通道传递数据的方式。这可通过使用 PassFlags 标签来实现,该标签的值为空格分隔的标志名称。目前支持以下标志:
一个通道可指示仅当满足某些外部条件时才渲染该通道。这可通过使用 RequireOptions 标签来实现,该标签的值为空格分隔的选项字符串。目前,Unity 支持以下选项:
也可为子着色器提供标签,请参阅子着色器标签。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.