• unity shader 剔除指定的颜色


    Shader "MyShader/PaintingBGTransparency" {
        Properties{
            _MainTex("Base (RGB)", 2D) = "white" {}
            _FilterfColor("Ridof (RGB)",Color) = (1,1,1,1)
        }
            SubShader{
                Tags { "RenderType" = "Opaque" }
                Blend SrcAlpha OneMinusSrcAlpha
                pass
                {
                    CGPROGRAM
     
                    #pragma vertex vertext_convert
                    #pragma fragment fragment_convert
                    #include "UnityCG.cginc"
     
                    sampler2D  _MainTex;
                    sampler2D  _MainTex1;
                    float4  _FilterfColor;
                    struct Inputvrite
                    {
                        float4 vertex : POSITION;
                        float4 texcoord : TEXCOORD0;
                    };
                    struct Inputfragment
                    {
                        float4 pos : SV_POSITION;
                        float4 uv : TEXCOORD0;
                    };
     
                    float ColorLerp(float3 tmp_nowcolor,float3 tmp_FilterfColor)
                    {
                        float3 dis = float3(abs(tmp_nowcolor.x - tmp_FilterfColor.x),abs(tmp_nowcolor.y - tmp_FilterfColor.y),abs(tmp_nowcolor.z - tmp_FilterfColor.z));
                        float dis0 = sqrt(pow(dis.x,2) + pow(dis.y,2) + pow(dis.z,2));
                        float maxdis = sqrt(3);
                        float dis1 = lerp(0,maxdis,dis0);
                        return dis1;
                    }
     
                    Inputfragment vertext_convert(Inputvrite i)
                    {
                        Inputfragment o;
                        o.pos = UnityObjectToClipPos(i.vertex);
                        o.uv = float4(i.texcoord.xy,1,1);
                        return o;
                    }
     
                    float4 fragment_convert(Inputfragment o) : COLOR
                    {
                        float4 c = tex2D(_MainTex,o.uv);
                        c.a *= ColorLerp(c.rgb,_FilterfColor.rgb);
                        return c;
                    }
     
     
                ENDCG
                }
            }
                FallBack "Diffuse"
    }
  • 相关阅读:
    WPF中各个Template的分析(转)
    WPF TreeView
    微信支付文章综合
    WPF 颜色渐变
    史上最全的厦门英语角!赶紧收藏啦!
    SQL008存储过程总结
    SQL SERVER事务处理
    HTTP 头部解释
    为你详细解读HTTP请求头的具体含意
    IIS部署常见问题总结
  • 原文地址:https://www.cnblogs.com/dj1232090/p/14757994.html
Copyright © 2020-2023  润新知