예제 #1
0
        static unsafe void Reset(MyGeneratedTexture tex, byte[] data, int nchannels)
        {
            if (data == null)
            {
                tex.Reset(null);
            }
            else
            {
                fixed(byte *dptr = data)
                {
                    int numMiplevels = tex.NumMipLevels;

                    DataBox[] dataBox = new DataBox[numMiplevels];

                    int width  = tex.Size.X;
                    int height = tex.Size.Y;

                    int offset = 0;

                    for (int i = 0; i < numMiplevels; ++i)
                    {
                        dataBox[i].DataPointer = new IntPtr(dptr + offset);
                        dataBox[i].RowPitch    = width * nchannels;
                        offset += width * height * nchannels;

                        width  >>= 1;
                        height >>= 1;
                    }
                    tex.Reset(dataBox);
                }
            }
        }
예제 #2
0
        void CreateR32G32B32A32_Float(MyGeneratedTexture tex, string name, Vector2I resolution, Vector4[] colors)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R32G32B32A32_Float;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Height = width;
            desc.Width  = height;
            tex.Init(name, desc, new Vector2I(width, height), width * height * 16);

            if (colors != null)
            {
                float[] values = new float[width * height * 4];

                int inOffset  = 0;
                int outOffset = 0;
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        values[outOffset++] = colors[inOffset].X;
                        values[outOffset++] = colors[inOffset].Y;
                        values[outOffset++] = colors[inOffset].Z;
                        values[outOffset++] = colors[inOffset].W;
                        inOffset++;
                    }
                }

                Reset(tex, values, width, 4);
            }
        }
예제 #3
0
        static unsafe void Reset(MyGeneratedTexture tex, int data)
        {
            void *ptr = &data;

            m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
            m_tmpDataBoxArray1[0].RowPitch    = 4;
            tex.Reset(m_tmpDataBoxArray1);
        }
예제 #4
0
 static unsafe void Reset(MyGeneratedTexture tex, float[] data, int rowlength, int nchannels)
 {
     fixed(float *dptr = data)
     {
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
         m_tmpDataBoxArray1[0].RowPitch    = rowlength * nchannels * 4;
         tex.Reset(m_tmpDataBoxArray1);
     }
 }
예제 #5
0
        void CreateR_1x1(MyGeneratedTexture tex, string name, byte data)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8_UNorm;
            desc.Height = 1;
            desc.Width  = 1;
            tex.Init(name, desc, new Vector2I(1, 1), 1);
            Reset(tex, data);
        }
예제 #6
0
        static unsafe void ResetCube(MyGeneratedTexture tex, int data)
        {
            void *ptr = &data;

            for (int i = 0; i < 6; i++)
            {
                m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr);
                m_tmpDataBoxArray6[i].RowPitch    = 4;
            }
            tex.Reset(m_tmpDataBoxArray6);
        }
예제 #7
0
        void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8G8B8A8_UNorm;
            desc.Height = 1;
            desc.Width  = 1;
            tex.Init(name, desc, new Vector2I(1, 1), 4);
            int data = color.ToRgba();

            Reset(tex, data);
        }
        unsafe void CreateR_1x1(MyGeneratedTexture tex, string name, byte data)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8_UNorm;
            desc.Height = 1;
            desc.Width  = 1;
            void *ptr = &data;

            m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
            m_tmpDataBoxArray1[0].RowPitch    = 1;
            CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 1);
        }
예제 #9
0
        void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format      = Format.R8G8B8A8_UNorm;
            desc.Height      = 1;
            desc.Width       = 1;
            desc.ArraySize   = 6;
            desc.OptionFlags = ResourceOptionFlags.TextureCube;
            tex.Init(name, desc, new Vector2I(1, 1), 4);
            int data = color.ToRgba();

            ResetCube(tex, data);
        }
        unsafe void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8G8B8A8_UNorm;
            desc.Height = 1;
            desc.Width  = 1;
            int   data = color.ToRgba();
            void *ptr  = &data;

            m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
            m_tmpDataBoxArray1[0].RowPitch    = 4;
            CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 4);
        }
