0

我在 iPhone 上使用 openGL 和编程。

我正在我的游戏场景上渲染一个发光的“光束”。我正在使用一些带有添加剂混合的纹理来制作发光效果。如果光束在纯黑色背景上渲染,光束将看起来完全符合我的要求,但是,当光束在我不断变化的游戏中渲染时,它会与它背后的颜色混合。

目前,这是我唯一的想法:

1) 将光束渲染为纹理并使用普通混合在背景上绘制纹理。

问题 - 纹理总是不透明的(黑色是我的 glClear 颜色)。我还不知道如何从我渲染的纹理中删除所有黑色。

有什么建议么?

4

1 回答 1

1

You could render to an texture with alpha channel and blend that. But this will again change your beam's appearance. Blending will always introduce some change in appearance, you can't get around this.

The blending formula is

Destination = Incoming * Incoming_Blend_Factor + Original * Original_Blend_Factor

If you want your colour to be the same this equates to

Destination = Incoming

which, by comparision of coefficients is

Destination = Incoming * 1 + Original * 0

I.e. by not blending at all.


As an exercise I give you the following: In Photoshop or GIMP but some background image into the background layer and your beam into a layer on top of it. Then try to get the result you desire by tinkering with the available blend modes.

于 2011-07-20T13:29:21.740 回答