Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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
0
Question by amirnik · May 02, 2019 at 05:03 AM · issuepixelblackpixelateddepthmask

Black pixels on depth mask

Hi,

I have tried to use depth mask and create a hole in plane using the following tutorial:

YOUTUBE:Unity Sort-of-Tutorial: Making Fake Holes

 Shader "Masked/Mask" {
  
     SubShader {
         // Render the mask after regular geometry, but before masked geometry and
         // transparent things.
  
         Tags {"Queue" = "Geometry-1" }
  
         // Don't draw in the RGBA channels; just the depth buffer
  
         ColorMask 0
         ZWrite On
  
         // Do nothing specific in the pass:
  
         Pass {}
     }
 }

The issue is that transparent plane is shown as black pixels in some android phones.

I have tested the hole in Samsung S7 and Huawei Mate 20 Pro and it is working fine but same apk will produce black pixels, e.g. Samsung Galaxy S9. I am worried that this will be common to many other phones as well.

Any solution on how to fix this. Is this a bug on unity or it is something else?

alt text

Picture on top is the correct one and the bottom is how it looks like on Samsung Galaxy S9.

I found other issues which looks a like:

  • Depth Mask Shader becomes black and pixelated on Devices with Android 7.0 or higher

  • Black pixels in android build

hole.jpg (31.1 kB)
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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by screelman · Aug 08, 2019 at 07:23 AM

User petermauger on the Vuforia forums posted a variant on the shader that worked on my android devices. https://developer.vuforia.com/forum/unity-extension-technical-discussion/issue-depth-mask-shader-dont-work-ar-unity3d

 Shader "DepthMask" {
     SubShader {
         Tags { "RenderType"="Opaque" "Queue"="Geometry-1"}
         colormask 0
         Pass {
             Stencil {
                 Ref 2
                 Comp Greater
                 Pass Replace
             }
     
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             struct appdata {
                 float4 vertex : POSITION;
             };
             struct v2f {
                 float4 pos : SV_POSITION;
             };
             v2f vert(appdata v) {
                 v2f o;
                 o.pos = UnityObjectToClipPos(v.vertex);
                 return o;
             }
             half4 frag(v2f i) : SV_Target {
                 return half4(1,0,0,1);
             }
             ENDCG
         }
     }
 }
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 Delcasda · Sep 05, 2021 at 05:02 PM 0
Share

works perfect on 2020.3.17f as long as you remove vulkan

avatar image
1

Answer by georgelewising · Aug 07, 2019 at 04:44 PM

Suggestion: Try setting the "ZTest" flag to "Always" in the shader, it's a problem my studio has faced in the past with certain devices

Hope that helps!

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
avatar image
0

Answer by Pubesco · Dec 10, 2020 at 11:41 AM

Figured it out, set the camera clear flags to depth only

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
avatar image
0

Answer by gamefish · Jun 06, 2021 at 11:05 AM

alt textYear 2021 here, It's due to the default API in player settings of android is Vulkan, drag the OpenGLES 3 up to make it default API. For those of older unity version and graphics APIs, I guess it's also relative to graphics API bugs in unity, so try to change your graphics API might help


解决.png (279.2 kB)
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

108 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

Related Questions

How I do a Pixel Distort Shader 0 Answers

Unity 3D - Material or Shader issue 1 Answer

Unwanted 2d pixel after-image when moving 1 Answer

How to fix pixelated textures? 2 Answers

Everything is black except for the scene 1 Answer


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