TerrainFourLayerToon

From Unify Community Wiki
Jump to: navigation, search


A mesh terrain shader, based on the TerrainFourLayer2Pass shader, but with support for a toon ramp for shading. This shader originated as the winner of a small contest held on the Unity forums; the original thread of which can be found here. The winning coder was Pvloon.

Great for games trying to achieve a stylized or cartoony art style that would prefer to not use Unity's built-in terrains, in favor of a mesh terrain or similar.

Comes in four variants:

  • Compact - Uses two passes for compatibility with older cards. Use this if you're unsure about your target platform's specs.
  • Compact Optional - Same as above, but it also contains two new(ish) features: a fallback texture for really old cards, and a light cutoff setting.
  • Modern - A version of the shader that runs approximately 50% faster, but uses acceleration functions found only on somewhat more modern cards. Experiment with your target platform to ensure it works before using this.
  • Modern Optional - Same as above, but contains the extra options found in the Compact Optional variant.

As previously stated, use the Compact version if you're not sure what's compatible with your target specs.


Contents

Compact Variant

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


// Credit for all code goes to Arthur B. (Pvloon)
// Released to the Unify Community Wiki as part of a contest, for free or commercial use;
// HOWEVER, THIS NOTICE MUST BE RETAINED IF ANY OF THE FOLLOWING CODE IS USED.

// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'

Shader "Terrain/Four Layer Toon Compat" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Color 1 (RGB)", 2D) = "white" {}
		_MainTex2 ("Color 2 (RGB)", 2D) = "white" {}
		_MainTex3 ("Color 3 (RGB)", 2D) = "white" {}
		_MainTex4 ("Color 4 (RGB)", 2D) = "white" {}
		_Mask ("Mixing Mask (RGBA)", 2D) = "gray" {}
		_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 
	}

	Category {
		Lighting On
		Cull Back
		Fog { Color [_AddFog] }
		Subshader 
		{
			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;

			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;



				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}

			sampler2D _MainTex;
			sampler2D _MainTex2;

			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;
				float2 uv_MainTex;
				float2 uv_MainTex2;

				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};


			void surf (Input IN, inout SurfaceOutput o) {
			
				// get the first three layer colors
				half4 color1 = tex2D( _MainTex, IN.uv_MainTex);
				half4 color2 = tex2D( _MainTex2, IN.uv_MainTex2);


				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);
				// mix the three layers
				
				half4 color = color1 * mask.r + color2 * mask.g;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 

			Blend one one

			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;
			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;

				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}


			sampler2D _MainTex3;
			sampler2D _MainTex4;
			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;

				float2 uv_MainTex3;
				float2 uv_MainTex4;
				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};



			void surf (Input IN, inout SurfaceOutput o) {
			
				// get the first three layer colors

				half4 color3 = tex2D( _MainTex3, IN.uv_MainTex3);
				half4 color4 = tex2D( _MainTex4, IN.uv_MainTex4);

				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);


				// mix the three layers
				half4 color = color3 * mask.b + color4 * mask.a;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 
		}
	}

    // ------------------------------------------------------------------
    // Radeon 7000 / 9000
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            } 
            Lighting On
            SetTexture [_MainTexture] {
                Combine texture * primary DOUBLE, texture * primary
            }
        }
    }
}


Compact Optional Variant

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


// Credit for all code goes to Arthur B. (Pvloon)
// Released to the Unify Community Wiki as part of a contest, for free or commercial use;
// HOWEVER, THIS NOTICE MUST BE RETAINED IF ANY OF THE FOLLOWING CODE IS USED.

// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'

Shader "Terrain/Four Layer Toon Compat Optional" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Color 1 (RGB)", 2D) = "white" {}
		_MainTex2 ("Color 2 (RGB)", 2D) = "white" {}
		_MainTex3 ("Color 3 (RGB)", 2D) = "white" {}
		_MainTex4 ("Color 4 (RGB)", 2D) = "white" {}
		_Mask ("Mixing Mask (RGBA)", 2D) = "gray" {}
		_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 
		_Base ("Base Color (RGB)", 2D) = "white" {}
		_LightCutoff("Light Cutoff", Range(0, 0.5)) = 0.05
	}

	Category {
		Lighting On
		Cull Back
		Fog { Color [_AddFog] }
		Subshader 
		{
			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;
			float _LightCutoff;
			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;

				if (atten > (1.0 - _LightCutoff))
					atten = 1.0;
				else if (atten < _LightCutoff)
					atten = 0;

				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}

			sampler2D _MainTex;
			sampler2D _MainTex2;

			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;
				float2 uv_MainTex;
				float2 uv_MainTex2;

				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};


			void surf (Input IN, inout SurfaceOutput o) {
			
				// get the first three layer colors
				half4 color1 = tex2D( _MainTex, IN.uv_MainTex);
				half4 color2 = tex2D( _MainTex2, IN.uv_MainTex2);


				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);
				// mix the three layers
				
				half4 color = color1 * mask.r + color2 * mask.g;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 

			Blend one one

			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;
			float _LightCutoff;
			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;

				if (atten > (1.0 - _LightCutoff))
					atten = 1.0;
				else if (atten < _LightCutoff)
					atten = 0;

				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}


			sampler2D _MainTex3;
			sampler2D _MainTex4;
			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;

				float2 uv_MainTex3;
				float2 uv_MainTex4;
				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};



			void surf (Input IN, inout SurfaceOutput o) {
			
				// get the first three layer colors

				half4 color3 = tex2D( _MainTex3, IN.uv_MainTex3);
				half4 color4 = tex2D( _MainTex4, IN.uv_MainTex4);

				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);


				// mix the three layers
				half4 color = color3 * mask.b + color4 * mask.a;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 
		}
	}

    // ------------------------------------------------------------------
    // Radeon 7000 / 9000
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            } 
            Lighting On
            SetTexture [_Base] {
                Combine texture * primary DOUBLE, texture * primary
            }
        }
    }
}


