- Home /
Pages overlapping problem
I'm making flipping book on Megafiers. I need to use some transparent elements on pages, so I put Transparent/Diffuse shader on materials. Then there was a overlapping problem. Back sides of the pages became drawn on top of the front side.
I've tried different settings for textures and different shaders with transparency, but nothing helps.
1.jpg
(211.2 kB)
Comment
Answer by Jona-Marklund · Aug 28, 2013 at 02:52 AM
Have you tried using a cutoff shader? Should remove the z-fighting, here's a simple one that doesn't cull the back of your pages.
Shader "JM/VertexColoCutoff"
{
//Jona Marklund 28th August 2013
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0, 1)) = 0.8
}
SubShader
{
Pass
{
Cull Off //Could be set to Back
AlphaTest Greater [_Cutoff]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform sampler2D _MainTex;
uniform fixed _Cutoff;
struct appdata
{
half4 position : POSITION;
fixed4 texcoord : TEXCOORD;
};
struct v2f
{
half4 position : POSITION;
fixed4 texcoord : TEXCOORD0;
};
v2f vert( appdata IN )
{
v2f OUT;
OUT.position = mul(UNITY_MATRIX_MVP, IN.position);
OUT.texcoord = IN.texcoord;
return OUT;
}
fixed4 frag(v2f IN) : COLOR
{
fixed4 colorOut = tex2D(_MainTex, float2(IN.texcoord));
return colorOut;
}
ENDCG
}
}
}
Hope that works. Best Regards Jona