【发布时间】:2017-09-04 19:30:25
【问题描述】:
此代码创建具有非零 Alpha 通道的纹理。
Texture2D result = new Texture2D(Program.MainThread.GraphicsDevice, (Int32)texture_size, (Int32)texture_size);
Color[ ] colorData = new Color[result.Width * result.Height];
for (UInt32 x = 0; x < result.Width; x++) {
for (UInt32 y = 0; y < result.Height; y++) {
UInt32 index = (UInt32)(x * result.Width + y);
colorData[index] = new Color(1f, 0f, 0f, 0f);
}
}
result.SetData(colorData);
颜色变得略微透明。但是,大约为 0.5f 的值。为什么会这样?
附: Color.Transparent 工作正常,但我有一个要以编程方式计算的 alpha 通道,例如:
colorData[index] = new Color(1f, 0f, 0f, 1f - temp);
【问题讨论】: