Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bizio · Feb 02, 2019 at 11:30 AM · shaderlightingspritesmaterials

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
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

189 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges