当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.Data方法代码示例

本文整理汇总了C#中Texture2D.Data方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.Data方法的具体用法?C# Texture2D.Data怎么用?C# Texture2D.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture2D的用法示例。


在下文中一共展示了Texture2D.Data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePerlinGradientTexture

        void CreatePerlinGradientTexture(byte[] permutations)
        {
            Vector4nsb[] gradients = new Vector4nsb[] {
                new Vector4nsb(1, 1, 0, 0), new Vector4nsb(-1, 1, 0, 0), new Vector4nsb(1, -1, 0, 0), new Vector4nsb(-1, -1, 0, 0),
                new Vector4nsb(1, 0, 1, 0), new Vector4nsb(-1, 0, 1, 0), new Vector4nsb(1, 0, -1, 0), new Vector4nsb(-1, 0, -1, 0),
                new Vector4nsb(0, 1, 1, 0), new Vector4nsb(0, -1, 1, 0), new Vector4nsb(0, 1, -1, 0), new Vector4nsb(0, -1, -1, 0),
                new Vector4nsb(1, 1, 0, 0), new Vector4nsb(0, -1, 1, 0), new Vector4nsb(-1, 1, 0, 0), new Vector4nsb(0, -1, -1, 0)
            };

            Vector4nsb[] data = new Vector4nsb[256];

            #if false
            new NormalizedColor(0, -1, -1, -1),
            new NormalizedColor(0, -1, -1, 1),
            new NormalizedColor(0, -1, 1, -1),
            new NormalizedColor(0, -1, 1, 1),
            new NormalizedColor(0, 1, -1, -1),
            new NormalizedColor(0, 1, -1, 1),
            new NormalizedColor(0, 1, 1, -1),
            new NormalizedColor(0, 1, 1, 1),
            new NormalizedColor(-1, -1, 0, -1),
            new NormalizedColor(-1, 1, 0, -1),
            new NormalizedColor(1, -1, 0, -1),
            new NormalizedColor(1, 1, 0, -1),
            new NormalizedColor(-1, -1, 0, 1),
            new NormalizedColor(-1, 1, 0, 1),
            new NormalizedColor(1, -1, 0, 1),
            new NormalizedColor(1, 1, 0, 1),

            new NormalizedColor(-1, 0, -1, -1),
            new NormalizedColor(1, 0, -1, -1),
            new NormalizedColor(-1, 0, -1, 1),
            new NormalizedColor(1, 0, -1, 1),
            new NormalizedColor(-1, 0, 1, -1),
            new NormalizedColor(1, 0, 1, -1),
            new NormalizedColor(-1, 0, 1, 1),
            new NormalizedColor(1, 0, 1, 1),
            new NormalizedColor(0, -1, -1, 0),
            new NormalizedColor(0, -1, -1, 0),
            new NormalizedColor(0, -1, 1, 0),
            new NormalizedColor(0, -1, 1, 0),
            new NormalizedColor(0, 1, -1, 0),
            new NormalizedColor(0, 1, -1, 0),
            new NormalizedColor(0, 1, 1, 0),
            new NormalizedColor(0, 1, 1, 0),
            #endif
            for (int i = 0; i < 256; i++)
                data[i] = gradients[permutations[i] % gradients.Length];

            var texture = new Texture2D();
            texture.Data(data.Length, 1, Formats.Vector4nsb, data);
            Program.Uniforms["PerlinGradientTexture"].Set(texture);
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:53,代码来源:TerrainEditor.cs

示例2: CreatePerlinPermutationTexture

        void CreatePerlinPermutationTexture(byte[] permutations)
        {
            Vector4b[] data = new Vector4b[256 * 256];
            for (int y = 0; y < 256; y++)
                for (int x = 0; x < 256; x++)
                {
                    int a = permutations[x] + y;
                    int AA = permutations[a % 256];
                    int AB = permutations[(a + 1) % 256];
                    int B = permutations[(x + 1) % 256] + y;
                    int BA = permutations[B % 256];
                    int BB = permutations[(B + 1) % 256];
                    data[x + y * 256] = new Vector4b((byte)AA, (byte)AB, (byte)BA, (byte)BB);
                }

            var texture = new Texture2D();
            texture.Data(256, 256, Formats.Vector4nb, data);
            Program.Uniforms["PerlinPermutationTexture"].Set(texture);
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:19,代码来源:TerrainEditor.cs

示例3: Update

        /// <summary>Update the texture.</summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        protected void Update(int width, int height)
        {
            if (Indices == null || Palette == null)
                return;

            int[] colors = new int[Palette.Colors.Count];
            for (int index = 0; index < colors.Length; index++)
                colors[index] = ConvertColor(Palette.Colors[index]);

            int[] indices = Indices;
            int[] rgba = new int[width * height];
            int colorCount = colors.Length;
            int purple = ConvertColor(Color.Purple);

            for (int row = 0; row < height; row++) {
                for (int input = row * Pitch, inputEnd = input + width, output = row * width; input < inputEnd; input++, output++) {
                    int index = indices[input];
                    int color = index < colorCount && index >= 0 ? colors[index] : purple;
                    rgba[output] = color;
                }
            }

            var texture = new Texture2D();
            texture.MaxLod = 0;
            texture.MipmapFilter = TextureFilter.None;
            texture.Data(width, height, Glare.Graphics.Formats.Vector4srgba, rgba);
            Content = texture;
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:31,代码来源:IndexedTextureAsset.cs


注:本文中的Texture2D.Data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。