예제 #11
0
        void CreateR(MyGeneratedTexture tex, string name, Vector2I resolution, byte[] data, bool userTexture = false, int numMipLebels = 1)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Usage  = userTexture ? ResourceUsage.Default : ResourceUsage.Immutable;
            desc.Format = Format.R8_UNorm;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Height    = height;
            desc.Width     = width;
            desc.MipLevels = numMipLebels;
            tex.Init(name, desc, new Vector2I(width, height), width * height);
            if (data != null)
            {
                Reset(tex, data, 1);
            }
        }
        unsafe void CreateR(MyGeneratedTexture tex, string name, Vector2I resolution, byte[] data)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8_UNorm;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Height = height;
            desc.Width  = width;
            fixed(byte *dptr = data)
            {
                m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
                m_tmpDataBoxArray1[0].RowPitch    = width;
                CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width * height);
                m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
            }
        }
예제 #13
0
        void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, byte[] data, bool userTexture = false, int numMipLevels = 1)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Usage  = userTexture ? ResourceUsage.Default : ResourceUsage.Immutable;
            desc.Format = srgb ? Format.R8G8B8A8_UNorm_SRgb : Format.B8G8R8A8_UNorm;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Width     = width;
            desc.Height    = height;
            desc.MipLevels = numMipLevels;
            tex.Init(name, desc, new Vector2I(width, height), width * height * 4);
            if (data != null)
            {
                Debug.Assert(width * height * 4 == data.Length, "Wrong data array size for RGBA texture");
                Reset(tex, data, 4);
            }
        }
        unsafe void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format      = Format.R8G8B8A8_UNorm;
            desc.Height      = 1;
            desc.Width       = 1;
            desc.ArraySize   = 6;
            desc.OptionFlags = ResourceOptionFlags.TextureCube;
            int   data = color.ToRgba();
            void *ptr  = &data;

            for (int i = 0; i < 6; i++)
            {
                m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr);
                m_tmpDataBoxArray6[i].RowPitch    = 4;
            }

            CreateTexture(tex, name, desc, m_tmpDataBoxArray6, new Vector2I(1, 1), 4);
        }
예제 #15
0
        void CreateCheckerRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color v1, Color v2)
        {
            int width  = resolution.X;
            int height = resolution.Y;

            Color[] rawData = new Color[width * height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color v = v1;
                    if (((y + x) & 1) == 0)
                    {
                        v = v2;
                    }
                    rawData[y * width + x] = v;
                }
            }
            CreateRGBA(tex, name, resolution, false, rawData);
        }
예제 #16
0
        unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, Color[] colors, int numMipLevels = 1)
        {
            int width  = resolution.X;
            int height = resolution.Y;

            byte[] rawData = new byte[width * height * 4];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int   offset       = x + y * width;
                    Color currentColor = colors[offset];
                    rawData[offset * 4 + 0] = currentColor.R;
                    rawData[offset * 4 + 1] = currentColor.G;
                    rawData[offset * 4 + 2] = currentColor.B;
                    rawData[offset * 4 + 3] = currentColor.A;
                }
            }
            CreateRGBA(tex, name, resolution, srgb, rawData);
        }
예제 #17
0
        void CreateCheckerR(MyGeneratedTexture tex, string name, Vector2I resolution, byte v1, byte v2)
        {
            int width  = resolution.X;
            int height = resolution.Y;

            byte[] ditherData = new byte[width * height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < height; x++)
                {
                    byte v = v1;
                    if (((y + x) & 1) == 0)
                    {
                        v = v2;
                    }
                    ditherData[y * width + x] = v;
                }
            }
            CreateR(tex, name, resolution, ditherData);
        }
예제 #18
0
 unsafe void CreateR32G32B32A32_Float(MyGeneratedTexture tex, string name, Vector2I resolution, Vector4[] colors)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R32G32B32A32_Float;
     int width = resolution.X;
     int height = resolution.Y;
     desc.Height = width;
     desc.Width = height;
     float[] values = new float[width * height * 4];
     
     int inOffset = 0;
     int outOffset = 0;
     for (int y = 0; y < height; y++)
         for (int x = 0; x < width; x++)
         {
             values[outOffset++] = colors[inOffset].X;
             values[outOffset++] = colors[inOffset].Y;
             values[outOffset++] = colors[inOffset].Z;
             values[outOffset++] = colors[inOffset].W;
             inOffset++;
         }
     fixed (float* dptr = values)
     {
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
         m_tmpDataBoxArray1[0].RowPitch = width * 16;
         CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width * height * 16);
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
     }
 }
예제 #19
0
 unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color[] colors)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8G8B8A8_UNorm;
     int width = resolution.X;
     int height = resolution.Y;
     desc.Height = width;
     desc.Width = height;
     byte[] rawData = new byte[width * height * 4];
     for (int y = 0; y < height; y++)
         for (int x = 0; x < width; x++)
         {
             int offset = x + y*width;
             Color currentColor = colors[offset];
             rawData[offset*4 + 0] = currentColor.R;
             rawData[offset*4 + 1] = currentColor.G;
             rawData[offset*4 + 2] = currentColor.B;
             rawData[offset*4 + 3] = currentColor.A;
         }
     fixed (byte* dptr = rawData)
     {
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
         m_tmpDataBoxArray1[0].RowPitch = width*4;
         CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width*height*4);
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
     }
 }
예제 #20
0
 unsafe void CreateR(MyGeneratedTexture tex, string name, Vector2I resolution, byte[] data)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8_UNorm;
     int width = resolution.X;
     int height = resolution.Y;
     desc.Height = height;
     desc.Width = width;
     fixed (byte* dptr = data)
     {
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
         m_tmpDataBoxArray1[0].RowPitch = width;
         CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width * height);
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
     }
 }
예제 #21
0
        unsafe void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
        {
            Texture2DDescription desc = m_descDefault;
            desc.Format = Format.R8G8B8A8_UNorm;
            desc.Height = 1;
            desc.Width = 1;
            desc.ArraySize = 6;
            desc.OptionFlags = ResourceOptionFlags.TextureCube;
            int data = color.ToRgba();
            void* ptr = &data;
            for (int i = 0; i < 6; i++)
            {
                m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr);
                m_tmpDataBoxArray6[i].RowPitch = 4;
            }

            CreateTexture(tex, name, desc, m_tmpDataBoxArray6, new Vector2I(1, 1), 4);
        }
예제 #22
0
 unsafe void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8G8B8A8_UNorm;
     desc.Height = 1;
     desc.Width = 1;
     int data = color.ToRgba();
     void* ptr = &data;
     m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
     m_tmpDataBoxArray1[0].RowPitch = 4;
     CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 4);
 }
예제 #23
0
        void CreateR32G32B32A32_Float(MyGeneratedTexture tex, string name, Vector2I resolution, Vector4[] colors)
        {
            Texture2DDescription desc = m_descDefault;
            desc.Format = Format.R32G32B32A32_Float;
            int width = resolution.X;
            int height = resolution.Y;
            desc.Height = width;
            desc.Width = height;
            tex.Init(name, desc, new Vector2I(width, height), width * height * 16);

            if (colors != null)
            {
                float[] values = new float[width * height * 4];

                int inOffset = 0;
                int outOffset = 0;
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        values[outOffset++] = colors[inOffset].X;
                        values[outOffset++] = colors[inOffset].Y;
                        values[outOffset++] = colors[inOffset].Z;
                        values[outOffset++] = colors[inOffset].W;
                        inOffset++;
                    }
                }

                Reset(tex, values, width, 4);
            }
        }
예제 #24
0
 unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, Color[] colors, int numMipLevels = 1)
 {
     int width = resolution.X;
     int height = resolution.Y;
     byte[] rawData = new byte[width * height * 4];
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             int offset = x + y * width;
             Color currentColor = colors[offset];
             rawData[offset * 4 + 0] = currentColor.R;
             rawData[offset * 4 + 1] = currentColor.G;
             rawData[offset * 4 + 2] = currentColor.B;
             rawData[offset * 4 + 3] = currentColor.A;
         }
     }
     CreateRGBA(tex, name, resolution, srgb, rawData);
 }
 void CreateTexture(MyGeneratedTexture tex, string name, Texture2DDescription desc, DataBox[] dataBoxes, Vector2I size, int bytes, bool enableDxInitialisation = true)
 {
     tex.Init(name, desc, dataBoxes, size, bytes, enableDxInitialisation);
 }
예제 #26
0
 static unsafe void ResetCube(MyGeneratedTexture tex, int data)
 {
     void* ptr = &data;
     for (int i = 0; i < 6; i++)
     {
         m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr);
         m_tmpDataBoxArray6[i].RowPitch = 4;
     }
     tex.Reset(m_tmpDataBoxArray6);
 }
예제 #27
0
 void CreateR(MyGeneratedTexture tex, string name, Vector2I resolution, byte[] data, bool userTexture = false, int numMipLebels = 1)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Usage = userTexture ? ResourceUsage.Default : ResourceUsage.Immutable;
     desc.Format = Format.R8_UNorm;
     int width = resolution.X;
     int height = resolution.Y;
     desc.Height = height;
     desc.Width = width;
     desc.MipLevels = numMipLebels;
     tex.Init(name, desc, new Vector2I(width, height), width * height);
     if (data != null)
         Reset(tex, data, 1);
 }
예제 #28
0
 void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8G8B8A8_UNorm;
     desc.Height = 1;
     desc.Width = 1;
     tex.Init(name, desc, new Vector2I(1, 1), 4);
     int data = color.ToRgba();
     Reset(tex, data);
 }
예제 #29
0
        static unsafe void Reset(MyGeneratedTexture tex, byte[] data, int nchannels)
        {
            if (data == null)
            {
                tex.Reset(null);
            }
            else
            {
                fixed (byte* dptr = data)
                {
                    int numMiplevels = tex.NumMipLevels;
                    DataBox[] dataBox = new DataBox[numMiplevels];

                    int width = tex.Size.X;
                    int height = tex.Size.Y;

                    int offset = 0;
                    for (int i = 0; i < numMiplevels; ++i)
                    {
                        dataBox[i].DataPointer = new IntPtr(dptr + offset);
                        dataBox[i].RowPitch = width * nchannels;
                        offset += width * height * nchannels;

                        width >>= 1;
                        height >>= 1;
                    }
                    tex.Reset(dataBox);
                }
            }
        }
예제 #30
0
 unsafe void CreateCheckerR(MyGeneratedTexture tex, string name, Vector2I resolution, byte v1, byte v2)
 {
     int width = resolution.X;
     int height = resolution.Y;
     byte[] ditherData = new byte[width * height];
     for (int y = 0; y < height; y++)
         for (int x = 0; x < height; x++)
         {
             byte v = v1;
             if (((y + x) & 1) == 0)
                 v = v2;
             ditherData[y*width + x] = v;
         }
     CreateR(tex, name, resolution, ditherData);
 }
예제 #31
0
 static unsafe void Reset(MyGeneratedTexture tex, int data)
 {
     void* ptr = &data;
     m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
     m_tmpDataBoxArray1[0].RowPitch = 4;
     tex.Reset(m_tmpDataBoxArray1);
 }
예제 #32
0
 unsafe void CreateCheckerRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color v1, Color v2)
 {
     int width = resolution.X;
     int height = resolution.Y;
     Color[] rawData = new Color[width * height];
     for (int y = 0; y < height; y++)
         for (int x = 0; x < width; x++)
         {
             Color v = v1;
             if (((y + x) & 1) == 0)
                 v = v2;
             rawData[y * width + x] = v;
         }
     CreateRGBA(tex, name, resolution, rawData);
 }
