- Home /
 
How to edit a shader to make it show sprites it's on without lighting?
I found some shader on the Internet that makes radial blur effect for spinning objects. It works and looks pretty cool but when I apply it to a sprite it works like Sprite/Diffuse shader, it needs a light source to be seen, otherwise it's black. How can I edit this shader to make it work like normal Sprite/Default shader that doesn't need a light. I have none experience with shaders so it's magic for me. Any help?
Here's the code:
  Shader "Custom/SpinBlur"{
      Properties{
          _Color("Main Color", Color) = (1,1,1,1)
          _Samples("Samples", Range(0,360)) = 100
          _Angle("Angle", Range(0,360)) = 10
          _MainTex("Color (RGB) Alpha (A)", 2D) = "white"
      }
      SubShader{
      Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
   
      LOD 200
      Cull Off
   
      CGPROGRAM
      #pragma target 3.0
      #pragma surface surf Lambert alpha
   
      sampler2D _MainTex;
      int _Angle;
      int _Samples;
      float4 _Color;
     
      struct Input {
          float2 uv_MainTex;
          float4 screenPos;
      };
   
      float2 rotateUV(float2 uv, float degrees) {
          const float Deg2Rad = (UNITY_PI * 2.0) / 360.0;
          float rotationRadians = degrees * Deg2Rad;
          float s = sin(rotationRadians);
          float c = cos(rotationRadians);
          float2x2 rotationMatrix = float2x2(c, -s, s, c);
          uv -= 0.5;
          uv = mul(rotationMatrix, uv);
          uv += 0.5;
          return uv;
      }
   
      void surf(Input IN, inout SurfaceOutput o) {
          const float Deg2Rad = (UNITY_PI * 2.0) / 360.0;
          const float Rad2Deg = 180.0 / UNITY_PI;
          float2 vUv = IN.uv_MainTex;
          float2 coord = vUv;
          float4 FragColor = float4(0.0, 0.0, 0.0, 0.0);
          int samp = _Samples;
          if (samp <= 0) samp = 1;
          for (float i = 0; i < samp; i++) {
              float a = (float)_Angle / (float)samp;
              coord = rotateUV(coord, a);
              float4 texel = tex2D(_MainTex, coord);
              texel *= 1.0 / samp;
              FragColor += texel;
          }
          float4 c = FragColor*_Color;
          o.Albedo = c.rgb;
          o.Alpha = c.a;
      }
      ENDCG
      }
          FallBack "Diffuse"
  }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
2D Sprite Shader Acting like Light 0 Answers
Surface Shader PBR 1 Answer
Unity 3D Vs 3DS Max Default Models Colors Variance 0 Answers
Custom (Sprite-)Shader: Combine Sprite with light and original Sprite 0 Answers
HDRP double sided light problem 0 Answers