使用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 Shader "ztc_Blend"
2 {
3 Properties
4 {
5 _Color ("Main Color",Color) = (1,1,1,0.5)
6 _MainTex ("FrontTex (RGB)", 2D) = "white" {}
7 _BackTex ("BackTex (RGB)", 2D) = "white" {}
8 }
9 SubShader
10 {
11 Pass
12 {
13 Material
14 {
15 Diffuse[_Color]
16 }
17 Lighting On
18
19 SetTexture [_MainTex] //the default Texture
20 {
21 Combine texture
22 }
23 SetTexture [_BackTex] //use the combine lerp to mix two texture by the Main color's Alpha
24 {
25 constantColor [_Color]
26 Combine previous lerp(constant) texture
27 }
28
29 }
30 }
31 FallBack "Diffuse"
32 }
結果: