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
1
Question by nj4242 · Dec 08, 2016 at 10:43 AM · shaderspritemobile devicesoutlineshading

This is not working!

This is my outline shader, which i am using, it doesnt seem to work in android after building it.

the shader: Shader "Hidden/OutlineEffect" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _LineColor ("Line Color", Color) = (1,1,1,.5)

     }
     SubShader 
     {
         Pass
         {
             Tags { "RenderType"="Opaque" }
             LOD 200
             ZTest Always
             ZWrite Off
             Cull Off
             
             CGPROGRAM
 
             #pragma vertex vert
             #pragma fragment frag
             #pragma target 3.0
             #include "UnityCG.cginc"
 
             sampler2D _MainTex;
             sampler2D _OutlineSource;
 
             struct v2f {
                float4 position : SV_POSITION;
                float2 uv : TEXCOORD0;
             };
             
             v2f vert(appdata_img v)
             {
                    v2f o;
                 o.position = mul(UNITY_MATRIX_MVP, v.vertex);
                 o.uv = v.texcoord;
                 
                    return o;
             }
 
             float _LineThicknessX;
             float _LineThicknessY;
             float _LineIntensity;
             half4 _LineColor1;
             half4 _LineColor2;
             half4 _LineColor3;
             int _FlipY;
             int _Dark;
             uniform float4 _MainTex_TexelSize;
 
             half4 frag (v2f input) : COLOR
             {    
                 float2 uv = input.uv;
                 if (_FlipY == 1)
                     uv.y = 1 - uv.y;
 
                 half4 originalPixel = tex2D(_MainTex,input.uv);
                 half4 outlineSource = tex2D(_OutlineSource, uv);
                                 
                 float h = .95f;
                 half4 outline = 0;
                 bool hasOutline = false;
 
                 half4 sample1 = tex2D(_OutlineSource, uv + float2(_LineThicknessX,0.0) * _MainTex_TexelSize.x * 1000.0f);
                 half4 sample2 = tex2D(_OutlineSource, uv + float2(-_LineThicknessX,0.0) * _MainTex_TexelSize.x * 1000.0f);
                 half4 sample3 = tex2D(_OutlineSource, uv + float2(.0,_LineThicknessY) * _MainTex_TexelSize.y * 1000.0f);
                 half4 sample4 = tex2D(_OutlineSource, uv + float2(.0,-_LineThicknessY) * _MainTex_TexelSize.y * 1000.0f);
                 
                 if(outlineSource.a < h)
                 {
                     if (sample1.r > h || sample2.r > h || sample3.r > h || sample4.r > h)
                     {
                         outline = _LineColor1 * _LineIntensity * _LineColor1.a;        
                         if (_Dark)
                             originalPixel *= 1 - _LineColor1.a;
                         hasOutline = true;
                     }
                     else if (sample1.g > h || sample2.g > h || sample3.g > h || sample4.g > h)
                     {
                         outline = _LineColor2 * _LineIntensity * _LineColor2.a;
                         if(_Dark)
                             originalPixel *= 1 - _LineColor2.a;
                         hasOutline = true;
                     }
                     else if (sample1.b > h || sample2.b > h || sample3.b > h || sample4.b > h)
                     {
                         outline = _LineColor3 * _LineIntensity * _LineColor3.a;
                         if (_Dark)
                             originalPixel *= 1 - _LineColor3.a;
                         hasOutline = true;
                     }
                 }                    
                     
                 //return outlineSource;        
                 if (_Dark)
                 {
                     if (hasOutline)
                         return originalPixel + outline;
                     else
                         return originalPixel;
                 }
                 else
                 {
                     if(hasOutline)
                         return originalPixel + outline * _LineColor1.a;
                     else
                         return originalPixel;
                 }
             }
             
             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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sackstand · Dec 08, 2016 at 04:12 PM

i think Shader Language 3 is not supported on Android.

Comment
Add comment · Show 1 · 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
avatar image nj4242 · Dec 08, 2016 at 06:09 PM 0
Share

$$anonymous$$aybe, I have two android tablets one with android 6.0, and 5.0, both failed to help me with shading outlines. However when I tried it on my Nexus 5, it worked just as in my editor. Is there in anyway, I could use it on my tabs, I really need to make my shaders compatible for all devices. What'dya suggest? $$anonymous$$aybe is there a way to ensure or convert the following shader code into supported shader language ?

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

96 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

Related Questions

Combine Shaders 0 Answers

Shader Edit Help: 2D Outline Coloring 2 Answers

Invert background in shadergraph 0 Answers

Culling part of a sprite in Sprite Manager 2 1 Answer

Silhouette Toon Shader 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