Unity3D ShaderLab 混合两张贴图(Blend)
2012-01-12 15:47
1486 查看
使用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来做为混合的界定.
View Code
结果:
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编程】之五 圣诞夜篇: Unity中Shader的三种形态对比&混合操作合辑
- Unity3D ShaderLab<二>Shader属性
- Unity3D ShaderLab Half Lambert光照模型
- Unity3D Shaderlab 学习记录
- 【浅墨Unity3D Shader编程】之三 光之城堡篇:子着色器、通道与标签的写法 & 纹理混合
- Unity3d Shader (Cube两张材质逐渐转换
- Unity3D ShaderLab 自定义光照模型
- ShaderLab Tutorials-Blend,Grey Lightmap
- unity shaderlab Blend操作
- unity3D ShaderLab <四>漫反射光照改善技巧
- Unity3d shaderlab 实现多个贴图混合叠加与裁剪
- unity shaderlab Blend操作
- Shaderlab blend
- Unity3D的坑系列:打包Assetbundle丢失Shader问题(贴图显示不了)
- 【浅墨Unity3D Shader编程】之三 光之城堡篇:子着色器、通道与标签的写法 & 纹理混合
- 【浅墨Unity3D Shader编程】之五 圣诞夜篇: Unity中Shader的三种形态对比&混合操作合辑
- 【浅墨Unity3D Shader编程】之五 圣诞夜篇: Unity中Shader的三种形态对比&混合操作合辑