Unity之Shader Pass 通道显示贴图的几种方法- 六
2015-04-09 15:17
639 查看
Pass 通道显示贴图的几种方法
下面是几种显示模型贴图的方法,在此使用的是固定管线方法
方法一
方法二
方法三
实际使用效果如下
第一种方法
世界中可以没有光
第二种方法
世界中必须要有光,否则太暗
第三种方法
世界中可以没有光
上面三种均可显示,效果上不完全相同,由于用到的功能有限,所以功能有限,更过功能接下来的博客会一一赘述
下面是几种显示模型贴图的方法,在此使用的是固定管线方法
方法一
Shader "Custom/PassOne" { Properties { //定义一个贴图 _MainTex ("Base (RGB)", 2D) = "white" {} //定义一个颜色 _Color ("Main Color", Color) = (1, 1, 1, 1) _SpecColor ("Spec Color", Color) = (1, 1, 1, 1) _Emission ("Emission Color", Color) = (1, 1, 1, 1) _Shiness ("Shiness", Range(0, 1)) = 0.5 } SubShader { Tags {"RenderType" = "Opaque" "IGNOREPROJECTOR" = "TRUE" "QUEUE" = "Transparent"} LOD 200 Pass { //在此使用 Material 下面几个方法可以结合实际情况选择使用, //如果一个都不使用那么模型将显示为黑色,没有任何光 Material { Diffuse [_Color] //漫反射颜色 Ambient [_Color] // 环境光 Shininess [_Shiness] // 曲面反射 Emission [_Emission] // 自发光 Specular [_SpecColor] //镜面反射 } Lighting On //给材质设置 贴图 SetTexture [_MainTex] { Combine texture * primary double } } } FallBack "Diffuse" }
方法二
Shader "Custom/PassTwo" { Properties { //定义一个贴图 _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags {"RenderType" = "Opaque" "IGNOREPROJECTOR" = "TRUE" "QUEUE" = "Transparent"} LOD 200 Pass { //使用顶点色代替 Material 中的漫反射和环境光 //在此必须使用该方法,否则模型会变成黑色,即没有任何光 ColorMaterial AmbientAndDiffuse Lighting On //给材质设置 贴图 SetTexture [_MainTex] { Combine texture * primary double } } } FallBack "Diffuse" }
方法三
Shader "Custom/PassThree" { Properties { //定义一个贴图 _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags {"RenderType" = "Opaque" "IGNOREPROJECTOR" = "TRUE" "QUEUE" = "Transparent"} LOD 200 Pass { // 通过绑定固定通道来使用定点色 BindChannels { Bind "Vertex", vertex // 绑定定点 Bind "Normal", normal Bind "Color", color Bind "Texcoord", texcoord0 Bind "Texcoord", texcoord1 } //此处 不能设置为 Lighting On, 否则模型贴图显示不出来 //Lighting Off //给材质设置 贴图 SetTexture [_MainTex] { Combine texture * primary double } } } FallBack "Diffuse" }
实际使用效果如下
第一种方法
世界中可以没有光
第二种方法
世界中必须要有光,否则太暗
第三种方法
世界中可以没有光
上面三种均可显示,效果上不完全相同,由于用到的功能有限,所以功能有限,更过功能接下来的博客会一一赘述
相关文章推荐
- 【Unity实用小方法】判断shader使用贴图数
- Unity工程里图片的RGB和Alpha通道的分离,以及显示所有带有Alpha通道贴图的Material
- Unity之Shader过滤掉不带Alpha通道贴图的背景颜色 - 四
- 【Unity Shader】手游中高光效果的几种实现方法
- UnityShader:选择Pass渲染通道
- WinCE显示资源中BMP图片的几种方法
- DataGridView显示行号的几种方法
- VC下显示位图的几种方法
- 禁用IE的后退按钮|显示网页已过期|几种语言的实现方法|c#|javascript|html
- JSP页显示当前几种格式的日期方法!
- [转]3D图形渲染通道负载优化的几种方法
- Flex中Image加载图片出错时显示默认图片的几种方法
- aspx页面显示消息对话框几种方法
- DataGridView显示行号的几种方法
- [转]DataGridView显示行号的几种方法
- 3D图形渲染通道负载优化的几种方法
- VC下显示位图的几种方法
- VC下显示位图的几种方法
- 几种显示数据的方法的比较
- 几种常见的字符串长度截取显示方法