Texture2D texture = new Texture2D(GraphicsDevice, 512, 256, true, SurfaceFormat.Color);
uint[] data = new uint[texture.Height * texture.Width];
int index = 0;
for (int v=0 ; v < texture.Height; v++)
{
for (int h = 0; h < texture.Width; h++)
{
byte red = (byte)(0xff * ((float)h / texture.Width)); //テクスチャの幅に近くなれば0xffに近くなる
data[index] = 0xff000000u | (uint)(red << 16);
//ビットシフトと論理和を組み合わせたカラーセットの方法(0ならR、8ならG、16ならBになる)
index++;
}
}
texture.SetData(data);