HI All, I have a question related to OpenGL in unity. I need to paint in 3D and right now it is painting all the triangles superimposed mixing 3D position with 2D rendering. How can I paint in 3D using this unity openGL technique? Here the code: Code (CSharp): public class CameraPostRender : MonoBehaviour { private static Material m; private GameObject g; GraphModel gm; private float myConnectionThreshold; void Start () { gm = (GameObject.Find ("ConnectomeRoot").GetComponent<Connectome> ()).gm; m = new Material (Shader.Find ("Particles/Alpha Blended")); g = new GameObject ("g"); myConnectionThreshold = 1.51f; } void Update () { } void OnPostRender () { m.SetPass (0); GL.PushMatrix (); GL.MultMatrix (g.transform.transform.localToWorldMatrix); GL.Begin (GL.TRIANGLES); for (int i = 1; i <= gm.nodeCount; i++) { if (gm.Nodes [i].weight_node > myConnectionThreshold) { foreach (int n in gm.Nodes [i].EdgesFrom) { int particle_from = gm.Edges [n].NodeFrom; int particle_to = gm.Edges [n].NodeTo; float lineSize = Mathf.Clamp (gm.Edges [n].Weight * 5.5f, 0.09f, 1.0f); GL.Color (new Color (gm.Nodes [particle_from].myColor.r, gm.Nodes [particle_from].myColor.g, gm.Nodes [particle_from].myColor.b, 0.05f)); GL.Vertex3 (gm.Nodes [particle_from].newPosition.x, gm.Nodes [particle_from].newPosition.y, gm.Nodes [particle_from].newPosition.z); GL.Vertex3 (gm.Nodes [particle_to].newPosition.x, gm.Nodes [particle_to].newPosition.y, gm.Nodes [particle_to].newPosition.z); } } } GL.End (); GL.PopMatrix (); } }
Well, you've put all your code into POST RENDER, so the GL stuff is drawn over the top of everything else.