TerrainFourLayerDiffuseFast

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Added new page)
 
m (Text replace - "</shaderlab>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category: ShaderLab]]
 
[[Category: ShaderLab]]
Author: Eric Haines (Eric5h5)
+
Author: Eric Haines (Eric5h5) - Based on Aras's shader and the built-in Diffuse Fast shader; any mistakes are mine...though it does work (but only on ATI cards, not nVidia apparently, or at least not the 7300 or 8600).
 
==Description==
 
==Description==
 
This shader is a combination of the [[TerrainFourLayer]] shader and the built-in Diffuse Fast shader, so it can use fog and light cookies.  According to the graphics emulation, it needs an R9500 class card or newer to work.
 
This shader is a combination of the [[TerrainFourLayer]] shader and the built-in Diffuse Fast shader, so it can use fog and light cookies.  According to the graphics emulation, it needs an R9500 class card or newer to work.
Line 8: Line 8:
  
 
==ShaderLab - FourLayerDiffuseFast.shader==
 
==ShaderLab - FourLayerDiffuseFast.shader==
<shaderlab>Shader "Terrain/Four Layer Diffuse Fast" {
+
<syntaxhighlight lang="shaderlab">Shader "Terrain/Four Layer Diffuse Fast" {
 
Properties {
 
Properties {
 
     _Color ("Main Color", Color) = (1,1,1,1)
 
     _Color ("Main Color", Color) = (1,1,1,1)
Line 23: Line 23:
  
 
Category {
 
Category {
Blend AppSrcAdd AppDstAdd
+
    Blend AppSrcAdd AppDstAdd
Fog { Color [_AddFog] }
+
    Fog { Color [_AddFog] }
+
   
// ------------------------------------------------------------------
+
    // ------------------------------------------------------------------
// ARB fragment program
+
    // ARB fragment program
+
   
SubShader {
+
    SubShader {
// Ambient pass
+
        // Ambient pass
Pass {
+
        Pass {
Name "BASE"
+
            Name "BASE"
Tags {"LightMode" = "PixelOrNone"}
+
            Tags {"LightMode" = "PixelOrNone"}
Color [_PPLAmbient]
+
            Color [_PPLAmbient]
SetTexture [_MainTex] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
+
            CGPROGRAM
}
+
#pragma fragment frag
// Vertex lights
+
#pragma multi_compile_builtin_noshadows
Pass {  
+
#pragma fragmentoption ARB_fog_exp2
Name "BASE"
+
#pragma fragmentoption ARB_precision_hint_fastest
Tags {"LightMode" = "Vertex"}
+
 
Lighting On
+
struct v2f {
Material {
+
    float4 uv[5] : TEXCOORD0;
Diffuse [_Color]
+
    float4 diff : COLOR0;
Emission [_PPLAmbient]
+
}; 
}
+
 
SetTexture [_MainTex] { constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
+
uniform sampler2D _MainTex : register(s0);
}
+
uniform sampler2D _MainTex2 : register(s1);
// Pixel lights
+
uniform sampler2D _MainTex3 : register(s2);
Pass {
+
uniform sampler2D _MainTex4 : register(s3);
Name "PPL"
+
uniform sampler2D _Mask : register(s4);
Tags { "LightMode" = "Pixel" }
+
 
Material { Diffuse [_Color] }
+
half4 frag (v2f i) : COLOR
Lighting On
+
{
 +
    // get the four layer colors
 +
    half4 color1 = tex2D( _MainTex, i.uv[0].xy );
 +
    half4 color2 = tex2D( _MainTex2, i.uv[1].xy );
 +
    half4 color3 = tex2D( _MainTex3, i.uv[2].xy );
 +
    half4 color4 = tex2D( _MainTex4, i.uv[3].xy );
 +
    // get the mixing mask texture
 +
    half4 mask = tex2D( _Mask, i.uv[4].xy );
 +
   
 +
    half4 c;
 +
    // mix the four layers
 +
    c.xyz = (color1.xyz * mask.r + color2.xyz * mask.g + color3.xyz * mask.b + color4.xyz * mask.a) * i.diff.xyz * 2;
 +
    c.w = 0;
 +
    return c;
 +
}
 +
ENDCG
 +
 
 +
            SetTexture[_MainTex] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
 +
            SetTexture[_MainTex2] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
 +
            SetTexture[_MainTex3] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
 +
            SetTexture[_MainTex4] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
 +
            SetTexture[_Mask] {}
 +
        }
 +
        // Vertex lights
 +
        Pass {  
 +
            Name "BASE"
 +
            Tags {"LightMode" = "Vertex"}
 +
            Lighting On
 +
            Material {
 +
                Diffuse [_Color]
 +
                Ambient [_Color]
 +
                Emission [_PPLAmbient]
 +
            }
 +
            SetTexture [_MainTex] { constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
 +
        }
 +
        // Pixel lights
 +
        Pass {
 +
            Name "PPL"
 +
            Tags { "LightMode" = "Pixel" }
 +
            Material { Diffuse [_Color] }
 +
            Lighting On
  
 
CGPROGRAM
 
CGPROGRAM
Line 68: Line 108:
 
uniform sampler3D _LightTexture0 : register(s5);
 
uniform sampler3D _LightTexture0 : register(s5);
 
#ifdef SHADER_API_D3D9
 
#ifdef SHADER_API_D3D9
#define LIGHT_ATTENUATION(a) (tex3D(_LightTexture0, a._LightCoord).r)
+
#define LIGHT_ATTENUATION(a)   (tex3D(_LightTexture0, a._LightCoord).r)
 
#else
 
#else
#define LIGHT_ATTENUATION(a) (tex3D(_LightTexture0, a._LightCoord).w)
+
#define LIGHT_ATTENUATION(a)   (tex3D(_LightTexture0, a._LightCoord).w)
 
#endif
 
#endif
 
#endif
 
#endif
Line 79: Line 119:
 
uniform sampler2D _LightTexture0 : register(s5);
 
uniform sampler2D _LightTexture0 : register(s5);
 
uniform sampler2D _LightTextureB0 : register(s6);
 
uniform sampler2D _LightTextureB0 : register(s6);
#define LIGHT_ATTENUATION(a) (tex2Dproj (_LightTexture0, a._LightCoord.xyz).w * tex2D(_LightTextureB0, a._LightCoord2.xy).w)  
+
#define LIGHT_ATTENUATION(a)   (tex2Dproj (_LightTexture0, a._LightCoord.xyz).w * tex2D(_LightTextureB0, a._LightCoord2.xy).w)  
 
#endif  
 
#endif  
  
Line 85: Line 125:
 
#ifdef DIRECTIONAL
 
#ifdef DIRECTIONAL
 
#define LIGHTING_COORDS  
 
#define LIGHTING_COORDS  
#define LIGHT_ATTENUATION(a) 1.0
+
#define LIGHT_ATTENUATION(a)   1.0
 
#endif
 
#endif
  
Line 91: Line 131:
 
#ifdef POINT_NOATT
 
#ifdef POINT_NOATT
 
#define LIGHTING_COORDS  
 
#define LIGHTING_COORDS  
#define LIGHT_ATTENUATION(a) 1.0
+
#define LIGHT_ATTENUATION(a)   1.0
 
#endif
 
#endif
  
Line 98: Line 138:
 
#define LIGHTING_COORDS float3 _LightCoord : TEXCOORD5;
 
#define LIGHTING_COORDS float3 _LightCoord : TEXCOORD5;
 
uniform samplerCUBE _LightTexture0 : register(s5);
 
uniform samplerCUBE _LightTexture0 : register(s5);
#define LIGHT_ATTENUATION(a) (texCUBE(_LightTexture0, a._LightCoord).w)
+
#define LIGHT_ATTENUATION(a)   (texCUBE(_LightTexture0, a._LightCoord).w)
 
#endif
 
#endif
  
Line 105: Line 145:
 
#define LIGHTING_COORDS float2 _LightCoord : TEXCOORD5;
 
#define LIGHTING_COORDS float2 _LightCoord : TEXCOORD5;
 
uniform sampler2D _LightTexture0 : register(s5);
 
uniform sampler2D _LightTexture0 : register(s5);
#define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, a._LightCoord).w)
+
#define LIGHT_ATTENUATION(a)   (tex2D(_LightTexture0, a._LightCoord).w)
 
#endif
 
#endif
  
Line 111: Line 151:
 
struct v2f {
 
struct v2f {
 
     float4 uv[5] : TEXCOORD0;
 
     float4 uv[5] : TEXCOORD0;
LIGHTING_COORDS
+
    LIGHTING_COORDS
float4 diff : COLOR0;
+
    float4 diff : COLOR0;
 
};   
 
};   
  
Line 123: Line 163:
 
half4 frag (v2f i) : COLOR
 
half4 frag (v2f i) : COLOR
 
{
 
{
// get the four layer colors
+
    // get the four layer colors
half4 color1 = tex2D( _MainTex, i.uv[0].xy );
+
    half4 color1 = tex2D( _MainTex, i.uv[0].xy );
 
     half4 color2 = tex2D( _MainTex2, i.uv[1].xy );
 
     half4 color2 = tex2D( _MainTex2, i.uv[1].xy );
 
     half4 color3 = tex2D( _MainTex3, i.uv[2].xy );
 
     half4 color3 = tex2D( _MainTex3, i.uv[2].xy );
Line 131: Line 171:
 
     half4 mask = tex2D( _Mask, i.uv[4].xy );
 
     half4 mask = tex2D( _Mask, i.uv[4].xy );
 
      
 
      
half4 c;
+
    half4 c;
 
     // mix the four layers
 
     // mix the four layers
c.xyz = (color1.xyz * mask.r + color2.xyz * mask.g + color3.xyz * mask.b + color4.xyz * mask.a) * i.diff.xyz * (LIGHT_ATTENUATION(i) * 2);
+
    c.xyz = (color1.xyz * mask.r + color2.xyz * mask.g + color3.xyz * mask.b + color4.xyz * mask.a) * i.diff.xyz * (LIGHT_ATTENUATION(i) * 2);
c.w = 0;
+
    c.w = 0;
return c;
+
    return c;
 
}  
 
}  
 
ENDCG
 
ENDCG
  
SetTexture[_MainTex] {}
+
            SetTexture[_MainTex] {}
SetTexture[_MainTex2] {}
+
            SetTexture[_MainTex2] {}
SetTexture[_MainTex3] {}
+
            SetTexture[_MainTex3] {}
SetTexture[_MainTex4] {}
+
            SetTexture[_MainTex4] {}
SetTexture[_Mask] {}
+
            SetTexture[_Mask] {}
SetTexture[_LightTexture0] {}
+
            SetTexture[_LightTexture0] {}
SetTexture[_LightTextureB0] {}
+
            SetTexture[_LightTextureB0] {}
}
+
        }
}
+
    }
  
// ------------------------------------------------------------------
+
    // ------------------------------------------------------------------
// Radeon 7000 / 9000
+
    // Radeon 7000 / 9000
+
   
SubShader {
+
    SubShader {
Material {
+
        Material {
Diffuse [_Color]
+
            Diffuse [_Color]
Emission [_PPLAmbient]
+
            Emission [_PPLAmbient]
}
+
        }
Lighting On
+
        Lighting On
// Ambient pass
+
        // Ambient pass
Pass {
+
        Pass {
Name "BASE"
+
            Name "BASE"
Tags {"LightMode" = "PixelOrNone"}
+
            Tags {"LightMode" = "PixelOrNone"}
Color [_PPLAmbient]
+
            Color [_PPLAmbient]
Lighting Off
+
            Lighting Off
SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
+
            SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
}
+
        }
// Vertex lights
+
        // Vertex lights
Pass {
+
        Pass {
Name "BASE"
+
            Name "BASE"
Tags {"LightMode" = "Vertex"}
+
            Tags {"LightMode" = "Vertex"}
SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
+
            SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
}
+
        }
// Pixel lights with 2 light textures
+
        // Pixel lights with 2 light textures
Pass {
+
        Pass {
Name "PPL"
+
            Name "PPL"
Tags {
+
            Tags {
"LightMode" = "Pixel"
+
                "LightMode" = "Pixel"
"LightTexCount"  = "2"
+
                "LightTexCount"  = "2"
}
+
            }
ColorMask RGB
+
            ColorMask RGB
SetTexture [_LightTexture0] { combine previous * texture alpha, previous }
+
            SetTexture [_LightTexture0]     { combine previous * texture alpha, previous }
SetTexture [_LightTextureB0] { combine previous * texture alpha, previous }
+
            SetTexture [_LightTextureB0]   { combine previous * texture alpha, previous }
SetTexture [_MainTex] {combine previous * texture DOUBLE}
+
            SetTexture [_MainTex] {combine previous * texture DOUBLE}
}
+
        }
// Pixel lights with 1 light texture
+
        // Pixel lights with 1 light texture
Pass {
+
        Pass {
Name "PPL"
+
            Name "PPL"
Tags {
+
            Tags {
"LightMode" = "Pixel"
+
                "LightMode" = "Pixel"
"LightTexCount"  = "1"
+
                "LightTexCount"  = "1"
}
+
            }
ColorMask RGB
+
            ColorMask RGB
SetTexture [_LightTexture0] { combine previous * texture alpha, previous }
+
            SetTexture [_LightTexture0] { combine previous * texture alpha, previous }
SetTexture [_MainTex] { combine previous * texture DOUBLE }
+
            SetTexture [_MainTex] { combine previous * texture DOUBLE }
}
+
        }
// Pixel lights with 0 light textures
+
        // Pixel lights with 0 light textures
Pass {
+
        Pass {
Name "PPL"
+
            Name "PPL"
Tags {
+
            Tags {
"LightMode" = "Pixel"
+
                "LightMode" = "Pixel"
"LightTexCount" = "0"
+
                "LightTexCount" = "0"
}
+
            }
ColorMask RGB
+
            ColorMask RGB
SetTexture[_MainTex] { combine previous * texture DOUBLE }
+
            SetTexture[_MainTex] { combine previous * texture DOUBLE }
}
+
        }
}
+
    }
 
}
 
}
  
 
Fallback "VertexLit", 2
 
Fallback "VertexLit", 2
  
}</shaderlab>
+
}</syntaxhighlight>

Latest revision as of 21:56, 17 January 2012

Author: Eric Haines (Eric5h5) - Based on Aras's shader and the built-in Diffuse Fast shader; any mistakes are mine...though it does work (but only on ATI cards, not nVidia apparently, or at least not the 7300 or 8600).

[edit] Description

This shader is a combination of the TerrainFourLayer shader and the built-in Diffuse Fast shader, so it can use fog and light cookies. According to the graphics emulation, it needs an R9500 class card or newer to work.

[edit] Usage

Place this shader somewhere in your Assets folder hierarchy, create a material which uses it and apply it to the relevant objects.

[edit] ShaderLab - FourLayerDiffuseFast.shader

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


Shader "Terrain/Four Layer Diffuse Fast" {
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" {}
}

// Calculates lighting per vertex, but applies
// light attenuation maps or spot cookies per pixel.
// Quite fine for tesselated geometry.

Category {
    Blend AppSrcAdd AppDstAdd
    Fog { Color [_AddFog] }
    
    // ------------------------------------------------------------------
    // ARB fragment program
    
    SubShader {
        // Ambient pass
        Pass {
            Name "BASE"
            Tags {"LightMode" = "PixelOrNone"}
            Color [_PPLAmbient]
            CGPROGRAM
#pragma fragment frag
#pragma multi_compile_builtin_noshadows
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest

struct v2f {
    float4 uv[5] : TEXCOORD0;
    float4 diff : COLOR0;
};  

uniform sampler2D _MainTex : register(s0);
uniform sampler2D _MainTex2 : register(s1);
uniform sampler2D _MainTex3 : register(s2);
uniform sampler2D _MainTex4 : register(s3);
uniform sampler2D _Mask : register(s4);

half4 frag (v2f i) : COLOR
{
    // get the four layer colors
    half4 color1 = tex2D( _MainTex, i.uv[0].xy );
    half4 color2 = tex2D( _MainTex2, i.uv[1].xy );
    half4 color3 = tex2D( _MainTex3, i.uv[2].xy );
    half4 color4 = tex2D( _MainTex4, i.uv[3].xy );
    // get the mixing mask texture
    half4 mask = tex2D( _Mask, i.uv[4].xy );
    
    half4 c;
    // mix the four layers
    c.xyz = (color1.xyz * mask.r + color2.xyz * mask.g + color3.xyz * mask.b + color4.xyz * mask.a) * i.diff.xyz * 2;
    c.w = 0;
    return c;
} 
ENDCG

            SetTexture[_MainTex] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
            SetTexture[_MainTex2] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
            SetTexture[_MainTex3] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
            SetTexture[_MainTex4] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
            SetTexture[_Mask] {}
        }
        // Vertex lights
        Pass { 
            Name "BASE"
            Tags {"LightMode" = "Vertex"}
            Lighting On
            Material {
                Diffuse [_Color]
                Ambient [_Color]
                Emission [_PPLAmbient]
            }
            SetTexture [_MainTex] { constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
        }
        // Pixel lights
        Pass {
            Name "PPL"
            Tags { "LightMode" = "Pixel" }
            Material { Diffuse [_Color] }
            Lighting On

CGPROGRAM
// TODO: need vertex-lighting emulation here!
#pragma fragment frag
#pragma multi_compile_builtin_noshadows
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

#ifdef POINT
#define LIGHTING_COORDS float3 _LightCoord : TEXCOORD5;
uniform sampler3D _LightTexture0 : register(s5);
#ifdef SHADER_API_D3D9
#define LIGHT_ATTENUATION(a)    (tex3D(_LightTexture0, a._LightCoord).r)
#else
#define LIGHT_ATTENUATION(a)    (tex3D(_LightTexture0, a._LightCoord).w)
#endif
#endif


#ifdef SPOT
#define LIGHTING_COORDS float4 _LightCoord : TEXCOORD5; float4 _LightCoord2 : TEXCOORD6;
uniform sampler2D _LightTexture0 : register(s5);
uniform sampler2D _LightTextureB0 : register(s6);
#define LIGHT_ATTENUATION(a)    (tex2Dproj (_LightTexture0, a._LightCoord.xyz).w * tex2D(_LightTextureB0, a._LightCoord2.xy).w) 
#endif 


#ifdef DIRECTIONAL
#define LIGHTING_COORDS 
#define LIGHT_ATTENUATION(a)    1.0
#endif


#ifdef POINT_NOATT
#define LIGHTING_COORDS 
#define LIGHT_ATTENUATION(a)    1.0
#endif


#ifdef POINT_COOKIE
#define LIGHTING_COORDS float3 _LightCoord : TEXCOORD5;
uniform samplerCUBE _LightTexture0 : register(s5);
#define LIGHT_ATTENUATION(a)    (texCUBE(_LightTexture0, a._LightCoord).w)
#endif


#ifdef DIRECTIONAL_COOKIE
#define LIGHTING_COORDS float2 _LightCoord : TEXCOORD5;
uniform sampler2D _LightTexture0 : register(s5);
#define LIGHT_ATTENUATION(a)    (tex2D(_LightTexture0, a._LightCoord).w)
#endif


struct v2f {
    float4 uv[5] : TEXCOORD0;
    LIGHTING_COORDS
    float4 diff : COLOR0;
};  

uniform sampler2D _MainTex : register(s0);
uniform sampler2D _MainTex2 : register(s1);
uniform sampler2D _MainTex3 : register(s2);
uniform sampler2D _MainTex4 : register(s3);
uniform sampler2D _Mask : register(s4);

half4 frag (v2f i) : COLOR
{
    // get the four layer colors
    half4 color1 = tex2D( _MainTex, i.uv[0].xy );
    half4 color2 = tex2D( _MainTex2, i.uv[1].xy );
    half4 color3 = tex2D( _MainTex3, i.uv[2].xy );
    half4 color4 = tex2D( _MainTex4, i.uv[3].xy );
    // get the mixing mask texture
    half4 mask = tex2D( _Mask, i.uv[4].xy );
    
    half4 c;
    // mix the four layers
    c.xyz = (color1.xyz * mask.r + color2.xyz * mask.g + color3.xyz * mask.b + color4.xyz * mask.a) * i.diff.xyz * (LIGHT_ATTENUATION(i) * 2);
    c.w = 0;
    return c;
} 
ENDCG

            SetTexture[_MainTex] {}
            SetTexture[_MainTex2] {}
            SetTexture[_MainTex3] {}
            SetTexture[_MainTex4] {}
            SetTexture[_Mask] {}
            SetTexture[_LightTexture0] {}
            SetTexture[_LightTextureB0] {}
        }
    }

    // ------------------------------------------------------------------
    // Radeon 7000 / 9000
    
    SubShader {
        Material {
            Diffuse [_Color]
            Emission [_PPLAmbient]
        }
        Lighting On
        // Ambient pass
        Pass {
            Name "BASE"
            Tags {"LightMode" = "PixelOrNone"}
            Color [_PPLAmbient]
            Lighting Off
            SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
        }
        // Vertex lights
        Pass {
            Name "BASE"
            Tags {"LightMode" = "Vertex"}
            SetTexture [_MainTex] {Combine texture * primary DOUBLE, primary * texture}
        }
        // Pixel lights with 2 light textures
        Pass {
            Name "PPL"
            Tags {
                "LightMode" = "Pixel"
                "LightTexCount"  = "2"
            }
            ColorMask RGB
            SetTexture [_LightTexture0]     { combine previous * texture alpha, previous }
            SetTexture [_LightTextureB0]    { combine previous * texture alpha, previous }
            SetTexture [_MainTex] {combine previous * texture DOUBLE}
        }
        // Pixel lights with 1 light texture
        Pass {
            Name "PPL"
            Tags {
                "LightMode" = "Pixel"
                "LightTexCount"  = "1"
            }
            ColorMask RGB
            SetTexture [_LightTexture0] { combine previous * texture alpha, previous }
            SetTexture [_MainTex] { combine previous * texture DOUBLE }
        }
        // Pixel lights with 0 light textures
        Pass {
            Name "PPL"
            Tags {
                "LightMode" = "Pixel"
                "LightTexCount" = "0"
            }
            ColorMask RGB
            SetTexture[_MainTex] { combine previous * texture DOUBLE }
        }
    }
}

Fallback "VertexLit", 2

}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox