VegetationTwoPass

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
Line 9: Line 9:
  
 
==ShaderLab - VegetationTwoPass.shader==
 
==ShaderLab - VegetationTwoPass.shader==
 +
<shaderlab>
 
  Shader "Nature/Vegetation Two Pass" {
 
  Shader "Nature/Vegetation Two Pass" {
 
         Properties {
 
         Properties {
Line 53: Line 54:
 
         }
 
         }
 
  }
 
  }
 +
</shaderlab>

Revision as of 14:21, 2 December 2005

Author: Nicholas Francis

Description

This shader will renders two passes, One doing Cut off, and a second where it renders semitransparent details.

Usage

Place this shader somewhere in your Assets folder hierarchy. Then, use it on any object where you want Culling off and alpha textures.

ShaderLab - VegetationTwoPass.shader

<shaderlab>

Shader "Nature/Vegetation Two Pass" {
        Properties {
                _Color ("Main Color", Color) = (.5, .5, .5, .5)
                _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
                _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
        }
        SubShader {
                // Set up basic lighting
                Material {
                        Diffuse [_Color]
                        Ambient [_Color]
                }       
                Lighting On

                // Render both front and back facing polygons.
                Cull Off

                // first pass:
                //   render any pixels that are more than [_Cutoff] opaque
                Pass {  
                        AlphaTest Greater [_Cutoff]
                        SetTexture [_MainTex] {
                                combine texture * primary, texture
                        }
                }

                // Second pass:
                //   render in the semitransparent details.
                Pass {
                        // Dont write to the depth buffer
                        ZWrite off
                        
                        // Only render pixels less or equal to the value
                        AlphaTest LEqual [_Cutoff]
                        
                        // Set up alpha blending
                        Blend SrcAlpha OneMinusSrcAlpha

                        SetTexture [_MainTex] {
                                combine texture * primary, texture
                        }
                }
        }
}

</shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox