5/12/21

 

https://www.shadertoy.com/view/wdlGRM

 

 

// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.

Shader "Unlit/SPACE_GIF"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _Color2 ("Color", Color) = (1,1,1,1)
        _MainTex ("Texture", 2D) = "white" {}
        _RadiusMultiplier ("Radius", Range(0, 5)) = 1
        _GradientPivot ("Position", Vector) = (0, 0, 0, 0)
    }
    SubShader
    {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     LOD 100
     
     ZWrite Off
     Blend SrcAlpha OneMinusSrcAlpha 

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed4 _Color;
            fixed4 _Color2;
            float _RadiusMultiplier;
            float4 _GradientPivot;

            UNITY_INSTANCING_BUFFER_START(Props)
            //UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color) // Make _Color an instanced property (i.e. an array)
            UNITY_INSTANCING_BUFFER_END(Props)

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            float HexDist(float2 p) 
            {
                p = abs(p);
    
                float c = dot(p, normalize(float2(1,1.73)));
                c = max(c, p.x);
    
                return c;
            }


            fixed4 frag (v2f i) : SV_Target
            {
                float2 UV = i.uv - .5;
                float2 uv = UV;

    
                //uv *= float2x2(.707, -.707, .707, .707);
                uv *= 15.;
    
                float2 gv = frac(uv)-.5; 
                float2 id = floor(uv);
    
                float m = 0.;
                float t;
                for(float y=-1.; y<=1.; y++) 
                {
    				for(float x=-1.; x<=1.; x++) 
                    {
                        float2 offs = float2(x, y);
            
                        t = -_Time.y -length(uv-offs)*.3;
                        float r = lerp(.01, .75, sin(t)*.5+.5);
    					float c = smoothstep(r, r*.9, length(gv+offs));
    					m = m*(1.-c) + c*(1.-m);
                    }
                }
                //GRADIENT-RADIAL
                fixed2 pixelPoint = fixed2(UV.x, UV.y);
                float xDist = pow(pixelPoint.x - _GradientPivot.x, 2);
                float yDist = pow(pixelPoint.y - _GradientPivot.y, 2);
                float dist = sqrt(xDist + yDist) / _RadiusMultiplier;
                dist = clamp(dist, 0, 1);
                fixed4 colGRAD = lerp(_Color, _Color2, dist);

                fixed4 col = m *colGRAD;// sin(HexDist(UV)*10. + _Time.y)*
                return col;




            }
            ENDCG
        }
    }
}