Advertisement
SatyamBhatt

Shine Shader

May 14th, 2025 (edited)
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Unlit/DiagonalShine"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _Wipe ("Wipe", Float) = 0.0
  7.         _Angle ("Angle", Float) = 1
  8.         _Bands("Band", Float) = 0.0
  9.         _Thickness ("Thickness", Float) = 10
  10.         _Strength ("Strength", Float) = 1
  11.         _HighlightColor ("Highlight Color", Color) = (1,1,1,1)
  12.     }
  13.     SubShader
  14.     {
  15.         Tags {
  16.             "RenderType"="Transparent"
  17.             "Queue"="Transparent"
  18.         }
  19.  
  20.         Pass
  21.         {
  22.             Cull Off
  23.             ZWrite Off
  24.             Blend SrcAlpha OneMinusSrcAlpha
  25.  
  26.             CGPROGRAM
  27.             #pragma vertex vert
  28.             #pragma fragment frag
  29.             #define PI 3.14159
  30.  
  31.             #include "UnityCG.cginc"
  32.  
  33.             struct appdata
  34.             {
  35.                 float4 vertex : POSITION;
  36.                 float2 uv : TEXCOORD0;
  37.             };
  38.  
  39.             struct v2f
  40.             {
  41.                 float2 uv : TEXCOORD0;
  42.                 float4 vertex : SV_POSITION;
  43.             };
  44.  
  45.             sampler2D _MainTex;
  46.             float4 _MainTex_ST;
  47.             float _Wipe;
  48.             float _Bands;
  49.             float _Angle;
  50.             float _Thickness;
  51.             float _Strength;
  52.             float4 _HighlightColor;
  53.  
  54.             v2f vert (appdata v)
  55.             {
  56.                 v2f o;
  57.                 o.vertex = UnityObjectToClipPos(v.vertex);
  58.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  59.                 return o;
  60.             }
  61.  
  62.             float4 frag (v2f i) : SV_Target
  63.             {
  64.                 // sample the texture
  65.                 float4 col = tex2D(_MainTex, i.uv);
  66.                 float mask = step(0.05, col.x); // Mask black components of the texture
  67.  
  68.                 float2 uv = i.uv * 1; // Control distance between bands
  69.  
  70.                 // == If you want to control the wipe through script ==
  71.                 float xval = sin((uv.x * PI * _Bands + uv.y * PI/_Angle * _Bands) - _Wipe); // Control angle and wipe
  72.                 // ==
  73.  
  74.                 // == If you want to repeat the pattern ==
  75.                 //float xval = sin((uv.x * PI * _Bands + uv.y * PI/_Angle * _Bands) - (_Time.y * 3)); // Control speed of shine
  76.                 // ==
  77.  
  78.                 xval = saturate(xval);
  79.                 xval = pow(xval, _Thickness) * _Strength; // Control sharpness + thickness
  80.                 float4 xvaladd = float4(xval, xval, xval, col.a); // Mask
  81.                
  82.                 float4 stripe = lerp(col, _HighlightColor + col, xvaladd * mask);
  83.                 return stripe;
  84.             }
  85.             ENDCG
  86.         }
  87.     }
  88. }
  89.  
Tags: Shine Shader
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement