2016-11-28 42 views
0

我在两个平面上有此着色器。它使它们透明,只显示它们收到的阴影。然而,在iOS上编译和运行它会使阴影消失,我不知道为什么。有任何想法吗?在iOS中未显示Unity CG“影子捕捉器”着色器

Shader "FX/Matte Shadow" { 

Properties { 

    _Color ("Main Color", Color) = (1,1,1,1) 

    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 

    _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 

} 


SubShader { 

    Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 

    LOD 200 

    Blend Zero SrcColor 


CGPROGRAM 

    #pragma surface surf ShadowOnly alphatest:_Cutoff 


fixed4 _Color; 

struct Input { 

    float2 uv_MainTex; 

}; 


inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten) 

{ 

    fixed4 c; 


    c.rgb = s.Albedo*atten; 

    c.a = s.Alpha; 

    return c; 

} 


void surf (Input IN, inout SurfaceOutput o) { 

    fixed4 c = _Color; 

    o.Albedo = c.rgb; 

    o.Alpha = 1; 

} 

ENDCG 

} 

Fallback "Transparent/Cutout/VertexLit" 

} 
+0

你真的不应该在IOS中使用alphatest着色器。它们导致很多填充率问题,这也可能是这种情况。 –

回答

0

这个着色器工作得很好。在iOS设备上测试AR-App时,我的问题一直是很远的裁剪平面,它们不会一直走到墙边。哎呀。