Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Z buffer problems on Apple7GPU (while working on SGX554 and 543)

Discussion in 'Editor & General Support' started by Fuegan, Oct 9, 2014.

  1. Fuegan


    Dec 5, 2012
    I am currently working on a painting tool for an iOS app. It is based on transforming the usert input to a spline and then creating a mesh following that spline.

    One of the features is painting with semi-transparent colors and it works like photoshop painter, meaning the alpha blending is done only for differents draws (the generated mesh is flat).

    I'm using this shader
    Code (CSharp):
    1. Properties
    2.     {
    3.         _Color ("Main Color", Color) = (1,1,1,1)
    4.     }
    6.     SubShader
    7.     {
    8.         Tags {"Queue"="Transparent"}
    9.         LOD 100
    11.         Pass
    12.         {
    13.             Zwrite On
    14.             ZTest Less
    15.             Blend SrcAlpha OneMinusSrcAlpha
    16.             Lighting Off
    17.             ColorMask RGB
    18.             CGPROGRAM
    20.             #pragma vertex vert
    21.             #pragma fragment frag
    23.             uniform fixed4 _Color;
    25.             struct appdata
    26.             {
    27.                 float4 vertex : POSITION;
    28.             };
    30.             struct v2f
    31.             {
    32.                 float4 pos : POSITION;
    33.             };
    35.             v2f vert (appdata v)
    36.             {
    37.                 v2f o;
    38.                 o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    39.                 return o;
    40.             }
    42.             half4 frag (v2f i) : COLOR
    43.             {
    44.                 return _Color;
    45.             }
    46.             ENDCG
    47.         }
    48.     }
    The point of this shader is to have a transparent_unlit writing in the z buffer (and displaying only if closer, not displaying if equal).

    This is an example of a generated mesh, all points are on a single plane. The mesh is not optimized but worked fine on iPad2.


    The color used has an oppacity of approximately 50%

    This is the wanted result (as I have on ipad 2,3,4)


    and this is what i have on ipad air, mini retina

    I had this kind of artifacts on all devices when my camera had a farclip of 20 (near 1) but when set to 100 I have the correct results (I supposed it has to do with float precision). I tried different camera settings but the only differences are where those artifacts are on screen.

    Here are the camera settings. The object is placed 19.8m in front of the camera.

    The same problems occur with forced openGLES 2.0 and 3.0.

    I found here that A7GPU uses different way to treat vectors so I guess my problem maybe has to do with it but I don't know if there is a solution.

    I'm stuck here, so if anyone knows what I did wrong or how can I make a workaround I would be glad.