Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
1
Question by Oruji · Oct 04, 2014 at 02:00 PM · shaderlightingmaterialshadow

Custom Sprite Shader Ignore Light

Hi!

The "Sprite-Default" shader used for 2D sprites ignores the built-in light.

I have "written" (modified a shader I found online) a custom shader that outlines a sprite and the outlining works well.

However, this custom shaders does not ignore the built-in light, which means the sprite is rendered differently from the other sprites that ignore the light.

What do I need to add to my custom shader to make it ignore the built in light?

I have looked a the Sprite-Default shader and I can't figure out what to do.

This is how my custom shader looks;

 Shader "Custom/Outline2D" {
     Properties 
     {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _OutLineSpread ("Outline Spread", Range(0,0.012)) = 0.007
         _Alpha ("Alpha", float) = 1
         _Color ("Color", Color) = (1,1,1,1)
     }
  
     SubShader
     {
         Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
         ZWrite On Blend One OneMinusSrcAlpha Cull Off
         LOD 110
  
         CGPROGRAM
         #pragma surface surf Lambert alpha
  
         struct Input 
         {
             float2 uv_MainTex;
             fixed4 color : COLOR;
         };
  
         sampler2D _MainTex;
         float _OutLineSpread;
         float _Alpha;
         fixed4 _Color;
  
         void surf(Input IN, inout SurfaceOutput o)
         {
             fixed4 mainColor =
             (tex2D(_MainTex, IN.uv_MainTex+float2(_OutLineSpread,_OutLineSpread))
             + tex2D(_MainTex, IN.uv_MainTex+float2(-_OutLineSpread,-_OutLineSpread))
             + tex2D(_MainTex, IN.uv_MainTex+float2(-_OutLineSpread,_OutLineSpread))
             + tex2D(_MainTex, IN.uv_MainTex+float2(_OutLineSpread,-_OutLineSpread)))
             * fixed4(_Color.r, _Color.g, _Color.b, _Alpha);
 
             mainColor = fixed4(1,1,1, mainColor.a);
             
             fixed4 addcolor = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
  
             if(addcolor.a > _Alpha - 0.05){
             mainColor = addcolor;}
  
             o.Albedo = mainColor.rgb;
             o.Alpha = mainColor.a;
         }
         ENDCG       
     }
 }





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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dreach913 · Mar 13, 2015 at 04:39 PM

Have you tried

 Lighting Off


Maybe thats what you are missing. I don't see it where you describe your cull mode.

Comment
Add comment · Share
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

"Interesting" Shader 2 Answers

Unity 3d Lights, Shadows and material of objects? 1 Answer

Glass shadow problem 3 Answers

Odd shadow effect, help! 1 Answer

Marmoset + Unity 4 vs Unity 5 Lighting 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