Im facing a problem using Open GL. I have two images to show.
What i want to achieve is in the first image which is made in Cocos2d.
Second one i made with unity.
[36218-screen+shot+2014-12-01+at+3.28.28+pm.png|36218]
[36228-screen+shot+2014-12-01+at+3.30.15+pm.png|36228]
The Alpha shaded layer is made in GL. In cocos ihave the option to set Z. In unity when i Set/change the Z of the layer. It comes on top of everything. e.g a building z is 10 other is 5 and if i set the z of the layer to 6 i should come between but there are only two options either it appears on top of all or below which means we cant see it …
any solution to this ???
My code for this is
static void CreateLineMaterial(){
if( !lineMaterial ) {
lineMaterial = new Material( "Shader \"Lines/Colored Blended\" {" +
"SubShader { Pass { " +
" Blend SrcAlpha OneMinusSrcAlpha " +
" ZWrite Off Cull Off Fog { Mode Off } " +
" BindChannels {" +
" Bind \"vertex\", vertex Bind \"color\", color }" +
"} } }" );
lineMaterial.hideFlags = HideFlags.HideAndDontSave;
lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
}
}
public IsoShader (List<Vector2> p1, List<Vector2> p2, List<Vector2> p3, List<Vector2> p4)
{
boundaryPoint1 = new List<Vector2>(p1);
boundaryPoint2 = new List<Vector2>(p2);
boundaryPoint3 = new List<Vector2>(p3);
boundaryPoint4 = new List<Vector2>(p4);
}
void OnPostRender()
{
CreateLineMaterial();
lineMaterial.SetPass( 0 );
if(boundaryPoint1 != null)
{
GL.PushMatrix();
GL.Begin(GL.TRIANGLES);
GL.Color(color);
Draw();
GL.End();
GL.PopMatrix();
}
}
public float zIndex;
void Draw()
{
float scale = gState.world.isoView.transform.localScale.x;
for(int i=0; i<boundaryPoint1.Count; i++)
GL.Vertex3(scale * boundaryPoint1_.x + gState.world.isoView.transform.position.x, scale * boundaryPoint1*.y + gState.world.isoView.transform.position.y,zIndex);*_
* for(int i=0; i<boundaryPoint2.Count; i++)*
GL.Vertex3(scale * boundaryPoint2_.x + gState.world.isoView.transform.position.x, scale * boundaryPoint2*.y + gState.world.isoView.transform.position.y,zIndex);
for(int i=0; i<boundaryPoint3.Count; i++)
GL.Vertex3(scale * boundaryPoint3.x + gState.world.isoView.transform.position.x, scale * boundaryPoint3.y + gState.world.isoView.transform.position.y,zIndex);
for(int i=0; i<boundaryPoint4.Count; i++)
GL.Vertex3(scale * boundaryPoint4.x + gState.world.isoView.transform.position.x, scale * boundaryPoint4.y + gState.world.isoView.transform.position.y,zIndex);
}*
I dont know how to do this with GL. For now im moving onto Graphics Library in Unity. Create a mesh programatically. Assing Material/ Transparent Shader and then do the required task. But i read some where that GL Library is faster than Graphics library is that so ?
Regards
Usama_