Ejemplo n.º 1
0
 // internal data process
 private void _SetUV(int x, int y, int z, IntVector2 uv, int d = -1)
 {
     if (tex.GetPixel(uv.x, uv.y) == 0)
     {
         uv = EmptyUV;
     }
     if (pattern3D.Mode == RenderAlgo.Greedy)
     {
         if (d != -1)
         {
             pixelUV[(x | ((y | (z << 3)) << 3)) * 3 + d] = uv;
         }
         else
         {
             for (int i = 0; i < 3; i++)
             {
                 pixelUV[(x | ((y | (z << 3)) << 3)) * 3 + i] = uv;
             }
         }
     }
     else
     {
         pixelUV[(x | ((y | (z << 3)) << 3)) * 3] = uv;
     }
 }
Ejemplo n.º 2
0
        static public void Invalidate()
        {
            unsyncedSlices.Clear();
            int tailValue = tail;

            while (head != tailValue)
            {
                head = (head + 1) & MAX_SLOT_PER_FRAME;
                Slot slot = newRegSlots[head];
                newRegSlots[head] = null;

                TextureData tex = slot.tex;
                if (tex != null)
                {
                    var texture = texList[slot.slice];
                    for (int i = 0; i < tex.w; i++)
                    {
                        for (int j = 0; j < tex.h; j++)
                        {
                            if (tex.format == ColorFormat.Index)
                            {
                                Color c = new Color(0, 0, 0, tex.GetPixel(i, j) / 3f);
                                if (!slot.flip)
                                {
                                    texture.SetPixel(slot.x + i, slot.y + j, c);
                                }
                                else
                                {
                                    texture.SetPixel(slot.x + j, slot.y + i, c);
                                }
                            }
                            else
                            {
                                if (!slot.flip)
                                {
                                    texture.SetPixel(slot.x + i, slot.y + j, tex.GetColor(i, j));
                                }
                                else
                                {
                                    texture.SetPixel(slot.x + j, slot.y + i, tex.GetColor(i, j));
                                }
                            }
                        }
                    }
                    unsyncedSlices.Add(slot.slice);
                }
            }

            foreach (int i in unsyncedSlices)
            {
                texList[i].Apply();
                Graphics.CopyTexture(texList[i], 0, atlas, i);
            }
        }
Ejemplo n.º 3
0
 public void SetRect(TextureData tex, int x = 0, int y = 0)
 {
     if (CanCopyFrom(tex))
     {
         for (int i = 0; i < tex.w; i++)
         {
             for (int j = 0; j < tex.h; j++)
             {
                 SetPixel(x + i, y + j, tex.GetPixel(i, j));
             }
         }
     }
     else if (format == ColorFormat.Direct)
     {
         Debug.Log("Can not copy data between textures with different color formats.");
     }
 }