예제 #33
0
 void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, byte[] data, bool userTexture = false, int numMipLevels = 1)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Usage = userTexture ? ResourceUsage.Default : ResourceUsage.Immutable;
     desc.Format = srgb ? Format.R8G8B8A8_UNorm_SRgb : Format.B8G8R8A8_UNorm;
     int width = resolution.X;
     int height = resolution.Y;
     desc.Width = width;
     desc.Height = height;
     desc.MipLevels = numMipLevels;
     tex.Init(name, desc, new Vector2I(width, height), width * height * 4);
     if (data != null)
     {
         Debug.Assert(width * height * 4 == data.Length, "Wrong data array size for RGBA texture");
         Reset(tex, data, 4);
     }
 }
예제 #34
0
 void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8G8B8A8_UNorm;
     desc.Height = 1;
     desc.Width = 1;
     desc.ArraySize = 6;
     desc.OptionFlags = ResourceOptionFlags.TextureCube;
     tex.Init(name, desc, new Vector2I(1, 1), 4);
     int data = color.ToRgba();
     ResetCube(tex, data);
 }
예제 #35
0
 void CreateTexture(MyGeneratedTexture tex, string name, Texture2DDescription desc, DataBox[] dataBoxes, Vector2I size, int bytes, bool enableDxInitialisation = true)
 {
     tex.Init(name, desc, dataBoxes, size, bytes, enableDxInitialisation);
 }
예제 #36
0
 unsafe void CreateR_1x1(MyGeneratedTexture tex, string name, byte data)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8_UNorm;
     desc.Height = 1;
     desc.Width = 1;
     void* ptr = &data;
     m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr);
     m_tmpDataBoxArray1[0].RowPitch = 1;
     CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 1);
 }
