unity自发光透明shader

unity自发光透明shader

这本来是一个glass的shader,但是我发现也可以用到自发光+透明,这两个脚本都是unity文档里面的。呵呵~~~

  1. Shader "Custom/AlphaSelfIllum" {  
  2. Properties {  
  3.         _Color ("Main Color", Color) = (1,1,1,0)  
  4.         _SpecColor ("Spec Color", Color) = (1,1,1,1)  
  5.         _Emission ("Emmisive Color", Color) = (0,0,0,0)  
  6.         _Shininess ("Shininess", Range (0.01, 1)) = 0.7  
  7.         _MainTex ("Base (RGB)", 2D) = "white" { }  
  8.     }  
  9.   
  10.     SubShader {  
  11.         // We use the material in many passes by defining them in the subshader.  
  12.         // Anything defined here becomes default values for all contained passes.  
  13.         Material {  
  14.             Diffuse [_Color]  
  15.             Ambient [_Color]  
  16.             Shininess [_Shininess]  
  17.             Specular [_SpecColor]  
  18.             Emission [_Emission]  
  19.         }  
  20.         Lighting On  
  21.         SeparateSpecular On  
  22.   
  23.         // Set up alpha blending  
  24.         Blend SrcAlpha OneMinusSrcAlpha  
  25.   
  26.         // Render the back facing parts of the object.  
  27.         // If the object is convex, these will always be further away  
  28.         // than the front-faces.    
  29.         //控制前面透明度        
  30.         //Pass {  
  31.         //    Cull Front  
  32.         //    SetTexture [_MainTex] {  
  33.         //        Combine Primary * Texture  
  34.         //    }  
  35.         //}  
  36.         // Render the parts of the object facing us.  
  37.         // If the object is convex, these will be closer than the  
  38.         // back-faces.  
  39.         //控制后面透明度    
  40.         Pass {  
  41.             Cull Back  
  42.             SetTexture [_MainTex] {  
  43.                 Combine Primary * Texture  
  44.             }  
  45.         }  
  46.     }  
  47. }   
Shader "Custom/AlphaSelfIllum" {
Properties {
        _Color ("Main Color", Color) = (1,1,1,0)
        _SpecColor ("Spec Color", Color) = (1,1,1,1)
        _Emission ("Emmisive Color", Color) = (0,0,0,0)
        _Shininess ("Shininess", Range (0.01, 1)) = 0.7
        _MainTex ("Base (RGB)", 2D) = "white" { }
    }

    SubShader {
        // We use the material in many passes by defining them in the subshader.
        // Anything defined here becomes default values for all contained passes.
        Material {
            Diffuse [_Color]
            Ambient [_Color]
            Shininess [_Shininess]
            Specular [_SpecColor]
            Emission [_Emission]
        }
        Lighting On
        SeparateSpecular On

        // Set up alpha blending
        Blend SrcAlpha OneMinusSrcAlpha

        // Render the back facing parts of the object.
        // If the object is convex, these will always be further away
        // than the front-faces.  
        //控制前面透明度      
        //Pass {
        //    Cull Front
        //    SetTexture [_MainTex] {
        //        Combine Primary * Texture
        //    }
        //}
        // Render the parts of the object facing us.
        // If the object is convex, these will be closer than the
        // back-faces.
        //控制后面透明度  
        Pass {
            Cull Back
            SetTexture [_MainTex] {
                Combine Primary * Texture
            }
        }
    }
} 




 

 

 

  1. Shader "Custom/Fog" {  
  2.     Properties {  
  3.       _MainTex ("Texture", 2D) = "white" {}  
  4.       _FogColor ("Fog Color", Color) = (0.3, 0.4, 0.7, 1.0)  
  5.     }  
  6.     SubShader {  
  7.       Tags { "RenderType" = "Opaque" }  
  8.       CGPROGRAM  
  9.       #pragma surface surf Lambert finalcolor:mycolor vertex:myvert  
  10.       struct Input {  
  11.           float2 uv_MainTex;  
  12.           half fog;  
  13.       };  
  14.       void myvert (inout appdata_full v, out Input data)  
  15.       {  
  16.           float4 hpos = mul (UNITY_MATRIX_MVP, v.vertex);  
  17.           data.fog = min (1, dot (hpos.xy, hpos.xy) * 0.1);  
  18.       }  
  19.       fixed4 _FogColor;  
  20.       void mycolor (Input IN, SurfaceOutput o, inout fixed4 color)  
  21.       {  
  22.           fixed3 fogColor = _FogColor.rgb;  
  23.           #ifdef UNITY_PASS_FORWARDADD  
  24.           fogColor = 0;  
  25.           #endif  
  26.           color.rgb = lerp (color.rgb, fogColor, IN.fog);  
  27.       }  
  28.       sampler2D _MainTex;  
  29.       void surf (Input IN, inout SurfaceOutput o) {  
  30.            o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;  
  31.       }  
  32.       ENDCG  
  33.     }   
  34.     Fallback "Diffuse"  
  35.   }  
posted @ 2013-03-23 15:09  小薇林  阅读(4959)  评论(1编辑  收藏  举报