Code Monkey home page Code Monkey logo

ugui-shader's Introduction

UGUI-shader 自定义效果

参考消融开源链接

思路:1.

		_graphics = GetComponentsInChildren<Graphic>();
        for(int i=0;i< Graphics.Length;i++)
        {
        	Graphics[i].material = _defaultMaterial;
        }

​ 2.使用点在屏幕上位置,作为的噪声贴图采样的uv值。

v2f vert(appdata v)
{
    v2f o = (v2f)0;
    UNITY_SETUP_INSTANCE_ID(v);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);

    o.worldPosition = v.vertex;
    o.vertex = UnityObjectToClipPos(v.vertex);
    o.srcPos = ComputeScreenPos(o.vertex);
    o.texcoord.xy = v.texcoord;
    o.texcoord.zw = v.texcoord.xy * _Ramp_ST.xy + _Ramp_ST.zw;
    o.color = v.color;

    return o;
}

fixed4 frag(v2f i) : SV_Target
{
    float2 noiseUV = float2(i.srcPos.xy * _Ramp_ST + _Ramp_ST.zw);
    float cutout = tex2D(_Ramp, noiseUV).r;
    fixed4 col = (tex2D(_MainTex, i.texcoord.xy) + _TextureSampleAdd) * i.color;

    #ifdef UNITY_UI_CLIP_RECT
    col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
    #endif

    #ifdef UNITY_UI_ALPHACLIP
    clip (min(col.a - 0.5, 0.6));
    #endif

    col.a *= smoothstep(0, 0.1, _Blend - cutout);


    return col;
}

ugui-shader's People

Contributors

hj9944 avatar

Stargazers

Mr.Hu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.