예제 #37
0
 static unsafe void Reset(MyGeneratedTexture tex, float[] data, int rowlength, int nchannels)
 {
     fixed (float* dptr = data)
     {
         m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
         m_tmpDataBoxArray1[0].RowPitch = rowlength * nchannels * 4;
         tex.Reset(m_tmpDataBoxArray1);
     }
 }
        unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color[] colors)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R8G8B8A8_UNorm;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Height = width;
            desc.Width  = height;
            byte[] rawData = new byte[width * height * 4];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int   offset       = x + y * width;
                    Color currentColor = colors[offset];
                    rawData[offset * 4 + 0] = currentColor.R;
                    rawData[offset * 4 + 1] = currentColor.G;
                    rawData[offset * 4 + 2] = currentColor.B;
                    rawData[offset * 4 + 3] = currentColor.A;
                }
                fixed(byte *dptr = rawData)
                {
                    m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
                    m_tmpDataBoxArray1[0].RowPitch    = width * 4;
                    CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width * height * 4);
                    m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
                }
        }

        unsafe void CreateR32G32B32A32_Float(MyGeneratedTexture tex, string name, Vector2I resolution, Vector4[] colors)
        {
            Texture2DDescription desc = m_descDefault;

            desc.Format = Format.R32G32B32A32_Float;
            int width  = resolution.X;
            int height = resolution.Y;

            desc.Height = width;
            desc.Width  = height;
            float[] values = new float[width * height * 4];

            int inOffset  = 0;
            int outOffset = 0;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    values[outOffset++] = colors[inOffset].X;
                    values[outOffset++] = colors[inOffset].Y;
                    values[outOffset++] = colors[inOffset].Z;
                    values[outOffset++] = colors[inOffset].W;
                    inOffset++;
                }
                fixed(float *dptr = values)
                {
                    m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr);
                    m_tmpDataBoxArray1[0].RowPitch    = width * 16;
                    CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width * height * 16);
                    m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null);
                }
        }

        unsafe void CreateCheckerR(MyGeneratedTexture tex, string name, Vector2I resolution, byte v1, byte v2)
        {
            int width  = resolution.X;
            int height = resolution.Y;

            byte[] ditherData = new byte[width * height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < height; x++)
                {
                    byte v = v1;
                    if (((y + x) & 1) == 0)
                    {
                        v = v2;
                    }
                    ditherData[y * width + x] = v;
                }
            }
            CreateR(tex, name, resolution, ditherData);
        }

        unsafe void CreateCheckerRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color v1, Color v2)
        {
            int width  = resolution.X;
            int height = resolution.Y;

            Color[] rawData = new Color[width * height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color v = v1;
                    if (((y + x) & 1) == 0)
                    {
                        v = v2;
                    }
                    rawData[y * width + x] = v;
                }
            }
            CreateRGBA(tex, name, resolution, rawData);
        }

        unsafe void CreateAllTextures()
        {
            CreateRGBA_1x1((MyGeneratedTexture)ZeroTex, "Zero", new Color(0, 0, 0, 0));
            CreateRGBA_1x1((MyGeneratedTexture)PinkTex, "Pink", new Color(255, 0, 255));
            CreateRGBA_1x1((MyGeneratedTexture)ReleaseMissingNormalGlossTex, "ReleaseMissingNormalGloss", new Color(127, 127, 255, 0));
            CreateR_1x1((MyGeneratedTexture)ReleaseMissingAlphamaskTex, "ReleaseMissingAlphamask", 255);
            CreateRGBA_1x1((MyGeneratedTexture)ReleaseMissingExtensionTex, "ReleaseMissingExtension", new Color(255, 0, 0, 0));
            CreateCubeRGBA_1x1((MyGeneratedTexture)ReleaseMissingCubeTex, "ReleaseMissingCube", new Color(0, 0, 0, 0));
            CreateCheckerRGBA((MyGeneratedTexture)DebugMissingNormalGlossTex, "DebugMissingNormalGloss", new Vector2I(8, 8), new Color(91, 0, 217, 0), new Color(217, 0, 217, 255));
            CreateCheckerR((MyGeneratedTexture)DebugMissingAlphamaskTex, "DebugMissingAlphamask", new Vector2I(8, 8), 255, 0);
            CreateCheckerRGBA((MyGeneratedTexture)DebugMissingExtensionTex, "DebugMissingExtension", new Vector2I(8, 8), new Color(255, 255, 0, 0), new Color(0, 0, 0, 0));
            CreateCubeRGBA_1x1((MyGeneratedTexture)DebugMissingCubeTex, "DebubMissingCube", new Color(255, 0, 255, 0));

            m_missingNormalGlossTex.Init(ReleaseMissingNormalGlossTex, DebugMissingNormalGlossTex);
            m_missingAlphamaskTex.Init(ReleaseMissingNormalGlossTex, DebugMissingNormalGlossTex);
            m_missingExtensionTex.Init(ReleaseMissingExtensionTex, DebugMissingExtensionTex);
            m_missingCubeTex.Init(ReleaseMissingCubeTex, DebugMissingCubeTex);

            CreateCubeRGBA_1x1((MyGeneratedTexture)IntelFallbackCubeTex, "IntelFallbackCubeTex", new Color(10, 10, 10, 0));

            InitializeRandomTexture();

            byte[] ditherData = new byte[]
            {
                0, 32, 8, 40, 2, 34, 10, 42,
                48, 16, 56, 24, 50, 18, 58, 26,
                12, 44, 4, 36, 14, 46, 6, 38,
                60, 28, 52, 20, 62, 30, 54, 22,
                3, 35, 11, 43, 1, 33, 9, 41,
                51, 19, 59, 27, 49, 17, 57, 25,
                15, 47, 7, 39, 13, 45, 5, 37,
                63, 31, 55, 23, 61, 29, 53, 21
            };
            for (int i = 0; i < 64; i++)
                ditherData[i] = (byte)(ditherData[i] * 4); }
            CreateR((MyGeneratedTexture)Dithering8x8Tex, "Dither_8x8", new Vector2I(8, 8), ditherData);
        }
예제 #39
0
 void CreateR_1x1(MyGeneratedTexture tex, string name, byte data)
 {
     Texture2DDescription desc = m_descDefault;
     desc.Format = Format.R8_UNorm;
     desc.Height = 1;
     desc.Width = 1;
     tex.Init(name, desc, new Vector2I(1, 1), 1);
     Reset(tex, data);
 }