Hi All.
I have a shader that I use to push some object in my game forward in the depth buffer so that they appear on top of other objects near by. Here’s the vert function I have.
FragmentInput vert ( VertexInput i )
{
FragmentInput o;
float4 worldPosition = mul ( unity_ObjectToWorld, i.vertex );
float4 cameraPos = float4(_WorldSpaceCameraPos, 1);
worldPosition = cameraPos + ((worldPosition - cameraPos) * _DepthScale);
float4 depth = mul ( UNITY_MATRIX_MVP, mul( unity_WorldToObject, worldPosition ) );
o.position = mul ( UNITY_MATRIX_MVP, i.vertex );
o.position.z = depth.z;
o.uv = TRANSFORM_TEX( i.texcoord, _MainTex );
o.color = i.color;
return o;
}
This use to work fine on all platforms but since I updated to Unity 5.5.1 I’ve found that it has stopped working on iOS.
Is this a bug in Unity? Can someone think of another way to get a similar effect?
I don’t want these objects to draw on top of everything, I just want to push them forward about 5-10 units in world space without their apparent size increasing.