Game Development Reference
In-Depth Information
Instead, it'd be better to separate the paint effects onto a separate texture with a
transparent background, which is layered over the destination texture via a custom
material. This creates a true separation between the destination texture and the
paint effects, even though in appearance, it appears as one consolidated texture.
To achieve this effect, a custom shader must be written, as shown in the following
code sample 9-4. This shader blends a top texture (with alpha transparency) on top
of a background texture:
01 Shader "TextureBlender"
02 {
03 Properties
04 {
05 _Color ("Main Color", Color) = (1,1,1,1)
06 _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
07 _BlendTex ("Blend (RGB)", 2D) = "white"
08 }
09
10 SubShader
11 {
12 Tags { "Queue"="Geometry-9" "IgnoreProjector"="True"
"RenderType"="Transparent" }
13 Lighting Off
14 LOD 200
15 Blend SrcAlpha OneMinusSrcAlpha
16
17 CGPROGRAM
18 #pragma surface surf Lambert
19 uniform fixed4 _Color;
20 uniform sampler2D _MainTex;
21 uniform sampler2D _BlendTex;
22
23 struct Input
24 {
25 float2 uv_MainTex;
26 };
27
28 void surf (Input IN, inout SurfaceOutput o)
29 {
30 fixed4 c1 = tex2D( _MainTex, IN.uv_MainTex );
31 fixed4 c2 = tex2D( _BlendTex, IN.uv_MainTex );
32
 
Search WWH ::




Custom Search