Пример #1
0
 public void ResetFull()
 {
     Reset();
     GCommon.FillTexture(HeightMap, Color.clear);
     SetRegionDirty(GCommon.UnitRect);
     TerrainData.SetDirty(GTerrainData.DirtyFlags.GeometryTimeSliced);
 }
Пример #2
0
 public void ResetFull()
 {
     Reset();
     GCommon.FillTexture(AlbedoMap, Color.clear);
     GCommon.FillTexture(MetallicMap, Color.clear);
     UpdateLookupTextures();
     TerrainData.SetDirty(GTerrainData.DirtyFlags.Shading);
     UpdateMaterials();
 }
        private void Export()
        {
            RenderTexture rt = new RenderTexture(resolution, resolution, 24, RenderTextureFormat.ARGB32);

            GCommon.FillTexture(rt, Color.clear);

            Vector2[] uv        = targetMesh.uv;
            int[]     tris      = targetMesh.triangles;
            int       trisCount = tris.Length / 3;

            CreateLineMaterial();
            // Apply the line material
            lineMaterial.SetPass(0);

            RenderTexture.active = rt;
            GL.PushMatrix();
            GL.LoadOrtho();
            // Draw lines
            GL.Begin(GL.LINES);
            for (int i = 0; i < trisCount; ++i)
            {
                GL.Color(Color.black);
                Vector2 p0 = uv[tris[i * 3 + 0]];
                Vector2 p1 = uv[tris[i * 3 + 1]];
                Vector2 p2 = uv[tris[i * 3 + 2]];

                GL.Vertex3(p0.x, p0.y, 0);
                GL.Vertex3(p1.x, p1.y, 0);

                GL.Vertex3(p1.x, p1.y, 0);
                GL.Vertex3(p2.x, p2.y, 0);

                GL.Vertex3(p2.x, p2.y, 0);
                GL.Vertex3(p0.x, p0.y, 0);
            }
            GL.End();
            GL.PopMatrix();

            Texture2D tex = new Texture2D(resolution, resolution, TextureFormat.ARGB32, false);

            tex.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            tex.Apply();

            byte[] data = tex.EncodeToPNG();
            File.WriteAllBytes(string.Format("Assets/{0}_UV_{1}.png", targetMesh.name, resolution), data);
            GUtilities.DestroyObject(tex);

            RenderTexture.active = null;
            rt.Release();
            GUtilities.DestroyObject(rt);
        }
Пример #4
0
 public void ResetFull()
 {
     Reset();
     GCommon.FillTexture(MaskMap, Color.clear);
 }