Modern Variant

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


// Credit for all code goes to Arthur B. (Pvloon)
// Released to the Unify Community Wiki as part of a contest, for free or commercial use;
// HOWEVER, THIS NOTICE MUST BE RETAINED IF ANY OF THE FOLLOWING CODE IS USED.

// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'

Shader "Terrain/Four Layer Toon Modern" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Color 1 (RGB)", 2D) = "white" {}
		_MainTex2 ("Color 2 (RGB)", 2D) = "white" {}
		_MainTex3 ("Color 3 (RGB)", 2D) = "white" {}
		_MainTex4 ("Color 4 (RGB)", 2D) = "white" {}
		_Mask ("Mixing Mask (RGBA)", 2D) = "gray" {}
		_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 
		_Base ("Base Color (RGB)", 2D) = "white" {}

	}

	Category {
		Lighting On
		Cull Back
		Fog { Color [_AddFog] }
		Subshader 
		{
			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;

			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;

				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}

			sampler2D _MainTex;
			sampler2D _MainTex2;
			sampler2D _MainTex3;
			sampler2D _MainTex4;
			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;
				float2 uv_MainTex;
				float2 uv_MainTex2;
				float2 uv_MainTex3;
				float2 uv_MainTex4;
				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};



			void surf (Input IN, inout SurfaceOutput o) {			
				// get the first three layer colors
				half4 color1 = tex2D( _MainTex, IN.uv_MainTex);
				half4 color2 = tex2D( _MainTex2, IN.uv_MainTex2);
				half4 color3 = tex2D( _MainTex3, IN.uv_MainTex3);
				half4 color4 = tex2D( _MainTex4, IN.uv_MainTex4);

				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);
				// mix the three layers
				
				half4 color = color1 * mask.r + color2 * mask.g + color3 * mask.b + color4 * mask.a;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 
		}
	}

    // ------------------------------------------------------------------
    // Radeon 7000 / 9000
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            } 
            Lighting On
            SetTexture [_MainTexture] {
                Combine texture * primary DOUBLE, texture * primary
            }
        }
    }
}


Modern Optional Variant

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


// Credit for all code goes to Arthur B. (Pvloon)
// Released to the Unify Community Wiki as part of a contest, for free or commercial use;
// HOWEVER, THIS NOTICE MUST BE RETAINED IF ANY OF THE FOLLOWING CODE IS USED.

// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'

Shader "Terrain/Four Layer Toon Modern Optional" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Color 1 (RGB)", 2D) = "white" {}
		_MainTex2 ("Color 2 (RGB)", 2D) = "white" {}
		_MainTex3 ("Color 3 (RGB)", 2D) = "white" {}
		_MainTex4 ("Color 4 (RGB)", 2D) = "white" {}
		_Mask ("Mixing Mask (RGBA)", 2D) = "gray" {}
		_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 
		_Base ("Base Color (RGB)", 2D) = "white" {}
		_LightCutoff("Light Cutoff", Range(0, 0.5)) = 0.05
	}

	Category {
		Lighting On
		Cull Back
		Fog { Color [_AddFog] }
		Subshader 
		{
			CGPROGRAM
			#pragma surface surf ToonRamp
				
			sampler2D _Ramp;
			float _LightCutoff;
			
			inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
			{
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
	
				half d = dot (s.Normal, lightDir)*0.5 + 0.5;

				half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
	
				half4 c;

				if (atten > (1.0 - _LightCutoff))
					atten = 1.0;
				else if (atten < _LightCutoff)
					atten = 0;

				c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
				c.a = 0;
				return c;
			}

			sampler2D _MainTex;
			sampler2D _MainTex2;
			sampler2D _MainTex3;
			sampler2D _MainTex4;
			sampler2D _Mask;
			float4 _Color;

			struct Input {			
				float4 pos : SV_POSITION;
				float2 uv_MainTex;
				float2 uv_MainTex2;
				float2 uv_MainTex3;
				float2 uv_MainTex4;
				float2 uv_Mask;
				float2 uv_Base;


				float4 diffuse : COLOR;
			};



			void surf (Input IN, inout SurfaceOutput o) {		
				// get the first three layer colors
				half4 color1 = tex2D( _MainTex, IN.uv_MainTex);
				half4 color2 = tex2D( _MainTex2, IN.uv_MainTex2);
				half4 color3 = tex2D( _MainTex3, IN.uv_MainTex3);
				half4 color4 = tex2D( _MainTex4, IN.uv_MainTex4);

				// get the mixing mask texture
				half4 mask = tex2D( _Mask, IN.uv_Mask.xy);
				// mix the three layers
				
				half4 color = color1 * mask.r + color2 * mask.g + color3 * mask.b + color4 * mask.a;

				o.Albedo = color.rgb;
				o.Alpha = color.a;
			}
			
			ENDCG 
		}
	}

    // ------------------------------------------------------------------
    // Radeon 7000 / 9000
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            } 
            Lighting On
            SetTexture [_Base] {
                Combine texture * primary DOUBLE, texture * primary
            }
        }
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools