XNA 在重叠时添加颜色
我有一些精灵,当它们重叠时,我希望它们“添加”它们的颜色 RGB 值(可能)变成白色,精灵也有变化的 alpha 值,应该保持不变。我已经尝试使用所有 spritebatch 选项 alphablend、additive 等...
这可以通过 spritebatch 实现还是我需要着色器?
谢谢, 保罗.
I have sprites that when they overlap I would like them to 'add' their colors rgb values to (potentially) go white, the sprites also have changin alpha values which should remain unchanged. I've already tried using all the spritebatch options alphablend, additive etc...
Is this possible through spritebatch or will i need a shader?
Thanks,
Paul.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 XNA 4 中的预乘 Alpha 方案,您可以通过以 0 Alpha 绘制纹理来进行加法混合。因为这意味着纹理完成了 0 块处理,然后将 RGB 添加到其后面的像素,您就得到了加法混合。
只需使用 spritebatch 模式“Alphablend”以 0 alpha 绘制纹理即可。要降低可加性,请增加 alpha。为了使其不那么明显,请降低 RGB。
我强烈建议确保内容中的任何纹理在其属性中都勾选了“预乘 Alpha”选项(如果您使用此选项)。
Using the Premultiplied Alpha scheme in XNA 4, you can do additive blending by having your texture drawn at 0 alpha. Because this means that there is 0 blocking done by the texture, and then the RGB is added to the pixels behind it, you get additive blending.
Just draw the texture with 0 alpha using the spritebatch mode 'Alphablend'. To lower the additivity, increase alpha. To make it less visible, lower RGB.
I highly suggest making sure any textures in your content have the option 'Premultiplied Alpha' ticked in their properties, if you use this.