- Home /
Shader problem with Droid X2 and soft clipping
Hey,
Recently while working on our project we had our game working on the Droid X2 with 1 panel and with no clipping (we are using NGUI). But when we added a second panel that has soft clipping (for dragging objects on the screen). The game will only flicker the first screen that comes up when we start the game up. I believe it is a shader issue because it stopped flickering the first screen when I changed the graphics level from OpenGL ES 2.0 to 1.x but if we do that then the soft clipping will not work properly. Here is the soft clipping shader script that came with NGUI (we have not modified it):
Shader "Unlit/Transparent Colored (SoftClip)"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
}
SubShader
{
LOD 200
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Offset -1, -1
Fog { Mode Off }
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
float2 _ClipSharpness = float2(20.0, 20.0);
struct appdata_t
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 worldPos : TEXCOORD1;
};
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.texcoord = v.texcoord;
o.worldPos = TRANSFORM_TEX(v.vertex.xy, _MainTex);
return o;
}
fixed4 frag (v2f IN) : COLOR
{
// Softness factor
float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipSharpness;
// Sample the texture
fixed4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0);
return col;
}
ENDCG
}
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
LOD 100
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
ColorMask RGB
AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine Texture * Primary
}
}
}
}
Any help will be greatly appreciated.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Control basics - NGUI 1 Answer
android shader issue 1 Answer
How to make Custom Clipping in NGUI 1 Answer
Android repeated texture problem 1 Answer