TerrainFourLayer
m (Text replace - "<shaderlab>" to "<syntaxhighlight lang="shaderlab">") |
m (Text replace - "</shaderlab>" to "</syntaxhighlight>") |
||
| Line 62: | Line 62: | ||
} | } | ||
FallBack " VertexLit", 1 | FallBack " VertexLit", 1 | ||
| − | }</ | + | }</syntaxhighlight> |
Latest revision as of 23:56, 17 January 2012
Author: Aras Pranckevicius
[edit] Description
This shader is similar to LayerShader, it just mixes four tileable textures based on RGBA channels of additional texture.
This shader requires a fragment program card to work. I'm not sure if it works correctly on GeForceFX, as they report only 4 texture units (whereas the shader needs 5).
[edit] ShaderLab - TerrainFourLayer.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" {
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" {}
}
SubShader {
Pass {
Lighting On
Material {
Diffuse [_Color]
Ambient [_Color]
}
CGPROGRAM
// profiles arbfp1
// fragment frag
sampler2D _MainTex : register(s0);
sampler2D _MainTex2 : register(s1);
sampler2D _MainTex3 : register(s2);
sampler2D _MainTex4 : register(s3);
sampler2D _Mask : register(s4);
struct v2f {
float4 uv[5] : TEXCOORD0;
float4 diffuse : COLOR;
};
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 );
// mix the four layers
half4 color = color1 * mask.r + color2 * mask.g + color3 * mask.b + color4 * mask.a;
// multiply and double by the lighting
return color * i.diffuse * 2.0;
}
ENDCG
SetTexture[_MainTex] {}
SetTexture[_MainTex2] {}
SetTexture[_MainTex3] {}
SetTexture[_MainTex4] {}
SetTexture[_Mask] {}
}
}
FallBack " VertexLit", 1
}