Unity3D ShaderLab 混合两张贴图(Blend)
2013-03-18 17:29
411 查看
使用Unity3D 中的 ShaderLab 实现两张不同贴图之前的混合 类似于3dsMAX 中的Blend材质.
1.在Properties 中定义三个变量.我们需要使用的..1. _Color 主要是用它的 Alpha 来进行两张图的混合 ,2.两张需要进行操作的贴图
2.在混合时主要是使用 SetTexture 中的 Combine scr1 lerp(constant) src2. 这里要注意.在一个SetTextrue 中我们只能对一个texture来操作. 所以在混合前我们需要先用一个SetTexture 将第一张图贴上去.
然后再用 Combine previous lerp(constant) texture .将第二张与之前的(previous)来混合,lerp(constant) 就是以_Color的Alpha来做为混合的界定.
1.在Properties 中定义三个变量.我们需要使用的..1. _Color 主要是用它的 Alpha 来进行两张图的混合 ,2.两张需要进行操作的贴图
2.在混合时主要是使用 SetTexture 中的 Combine scr1 lerp(constant) src2. 这里要注意.在一个SetTextrue 中我们只能对一个texture来操作. 所以在混合前我们需要先用一个SetTexture 将第一张图贴上去.
然后再用 Combine previous lerp(constant) texture .将第二张与之前的(previous)来混合,lerp(constant) 就是以_Color的Alpha来做为混合的界定.
View Code Shader "ztc_Blend" { Properties { _Color ("Main Color",Color) = (1,1,1,0.5) _MainTex ("FrontTex (RGB)", 2D) = "white" {} _BackTex ("BackTex (RGB)", 2D) = "white" {} } SubShader { Pass { Material { Diffuse[_Color] } Lighting On SetTexture [_MainTex] //the default Texture { Combine texture } SetTexture [_BackTex] //use the combine lerp to mix two texture by the Main color's Alpha { constantColor [_Color] Combine previous lerp(constant) texture } } } FallBack "Diffuse" }
相关文章推荐
- Unity3D ShaderLab 混合两张贴图(Blend)
- Unity3D ShaderLab压缩混合纹理贴图
- Unity3D - Shader - ShaderLab的混合命令
- 详解Unity3D Shader之Shader Lab框架
- [Unity3D]Shader编程之贴图切换
- unity shader学习笔记(十一)——Unity中的透明效果之ShaderLab中的混合命令
- Unity3D中的shader,视角,和贴图范围offset
- untiy3d 混合贴图shader
- Unity3d开发(一)ShaderLab 入门 语法格式
- Unity3D ShaderLab Use Properties
- ShaderLab Tutorials-Additive Vert Color Blend
- [Unity3D]Shader学习笔记之ShaderLab基础
- 【浅墨Unity3D Shader编程】之三 光之城堡篇:子着色器、通道与标签的写法 & 纹理混合
- Unity3d之Shader编程:子着色器、通道与标签的写法 & 纹理混合
- Unity3d Shader(三) Pass(Texturing)混合纹理(同时显示2张图),自发光
- Unity3D Shader官方教程翻译(二)(ShaderLab)
- Unity3D - Shader - 透明度混合
- Unity3D ShaderLab<二>Shader属性
- Unity 之 Shader Blend 混合操作 - 八
- Unity3D Shader官方教程翻译(十一)----Shader语法:Pass的Blending(混合)