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 /
  • Help Room /
avatar image
1
Question by Josepht45 · Nov 27, 2017 at 09:24 PM · iosshadersshader programmingoutlinebuilds

Custom Outline Shader acting weird on iOS builds.

Hello! We are using a custom outline shader in our project. It works great in the editor, on android, and on older iOS devices, but it seems on iOS 11 devices, the outline on the shader appears to disappear. It clearly still has the same shader on, but almost appears as if the values are getting adjusted in the builds or something strange.


Does anyone know anything about why this would happen? I'll shader the shader code below. I did not write it.

Any help is greatly appreciated!


 Shader "Custom/OutlineShader" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _Outline("Outline Thickness", Range(0.0, 0.3)) = 0.002
         _OutlineColor("Outline Color", Color) = (0,0,0,1)
     }
  
     CGINCLUDE
     #include "UnityCG.cginc"
  
     sampler2D _MainTex;
     half4 _MainTex_ST;
  
     half _Outline;
     half4 _OutlineColor;
  
     struct appdata {
         half4 vertex : POSITION;
         half4 uv : TEXCOORD0;
         half3 normal : NORMAL;
         fixed4 color : COLOR;
     };
  
     struct v2f {
         half4 pos : POSITION;
         half2 uv : TEXCOORD0;
         fixed4 color : COLOR;
     };
     ENDCG
  
     SubShader 
     {
         Tags {
             "RenderType"="Opaque"
             "Queue" = "Transparent"
         }
         
         Pass{
             Name "OUTLINE"
  
             Cull Front
  
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
  
             v2f vert(appdata v)
             {
                 v2f o;
                 o.pos = UnityObjectToClipPos(v.vertex);
                 half3 norm = mul((half3x3)UNITY_MATRIX_IT_MV, v.normal);
                 half2 offset = TransformViewToProjection(norm.xy);
                 o.pos.xy += offset * o.pos.z * _Outline;
                 o.color = _OutlineColor;
                 return o;
             }
  
             fixed4 frag(v2f i) : COLOR
             {
                 fixed4 o;
                 o = i.color;
                 return o;
             }
             ENDCG
         }
  
         Pass 
         {
             Name "TEXTURE"
  
             Cull Back
             ZWrite On
             ZTest LEqual
  
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
  
             v2f vert(appdata v)
             {
                 v2f o;
                 o.pos = UnityObjectToClipPos(v.vertex);
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 o.color = v.color;
                 return o;
             }
  
             fixed4 frag(v2f i) : COLOR 
             {
                 fixed4 o;
                 o = tex2D(_MainTex, i.uv.xy);
                 return o;
             }
             ENDCG
         }
     } 
 }
Comment
Add comment · Show 1
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 daniil_iisus · Jul 14, 2018 at 01:14 AM 0
Share

Hi there, Have you found a solution?, im having the same problem over here. cheers. [Edit] I also found your reddit post, the shader files U shared aren't available anymore, I know how to write shaders, im not highly skilled since im still a noob in CG but with your files & experience we may find a suitable solution.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by daniil_iisus · Jul 15, 2018 at 12:53 AM

Well I've found a solution, and it's thanks to you @Josepht45 for sharing that the shader works fine under older iOS versions, the most relevant factor was the Metal Graphics API, I supposed its shaders work differently from OpenGL's, so to fix shaders working weird in iOS you need to be working with macOS and in Unity go to;


Edit->Project Settings->Player, under the iOS tab select; Other, and enable; Metal Editor Support* and Metal API Validation*


Unity should restart using the Metal API and render your scene identical as it would in your IOS device, use your shader "Properties" Block to parametrize its values and play around until you achieve the desired look.


In your case which is very similar to mine just modify:

  _Outline("Outline Thickness", Range(0.0, 0.3)) = 0.002

To

 _Outline ("Outline width", Range (.002, 0.1)) = .005

Apparently Metal draws the line very thin basically invisible so just use a greater value for thickness in your IOS builds.

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

154 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

Related Questions

why outline is drawed only on front side of skinned mesh render 1 Answer

Why do dots appear on pbr materials when I use iOS Platform module?, 1 Answer

Help with Base Color + Outline shader! 0 Answers

Custom Shader IOS Build 0 Answers

Anisotropic Shader, How Does It Works? Help 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