VegetationTwoPass

From Unify Community Wiki
Revision as of 19:20, 1 December 2005 by 168.234.230.134 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Nicholas

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

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
                        }
                }
        }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox