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 Artuvazro · Apr 04, 2017 at 05:01 AM · 2dshadershadersshaderlab

Sprite Shader not working in 5.6

I was using the following shader to have unlit sprites that cast shadows. It worked pretty well and it did everything I needed. However, after updating to Unity 5.6 it broke. I've been looking at the changelog but I can't see exactly what's the change in unity behind this... Any help? Thank you!

Unity 5.5:

Unity5.5

Unity 5.6

Unity 56

 Shader "Sprite (Unlit)"
 {
     Properties
     {
         _MainTex ("Main Texture", 2D) = "white" {}
         _Color ("Color", Color) = (1,1,1,1)
         
         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
         
         _ZWrite ("Depth Write", Float) = 0.0
         _Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
         _ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
         _CustomRenderQueue ("Custom Render Queue", Float) = 0.0
         
         _OverlayColor ("Overlay Color", Color) = (0,0,0,0)
         _Hue("Hue", Range(-0.5,0.5)) = 0.0
         _Saturation("Saturation", Range(0,2)) = 1.0    
         _Brightness("Brightness", Range(0,2)) = 1.0    
         
         _BlendTex ("Blend Texture", 2D) = "white" {}
         _BlendAmount ("Blend", Range(0,1)) = 0.0
         
         [HideInInspector] _SrcBlend ("__src", Float) = 1.0
         [HideInInspector] _DstBlend ("__dst", Float) = 0.0
         [HideInInspector] _RenderQueue ("__queue", Float) = 0.0
         [HideInInspector] _Cull ("__cull", Float) = 0.0
     }
     
     SubShader
     {
         Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
         LOD 100
         
         Pass
         {
             Blend [_SrcBlend] [_DstBlend]
             Lighting Off
             ZWrite [_ZWrite]
             ZTest LEqual
             Cull [_Cull]
             Lighting Off
             
             CGPROGRAM            
                 #pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
                 #pragma shader_feature _ALPHA_CLIP
                 #pragma shader_feature _TEXTURE_BLEND
                 #pragma shader_feature _COLOR_ADJUST
                 #pragma shader_feature _FOG
                 
                 #pragma fragmentoption ARB_precision_hint_fastest
                 #pragma multi_compile_fog
                 #pragma multi_compile _ PIXELSNAP_ON
                 #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
                 
                 #pragma vertex vert
                 #pragma fragment frag
                 
                 #include "SpriteUnlit.cginc"
             ENDCG
         }
         Pass
         {
             Name "ShadowCaster"
             Tags { "LightMode"="ShadowCaster" }
             Offset 1, 1
             
             Fog { Mode Off }
             ZWrite On
             ZTest LEqual
             Cull Off
             Lighting Off
             
             CGPROGRAM        
                 #pragma fragmentoption ARB_precision_hint_fastest
                 #pragma multi_compile_shadowcaster
                 #pragma multi_compile _ PIXELSNAP_ON
                 #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
                 
                 #pragma vertex vert
                 #pragma fragment frag
                 
                 #include "SpriteShadows.cginc"
             ENDCG
         }
     }
     
     CustomEditor "SpriteShaderGUI"
 }
 



 #ifndef SPRITE_SHADOWS_INCLUDED
 #define SPRITE_SHADOWS_INCLUDED
 
 #include "ShaderShared.cginc"
 
 ////////////////////////////////////////
 // Vertex structs
 //
 
 struct vertexInput
 {
     float4 vertex : POSITION;
     float4 texcoord : TEXCOORD0;
 };
 
 struct vertexOutput
 { 
     V2F_SHADOW_CASTER;
     float2 texcoord : TEXCOORD1;
 };
 
 ////////////////////////////////////////
 // Vertex program
 //
 
 vertexOutput vert(vertexInput v)
 {
     vertexOutput o;
     TRANSFER_SHADOW_CASTER(o)
     o.texcoord = calculateTextureCoord(v.texcoord);
     return o;
 }
 
 ////////////////////////////////////////
 // Fragment program
 //
 
 
 uniform fixed _ShadowAlphaCutoff;
 
 fixed4 frag(vertexOutput IN) : COLOR 
 {
     fixed4 texureColor = calculateTexturePixel(IN.texcoord);
     clip(texureColor.a - _ShadowAlphaCutoff);
     
     SHADOW_CASTER_FRAGMENT(IN)
 }
 
 #endif // SPRITE_SHADOWS_INCLUDED


monster0.png (12.4 kB)
monster1.png (13.2 kB)
Comment
Add comment · Show 3
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
avatar image condeagustin · May 18, 2017 at 09:37 PM 0
Share

I also have problems with my laser shaders in unity 5.6.x. I had to move back to 5.5.x

avatar image condeagustin · May 22, 2017 at 03:09 PM 0
Share

I also have problems with my laser shaders in unity 5.6.x. I had to move back to 5.5.x

avatar image landon912 condeagustin · May 22, 2017 at 03:10 PM 0
Share

Please post this as a comment.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

viewDir changes with o.Normal 1 Answer

For a glass shader: How to "Fallback" completely 100% transparent that works in all device or that it do not render at all? 0 Answers

How to adapt this shader into a transparent one (alpha blend) 0 Answers

Quad vertex color shader 0 Answers

Shader inverts uv map only once, how to fix it? 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