unity遮挡提示,中枪散红,综合。。

Shader "Custom/PartDarkGeneral" {
    Properties {
        _MainTex ("Base (RGB)"2D) = "white" {}
        _AdjustColor("Adjust Color",Color)=(0,0,0,1)
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        //LOD 200
        
        Pass{
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off
            ZTest Greater
            CGPROGRAM
        #pragma vertex vert alpha
        #pragma fragment frag
        #include "UnityCG.cginc"
        sampler2D _MainTex;
        uniform float4 _MainTex_ST;
        float4 _AdjustColor;
        float _Pow;
        struct v2f {
                float4 pos : POSITION;
                float2 texcoord : TEXCOORD0;
            };
         v2f vert(appdata_base v)
        {
            v2f o;
            float3 nm;
            o.pos = mul (UNITY_MATRIX_MVPv.vertex);
            o.texcoord = TRANSFORM_TEX(v.texcoord_MainTex);
            return o;
        }
             fixed4 frag(v2f i) : COLOR
         {
             //return tex2D(_MainTex,i.texcoord)*fixed4(0.3,0.3,0.3,1);
             //return fixed4(0.4,0.4,0.4,1);
             return _AdjustColor;//fixed4(0,0.6,0,0.5);
         }
        ENDCG
        }
        Pass{
            //ZWrite On
            //ZTest LEqual
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        sampler2D _MainTex;
        uniform float4 _MainTex_ST;
        float _Pow;
        struct v2f {
                float4 pos : POSITION;
                float2 texcoord : TEXCOORD0;
            };
         v2f vert(appdata_base v)
        {
            v2f o;
            float3 nm;
            o.pos = mul (UNITY_MATRIX_MVPv.vertex);
            o.texcoord = TRANSFORM_TEX(v.texcoord_MainTex);
            return o;
        }
             fixed4 frag(v2f i) : COLOR
         {
             return tex2D(_MainTex,i.texcoord);
         }
        ENDCG
        }
    } 
    FallBack "Diffuse"

}



Shader "Custom/PartDark" {
    Properties {
        _MainTex ("Base (RGB)"2D) = "white" {}
        _AdjustColor2("Adjust Color",Color)=(0,0,0,1)
        _Pow ("Pow"Range(7.0,10.0)) = 8.0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        //LOD 200
        Pass{
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off
            ZTest Greater
            CGPROGRAM
        #pragma vertex vert alpha
        #pragma fragment frag
        #include "UnityCG.cginc"
        sampler2D _MainTex;
        uniform float4 _MainTex_ST;
        float4 _AdjustColor2;
        float _Pow;
        struct v2f {
                float4 pos : POSITION;
                float2 texcoord : TEXCOORD0;
                float amount:TEXCOORD1;
            };
         v2f vert(appdata_base v)
        {
            v2f o;
            float3 nm;
            o.pos = mul (UNITY_MATRIX_MVPv.vertex);
            nm = mul (UNITY_MATRIX_IT_MVfloat4(v.normal,0)).xyz;
                nm = normalize(nm);
            o.texcoord = TRANSFORM_TEX(v.texcoord_MainTex);
            o.amount =  saturate((nm.x*nm.x + nm.y*nm.y - nm.z*nm.z*0.3));
                o.amount =pow(o.amount,_Pow);
            return o;
        }
             fixed4 frag(v2f i) : COLOR
         {
             fixed4 ret;
             fixed4 f4=tex2D(_MainTex,i.texcoord);
             //ret.rgb=lerp(f4.rgb,fixed3(1,0,0),i.amount)*fixed3(0.3,0.3,0.3);
             //ret.rgb=fixed3(0.4,0.4,0.4);
             return _AdjustColor2;//fixed4(0,0.6,0,0.5);
         }
        ENDCG
        }
        Pass{
            //ZWrite On
            //ZTest LEqual
            CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        sampler2D _MainTex;
        uniform float4 _MainTex_ST;
        float _Pow;
        struct v2f {
                float4 pos : POSITION;
                float2 texcoord : TEXCOORD0;
                float amount:TEXCOORD1;
            };
         v2f vert(appdata_base v)
        {
            v2f o;
            float3 nm;
            o.pos = mul (UNITY_MATRIX_MVPv.vertex);
            nm = mul (UNITY_MATRIX_IT_MVfloat4(v.normal,0)).xyz;
                nm = normalize(nm);
            o.texcoord = TRANSFORM_TEX(v.texcoord_MainTex);
            o.amount =  saturate((nm.x*nm.x + nm.y*nm.y - nm.z*nm.z*0.3));
                o.amount =pow(o.amount,_Pow);
            return o;
        }
             fixed4 frag(v2f i) : COLOR
         {
             fixed4 ret;
             fixed4 f4=tex2D(_MainTex,i.texcoord);
             ret.rgb=lerp(f4.rgb,fixed3(0.8,0,0),i.amount);
             ret.a=f4.a;
             return ret;
         }
        ENDCG
        }
    } 
    FallBack "Diffuse"
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值