码迷,mamicode.com
首页 > 其他好文 > 详细

AlphaTest

时间:2016-12-27 14:02:43      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:diffuse   spec   code   sha   bsh   .com   alt   tput   blog   

//AlphaTest:

Shader "Siyi/AlphaTest"
{
    Properties
    {
        _MainTex("MainTex",2D) = "white"{}
        _BumpMap("BumpMap",2D) = "white"{}
        _SpecMap("SpecMap",2D) = "white"{}
        _SpecPower("SpecPower",Range(0,1)) = .2
        _CutOff("AlphaTest",Range(0,1)) = .5
    }

    SubShader
    {
        Tags{"RenderType"="Opaque"}
        LOD 200

        CGPROGRAM
        #pragma surface surf BlinnPhong alphatest:_CutOff

        sampler2D _MainTex;
        sampler2D _BumpMap;
        sampler2D _SpecMap;
        float _SpecPower;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            float2 uv_SpecMap;
        };

        void surf(Input IN,inout SurfaceOutput o)
        {
            //MainTex
            float4 tex = tex2D(_MainTex,IN.uv_MainTex);
            o.Albedo = tex.rgb;

            //Alpha Test
            o.Alpha = tex.a;

            //BumpMap
            float4 bumpTex = tex2D(_BumpMap,IN.uv_BumpMap);
            o.Normal = UnpackNormal(bumpTex);

            //Specular Map
            float4 specTex = tex2D(_SpecMap,IN.uv_SpecMap);
            o.Gloss = specTex.rgb;
            o.Specular = _SpecPower;
        }

        ENDCG
    }
    FallBack "Diffuse"
}

//效果:

技术分享

AlphaTest

标签:diffuse   spec   code   sha   bsh   .com   alt   tput   blog   

原文地址:http://www.cnblogs.com/siyi/p/6225262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!