简体   繁体   English

使Alpha通道/不透明度用于照明

[英]Getting alpha channel/opacity working for lighting

I have two pixel arrays, foreground and lighting. 我有两个像素阵列,前景和照明。 When I draw a white radial gradient (blurry circle) onto the lighting array, I want it to make the foreground visible - much like a torch in terraria/starbound. 当我在照明阵列上绘制一个白色的径向渐变(模糊圆圈)时,我希望它使前景可见-就像terraria / starbound中的火炬一样。 However, I also want to be able to mix different colors of lighting, rather than be stuck with black to white. 但是,我也希望能够混合使用不同颜色的照明,而不是将其卡在黑与白之间。

So how do I manipulate the pixel arrays so that they 'multiply' (I believe it's called)? 那么,如何操作像素阵列,使其“相乘”(我相信它被称为)? Or is there an easier way using RGBA which I have not been able to get to work (flickering black on white or image getting ever more posterized)? 还是有没有一种更容易使用RGBA的方法,而我却无法使用它(白色的黑色闪烁或图像变得更加海报化)?

So far most responses regarding alpha channels / opacity have been using libraries from java which for this project I want to refrain from using. 到目前为止,有关alpha通道/不透明度的大多数响应都使用了Java中的库,对于该项目,我想避免使用。

Any help much appreciated! 任何帮助,不胜感激!

If you want to know how the blending modes (such as "multiply") work in image editing programs on the pixel-value level, read this: How does photoshop blend two images together? 如果您想知道混合模式 (例如“乘”)在像素值级别的图像编辑程序中如何工作 ,请阅读以下内容: photoshop如何将两个图像混合在一起? .

Note that if you want to make the image lighter, you need a mode like "screen", because "multiply" makes it darker. 请注意,如果要使图像更亮,则需要“屏幕”之类的模式,因为“相乘”会使图像更暗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM