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 /
This question was closed Dec 26, 2012 at 10:19 AM by lvictorino for the following reason:

Duplicate Question

avatar image
0
Question by lvictorino · Dec 25, 2012 at 10:15 AM · androidshadermask

Mask shader on Android devices

Hi,

I'm currently working on a 2D game. For some feedback purpose I want to use a mask on a quad in order to make some parts of the quad transparents. To achieve this I use two shaders (one for the quad in background, and one on another quad to use it as mask). Here they are:

The shader used on the background quad

 Shader "FeedbackBG" {
     Properties {
         _MainTex("Base (RGB)", 2D) = "" {}
     }
     SubShader {
         Tags {"Queue" = "Geometry+10"} 
         Pass {
             Cull Off
             Lighting Off
             ZWrite On
             ZTest LEqual
             SetTexture [_MainTex] {}
         }
     }
     Fallback "Diffuse"
 }

The one used on the mask

 Shader "TexturedMask" {
 
     Properties {
         _Mask ("Culling Mask", 2D) = "white" {}
     }
         
     SubShader {
         Cull Off
            Blend SrcAlpha OneMinusSrcAlpha
          
         Tags {"Queue" = "Geometry+10"} 
          Tags { "Queue" = "Transparent" }
         
         ColorMask 0
         ZWrite On
         ZTest Always
         Alphatest LEqual 0.5        
         
         Pass { 
             SetTexture[_Mask] {}
         }
     }
 }

The combination of both works perfectly when I test it thanks to the webplayer but on Android devices (Samsung Galaxy S2 and Nexus7) only the background is displayed and the mask is not applied. As I'm not really good in making shaders I wonder what I missed?

Any help would be appreciated. Thank you.

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 Seth-Bergman · Dec 26, 2012 at 08:23 AM 0
Share

don't know much about shader code.. but generally multiple shaders, transparency and particularly using a culling mask are costly to the gpu, and can cause many issues with different mobile devices (Though I believe I have used a similar setup successfully with my Galaxy S2... but the same build caused issues on other devices anyway..)

for maximum compatibility, at least avoid the AlphaTest part.. this "clip instruction" will DEFINITELY cause issues on some devices

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by lvictorino · Dec 26, 2012 at 10:19 AM

I've finally put another camera to produce the mask effect. As explained here : http://answers.unity3d.com/questions/56564/treating-an-animated-sprite-as-a-mask.html

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

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

Set default number/emails in a new text message/email sent via unity 0 Answers

Shader works in editor but not on Android 1 Answer

Sprite pixels problem on Android with mask 0 Answers

How do I mask an object with a soft invisible mask? 0 Answers

Why Do Android Devices Hate This Shader? 2 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