LayerShader

From Unify Community Wiki
Revision as of 19:04, 19 October 2009 by NCarter (Talk | contribs)

Jump to: navigation, search

Author: Bill Vinton (Sync1B)

Description

Terrain using the shader

This shader is good for making terrains where you need to tile textures but still want paths. Basically it blends between two textures using alpha from the third (Path Mask) texture.

This shader requires a 4-texture video card (GeForce3 and up, Radeon 8500 and up).

See also: TerrainFourLayer, which blends four terrain textures, and TerrainTwoLayerBumped shader, which adds bumpmapping.


Usage

Terrains, Tile masking

Path Mask texture's alpha channel is used to blend between Main and Path textures.


ShaderLab - TerrainTwoLayer.shader

<shaderlab>Shader "MyShaders/TwoLayerTerrain" {

   Properties {
       _Color ("Main Color", Color) = (1,1,1,1)
       _MainTex ("Main Texture (RGB)", 2D) = "white" {}
       _PathTex ("Path Texture (RGB)", 2D) = "white" {}
       _PathMask ("Path Mask (A)", 2D) = "white" {}
   }
   SubShader {
      Pass {
          Lighting On
          
          Material {
              Diffuse [_Color]
              Ambient [_Color]
          }
          SetTexture [_MainTex] {
              combine texture
          }
          SetTexture [_PathMask] {
              combine previous, texture
          }
          SetTexture [_PathTex] {
              combine previous lerp (previous) texture
          }
          SetTexture [_MainTex] {
              combine previous * primary
          }
      }
   } 
   FallBack " Diffuse", 1

}</shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox