VegetationTwoPass

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
Author: Nicholas
+
[[Category: ShaderLab]]
 +
[[Category: Vegetation]]
 +
Author: Nicholas Francis
 
==Description==
 
==Description==
 
This shader will renders two passes, One doing Cut off, and a second where it renders semitransparent details.
 
This shader will renders two passes, One doing Cut off, and a second where it renders semitransparent details.

Revision as of 22:05, 1 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

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