本文整理汇总了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);
}
示例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);
}
示例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;
}