UnityShader 学习笔记 25 屏幕后期之Bloom效果

  • Shader:


Shader "_MyShader/9_PostScreenEffect/3_MyBloom"{

    Properties {

        _MainTex ("Base (RGB)", 2D) = "white" {}

            _Bloom ("Bloom (RGB)", 2D) = "black" {}

            _LuminanceThreshold ("Luminance Threshold", Float) = 0.5

            _BlurSize ("Blur Size", Float) = 1.0

    }

    SubShader {

        CGINCLUDE



        #include "UnityCG.cginc"



        sampler2D _MainTex;

        half4 _MainTex_TexelSize;

        sampler2D _Bloom;

        float _LuminanceThreshold;

        float _BlurSize;



        struct v2f {

            float4 pos : SV_POSITION; 

            half2 uv : TEXCOORD0;

        };    



        v2f vertExtractBright(appdata_img v) {

            v2f o;



            o.pos = mul(UNITY_MATRIX_MVP, v.vertex);



            o.uv = v.texcoord;



            return o;

        }



        fixed luminance(fixed4 color) {

            return  0.2125 * color.r + 0.7154 * color.g + 0.0721 * color.b; 

        }



        fixed4 fragExtractBright(v2f i) : SV_Target {

            fixed4 c = tex2D(_MainTex, i.uv);

            fixed val = clamp(luminance(c) - _LuminanceThreshold, 0.0, 1.0);



            return c * val;

        }



        struct v2fBloom {

            float4 pos : SV_POSITION; 

            half4 uv : TEXCOORD0;

        };



        v2fBloom vertBloom(appdata_img v) {

            v2fBloom o;



            o.pos = mul (UNITY_MATRIX_MVP, v.vertex);

            o.uv.xy = v.texcoord;        

            o
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值