Category:是渲染命令的逻辑组,着色器可以多个子着色器,他们需要共同的效果

// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License. // Original code by Nora
// http://stereoarts.jp
//
// Retrieved from:
// https://developer.oculusvr.com/forums/viewtopic.php?f=37&t=844#p28982 Shader "Panorama/2dSphere" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
}
Category {
Tags { "Queue"="Background" }
ZWrite Off
Lighting Off
Fog {Mode Off}
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
cull off
Pass {
SetTexture [_MainTex] {
Combine texture
}
SetTexture [_MainTex] {
constantColor [_Color]
combine previous * constant
}
}
}
}
}

ShaderLab 语法:绑定通道 (BindChannels)        

绑定通道 (BindChannels) 命令让您可以指定顶点数据如何绘制到图形硬件中。

使用可编程的顶点着色器时,绑定通道无效,因为这种情况下,捆绑由顶点着色器输入控制



默认情况下,Unity 为您进行绑定,但是在有些情况下,您需要自定义使用的绑定。

例如:您可以绘制在第一个纹理阶段使用的主要 UV 集和第二个纹理阶段使用的辅助 UV 集

;或者通知硬件要考虑顶点颜色。

语法

BindChannels { Bind "source", target }

指定顶点数据源 (source) 映射到硬件目标 (target)。

源 (Source)  可以是:

顶点 (Vertex):顶点位置

法线 (Normal):顶点法线

切线 (Tangent):顶点切线

纹理坐标 (Texcoord):主要 UV 坐标

纹理坐标 1 (Texcoord1):次要 UV 坐标

颜色 (Color):逐顶点颜色

目标 (Target) 可以是:

顶点 (Vertex):顶点位置

法线 (Normal:顶点法线

切线 (Tangent):顶点切线

Texcoord0, Texcoord1, ...:相应纹理阶段的纹理坐标

纹理坐标 (Texcoord):所有纹理阶段的纹理坐标

颜色 (Color):顶点颜色

详细信息

Unity 在哪些源可绘制到哪些目标上有一些限制。源和目标在 顶点 (Vertex)、法线 

(Normal)、切线 (Tangent) 和 颜色 (Color) 上必须是相匹配的。网格的纹理坐标

(Texcoord 和 Texcoord1)可绘制到纹理坐标目标(对于所有的纹理阶段为 Texcoord 或者

对于特定阶段为 TexcoordN)。

BindChannels 的两个经典使用案例:

考虑顶点颜色的着色器。

使用两个 UV 集的着色器。

示例

// 将第一个 UV 集绘制到第一个纹理阶段// 并将第二个 UV 集绘制到第二个纹理阶段

BindChannels {   Bind "Vertex", vertex   Bind "texcoord", texcoord0   Bind 

"texcoord1", texcoord1} 

// 将第一个 UV 集绘制到所有纹理阶段// 并使用顶点颜色BindChannels {   Bind 

"Vertex", vertex   Bind "texcoord", texcoord   Bind "Color", color}

shader Category的更多相关文章

  1. Unity3d Shader开发(五)Fallback ,Category

    Fallback定义在所有子着色器后.简单来说,它表示"如果没有任何子着色器能被运行在当前硬件上,请尝试使用降级着色器". Syntax 语法 Fallback "nam ...

  2. Shader

    Shader的学习方法总结 http://www.cnblogs.com/Esfog/p/How_To_Learn_Shader.html [Shader 着色器]学习shader之前必须知道的东西之 ...

  3. Unity3D着色器Shader编程入门(一)

    自学Unity3D也有大半年了,对Shader一直不敢入坑,最近看了些资料,以及通过自己的实践,对Shader还是有一点了解了,分享下仅作入门参考. 因Shader是对图像图像渲染的,学习前可以去了解 ...

  4. Shader的语法

    Shader "name" { [Properties] Subshaders [Fallback] }(1)Properties:{ Property [Property ... ...

  5. Unity3D中的Shader

    简单的说,Shader是为渲染管线中的特定处理阶段提供算法的一段代码.Shader是伴随着可编程渲染管线出现的,从而可以对渲染过程加以控制. 1. Unity提供了很多内建的Shader,这些可以从官 ...

  6. Unity shader之ColorMask

    Color Mask解释,见unity文档: ColorMask ColorMask RGB | A | 0 | any combination of R, G, B, A Set color cha ...

  7. (转)热空气扭曲效果shader

    转自:http://blog.sina.com.cn/s/blog_89d90b7c0102vaqy.html 热空气扭曲在大自然中形成是比较复杂的,这里只是通过取屏幕纹理和移动UV来模拟热扭曲效果. ...

  8. 关于Unity中Shader的基础认识

    Shader也叫着色器,是Unity里面比较难的一个点,网上有很多别人写好的shader,我们可以下载下来用或者修改学习. Shader可以做出很多非常不错的效果,因为它是插在渲染管道里面的程序,一来 ...

  9. Glow Shader

    [Glow Shader] Glow Shader基于BlurShader来实现.总的来说分为2步: 1.利用BlurShader渲染出BlurTexture. 2.将BlurTexture与SrcT ...

随机推荐

  1. angularJs 购物车模型

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel= ...

  2. css三角形实现的几种方法的区别

    演变: .triangle{ height: 30px; width: 30px; display: inline-block; border: 30px solid; border-color: # ...

  3. CentOS7 默认防火墙firewalld

    firewalld基础 firewalld是CentOS7源生支持的防火墙,firewalld最大的好处有两个:支持动态更新,不用重启服务:第二个就是加入了防火墙的“zone”概念. firewall ...

  4. Wireshark 的使用 —— 过滤器(filter)

    1. 基本 ip 地址: 目的IP:ip.dst==192.168.101.8,源ip:ip.src==1.1.1.1 不区分源和目的:ip.addr == 192.168.101.8: 端口过滤: ...

  5. Mac替换sublime图标

    下载.icns格式一个图标:http://www.easyicon.net/language.en/iconsearch/sublime/ 终端执行:open /Applications/Sublim ...

  6. 1080 Graduate Admission (30)(30 分)

    It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...

  7. 「NOIP2016」「P1850」 换教室(期望dp

    题目描述 对于刚上大学的牛牛来说,他面临的第一个问题是如何根据实际情况申请合适的课程. 在可以选择的课程中,有 2n2n 节课程安排在 nn 个时间段上.在第 ii(1 \leq i \leq n1≤ ...

  8. 「LOJ#10045」「一本通 2.2 练习 1」Radio Transmission (KMP

    题目描述 原题来自:BalticOI 2009 给你一个字符串,它是由某个字符串不断自我连接形成的.但是这个字符串是不确定的,现在只想知道它的最短长度是多少. 输入格式 第一行给出字符串的长度 L,第 ...

  9. ACM学习历程—HDU 1059 Dividing(dp && 多重背包)

    Description Marsha and Bill own a collection of marbles. They want to split the collection among the ...

  10. ACM学习历程——hihoCoder挑战赛10A 01串(策略)

    时间限制:7000ms 单点时限:1000ms 内存限制:256MB 描述 给定两个整数n和m,求是否存在恰好包含n个0和m个1的01串S,使得S中不存在子串"001"和" ...