Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 TeddyDief · Oct 12, 2012 at 05:57 PM · shaderiosshadersiphoneshaderlab

VertexLit Hilight Shader - Flicker on iOS Problem

Hi everyone! I'm pretty new to shader coding, but I managed to hack together a Hilight Shader that uses the Mobile VertexLit as its core, plus the outline code from Toon Basic Outline (both of these are builtin shaders).

BUT, the outline "higlight" is flickering on iOS devices. Could someone who is wise to shaders please take a look at this short shader and tell me why I'd be getting a flicker please? Thank you!

 // Mobile VertexLit PLUS highlight outline
 Shader "Custom/Mobile VertexLit Hilight" {
 
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" { }
     }
 
     CGINCLUDE
     #include "UnityCG.cginc"
     
     struct appdata {
         half4 vertex : POSITION;
         float3 normal : NORMAL;
     };
 
     struct v2f {
         half4 pos : POSITION;
         half4 color : COLOR;
     };
         
     // Outline relative to camera distance. See standard Toon Basic Outline shader for non-relative version
     v2f vert(appdata v) {
         v2f o;
         o.pos = v.vertex;
         o.pos.xyz += v.normal.xyz * 0.0225;//_Outline
         o.pos = mul(UNITY_MATRIX_MVP, o.pos);
         o.color.r = 0; //0
         o.color.g = 0.377; //96
         o.color.b = 1; //255
         return o;
     }
 
     ENDCG
 
     SubShader {
         Tags { "RenderType"="Opaque" }
         UsePass "Custom/Mobile VertexLit Named/BASIC"
         Pass {
             Name "OUTLINE"
             Tags { "LightMode" = "Always" } //"Vertex" }
             Cull Front
             ZWrite On
             ColorMask RGB
             Blend SrcAlpha OneMinusSrcAlpha
 
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             half4 frag(v2f i) :COLOR { return i.color; }
             ENDCG
         }
     }
 
     Fallback "Mobile/VertexLit"
 }
 
Comment
Add comment · Show 2
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 TeddyDief · Oct 18, 2012 at 07:41 AM 0
Share

Has anyone else encountered flicker like this?

avatar image TeddyDief · Oct 19, 2012 at 07:07 PM 0
Share

Hey guys, sorry. Just want to bump again. Does anyone on Answers know shaders?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Sonaten · Oct 19, 2012 at 08:53 PM

Shaders are a quite complicated part of unity. And one important detail that probably won't solve your problem right away, is that you have chosen to code in CG. CG is the best supported language for unity, because it has a build in translater from CG to OpenGLSL. However this conversion is at it's best not fit for mobile devices. Efficiency will be higher when programming OpenGLSL in unity if only for Mac OS and mobile devices.

That said it might not at all be affecting your current output. But due to the translated code you might find that you do not have total control. I am not familiar with how well the translated shading works.

Hope this can bring some new pawns on the table.

Comment
Add comment · Show 2 · 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 TeddyDief · Oct 24, 2012 at 07:08 AM 0
Share

Thanks Niklas! This is good to know for future Shader program$$anonymous$$g. For now, I'm 'using CG because it's copy-pasted and tweaked from the only Unity highlighting shader (Toon Basic Highlight). If I get savvier I'll try this out..

Looking more into it now, I think my flicker might be caused by using low-poly models for mobile, but that doesn't solve my problem yet :(

avatar image Sonaten · Oct 24, 2012 at 01:03 PM 0
Share

Flickering could also be cause by faces "battling" in the depth buffer. One could imagine that this battle is handled less neatly on mobile devices.

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

10 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

Related Questions

Why does this shader show up black on iOS? 1 Answer

What shader blending modes don't work on iOS? 1 Answer

How to achive the same look? Which shaders to use? 2 Answers

Iphone Shader Reflection Map 0 Answers

Unity Advanced Shader 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