Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by hunvee3 · Feb 01, 2018 at 12:15 AM · shaderspritematerialshadowfadeout

Need help with Sprite shadow shader!!!

Hello everyone! I'm having a problem with my project. Again shaders are killing me XD So I need a Sprite shader that is: - Unlit - Transparent ( so for example the image is a blue circule with the rest with alpha = 0, the alpha part needs to be transparent) - Only recieve shadows - It needs to have a property color that allow me to change the overall alpha to make a fading effect (shown in the image 3 as a gif).

I have a shader that accomplishes everything except the fading effect. I was wondering if someone could fix this one for me since I have 0 knowledge of shaders XS.

The Sprite/Default shader accomplishes everything except receiving shadows like image 1 (shown in image 2).

The one I already have was given to me by another user.


 // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
 
 Shader "UnlitShadows/UnlitShadowReceive" {
     Properties{
         _MainTex("Base (RGB)", 2D) = "white" {}
 _CutOff("Cut off", float) = 0.1
     }
 
         SubShader{
         Pass{
         Tags{ "LightMode" = "ForwardBase" }
         CGPROGRAM
 #pragma vertex vert 
 #pragma fragment frag 
 #include "UnityCG.cginc" 
 #pragma multi_compile_fwdbase 
 #include "AutoLight.cginc" 
         sampler2D _MainTex;
     float4 _MainTex_ST;
 uniform float _CutOff;
     struct v2f {
         float4 pos : SV_POSITION;
         LIGHTING_COORDS(0,1)
             float2 uv : TEXCOORD2;
     };
 
     v2f vert(appdata_base v) {
         v2f o;
         o.pos = UnityObjectToClipPos(v.vertex);
         o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
         TRANSFER_VERTEX_TO_FRAGMENT(o);
         return o;
     }
 
     fixed4 frag(v2f i) : COLOR
     {
     float4 color = tex2D(_MainTex, i.uv);
         if(color.a < _CutOff) discard;
 
         float attenuation = LIGHT_ATTENUATION(i);
     return color * attenuation;
     }
         ENDCG
     }
 
         Pass{
         Blend One One
         Tags{ "LightMode" = "ForwardAdd" }
         CGPROGRAM
 #pragma vertex vert 
 #pragma fragment frag 
 #include "UnityCG.cginc" 
 #pragma multi_compile_fwdadd_fullshadows 
 #include "AutoLight.cginc" 
         sampler2D _MainTex;
     float4 _MainTex_ST;
     uniform float _CutOff;
 
     struct v2f {
         float4 pos : SV_POSITION;
         LIGHTING_COORDS(0,1)
             float2 uv : TEXCOORD2;
     };
 
     v2f vert(appdata_base v) {
         v2f o;
         o.pos = UnityObjectToClipPos(v.vertex);
         o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
         TRANSFER_VERTEX_TO_FRAGMENT(o);
         return o;
     }
 
     fixed4 frag(v2f i) : COLOR
     {
         float4 color = tex2D(_MainTex, i.uv);
         if(color.a < _CutOff) discard;
         float attenuation = LIGHT_ATTENUATION(i);
     return color * attenuation;
     }
         ENDCG
     }
     }
         Fallback "VertexLit"
 
 }



alt text image 1: Provided shader - dont work with fading effect.

alt text image 2: Sprite Default shader - dont work with shadows

alt text image 3: Fading effect using Sprite Default

So basically I need to transform the Sprite / Default shader so it can receive shadows, without changing its behaviour

particules2.png (37.9 kB)
particules1.png (54.8 kB)
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

202 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 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

How to continue material between sprites. 1 Answer

Sprite Material Problem 0 Answers

2D Shadows with 3D effect 0 Answers

How can I remove shadows from alpha cutout? 1 Answer

Lightweight render pipeline causing sprites to render black 1 Answer


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