コード例 #1
0
        private void GenerateQuadtree()
        {
            if (Input.GetKeyDown(KeyCode.Space) == false)
            {
                return;
            }

            int width  = SourceImage.width;
            int height = SourceImage.height;

            quadtreeTexture            = new Texture2D(width, height, TextureFormat.RGB24, false);
            quadtreeTexture.filterMode = FilterMode.Point;

            quadtree = new QuadtreeTextureCompression(new Rectangle(width / 2, height / 2, width / 2, height / 2),
                                                      LaplacianMap, SourceImage);

            ClearQuadtreeTexture();

            quadtree.Show(quadtreeTexture);

            MyRenderer.material.mainTexture = quadtreeTexture;

            Subdivide();

            quadtreeTexture.Apply();

            Debug.Log("Compressed texture Size: " + quadtree.CompressedTextureSize());
        }
コード例 #2
0
        public void Show(Texture2D texture)
        {
            Color color = Color.cyan;

            for (float x = boundary.West; x < boundary.East; x += 1f)
            {
                texture.SetPixel((int)x, (int)boundary.South, color);
                texture.SetPixel((int)x, (int)boundary.North, color);
            }

            for (float y = boundary.South; y < boundary.North; y += 1f)
            {
                texture.SetPixel((int)boundary.West, (int)y, color);
                texture.SetPixel((int)boundary.East, (int)y, color);
            }

            if (divided == true)
            {
                northEast.Show(texture);
                northWest.Show(texture);

                southEast.Show(texture);
                southWest.Show(texture);
            }
        }
コード例 #3
0
        private void Subdivide()
        {
            quadtree.Subdivide();

            quadtree.Show(quadtreeTexture);
        }