查看: 2565|回复: 0
打印 上一主题 下一主题

[Unity 组件参考手册]着色器参考之着色器语法:SubShader

[复制链接]
.    

3797

主题

11

听众

5万

积分

首席设计师

Rank: 8Rank: 8

纳金币
32328
精华
41

活跃会员 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-2-24 09:54:04 |只看该作者 |倒序浏览
Each shader in Unity consists of a list of subshaders. When Unity has to display a mesh, it will find the shader to use, and pick the first subshader that***ns on the user's graphics card.
Unity中的每一个着色器都包含一个subshader的列表,当Unity需要显示一个网格时,它能发现使用的着色器,并提取第一个能运行在当前用户的显示卡上的子着色器。

Syntax 语法
Subshader { [Tags] [CommonState] Passdef [Passdef ...] }

    Defines the subshader as optional tags, common state and a list of pass definitions.

    通过可选标签,通用状态 和 一个Pass 定义的列表构成了子着色器。
Details 细节
A subshader defines a list of rendering passes and optionally setup any state that is common to all passes. Additionally, subshader specific Tags can be set up.
子着色器定义了一个渲染通道的列表,并可选是否为所有通道初始化所需要的通用状态。
When Unity chooses which subshader to render with, it renders an object once for each Pass defined (and possibly more due to light interactions). As each render of the object is an expensive operation, you want to define the shader in minimum amount of passes possible. Of course, sometimes on some graphics hardware the needed effect can't be done in a single pass; then you have no choice but to use multiple passes.
当Unity选择用于渲染的子着色器时,它为每一个被定义的通道渲染一次对象(可能会更多,这取决于光线的交互作用)。当对象的每一次渲染都是一次昂贵的操作时,你能选择使用最小数目的通道来定义着色器。当然,有时在一些显示硬件上需要的效果不能通过单次通道来完成。除了使用多次通道你别无选择。
Each pass definition can be a regular Pass, a Use Pass or a Grab Pass.
通道定义的类型包括a regular Pass, a Use Pass or a Grab Pass。
Any statements that are allowed in a Pass definition can also appear in Subshader block. This will make all passes use this "shared" state.
任何出现在通道定义的状态同时也能整个子着色器块中可见。这将使得所有通道共享状态。

Example
// ...

SubShader {

    Pass {

        Lighting Off

        SetTexture [_MainTex] {}

    }

}

// ...
This subshader defines a single Pass that turns off any lighting and just displays a mesh with texture named _MainTex.
这个着色器定义了一个单一的通道用来关闭任何光照,并只使用一个名叫_MainTex的纹理来显示网格。


【来源:互联网】

更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-22 15:48 , Processed in 0.132648 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部