简体   繁体   English

累积Alpha混合

[英]Cumulative alpha blending

Does anyone know what settings to use for glBlendFunc to achieve cumulative blending? 有谁知道glBlendFunc使用什么设置来实现累积混合?

For example: 例如:

  1. 50% alpha + 50% alpha = 50% alpha 50%alpha + 50%alpha = 50%alpha
  2. 50% alpha + 40% alpha = 50% alpha 50%alpha + 40%alpha = 50%alpha
  3. 50% alpha + 60% alpha = 60% alpha 50%alpha + 60%alpha = 60%alpha

What I'm tryong to do is render multiple shapes, all of the same colour, but with different alpha values. 我正在尝试做的是渲染多个形状,所有形状相同的颜色,但具有不同的alpha值。 Some shapes will overlap. 一些形状会重叠。 I want each resulting pixel to be the equivalent of just rendering once with the largest alpha value. 我希望每个结果像素都等于用最大的alpha值渲染一次。

I need to use vanilla GL10 so none of the min/max equation stuff is available. 我需要使用香草GL10,因此没有最小/最大方程式可用。

I'm working on a couple of hotch-potch alternative solutions, one using depth and one using multi-pass rendering, but I have a gut feeling there's a neater way that I'm not seeing. 我正在研究几种可行的替代解决方案,一种使用深度,另一种使用多遍渲染,但是我有一种直觉,感觉我没有看到一种更整洁的方式。

If you use a OpenGL 1.1. 如果使用OpenGL 1.1。 implementation, you can use the accumulation buffer. 执行时,可以使用累积缓冲区。

The accumulation buffer accumulates different rendering passes, allowing you to mean each pixel color. 累积缓冲区累积不同的渲染通道,使您可以表示每种像素颜色。 Indeed, if you draw different shapes, the overlapping regions will cumulate color values of the overlapping shapes. 实际上,如果绘制不同的形状,则重叠区域将累积重叠形状的颜色值。

Fixed the number of rendering phases (say N ), a pixel which is owned by M shapes will have the color RGB * M / N; 固定渲染阶段的数量(例如N ),由M个形状拥有的像素将具有RGB * M / N的颜色; as I can understand, this is what you want to get. 据我了解,这就是您想要得到的。

See glAccum manual for details. 有关详细信息,请参见glAccum手册。

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

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