我的应用程序通过调整它们的alpha值而在各种媒体和文本层之间渐变。但是,当使用线性交叉淡入淡出时,亮度似乎在中途“下降”,然后消退。经过一番搜索之后,我发现this answer解释了这个问题,但是建议的解决方案,一次只褪去一层,对我来说不起作用,因为我使用的大多数图层已经包含透明度。平滑alpha交叉淡入淡出算法?
Here's an example of the issue I'm having, in HTML/CSS (code below because SO requires it。
<style>
body, html {
width: 100%;
height: 100%;
margin: 0;
background-color: black;
}
.example {
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
}
#example1 {
background-color: red;
animation: 1s linear 0s fade infinite alternate;
}
#example2 {
background-color: red;
animation: 1s linear 1s fade infinite alternate;
}
@keyframes fade {
from {opacity: 0;}
to {opacity: 1;}
}
</style>
<div id="example1" class="example"></div>
<div id="example2" class="example"></div>
的两个div应该淡化其混浊回来来回,得到一个固体红色图像的整个时间。相反,它似乎在亮度下降。
使用alpha创建平滑交叉淡入淡出的算法或公式是什么?我正在使用OpenGL,如果这是相关的。 (HTML/CSS片段只是展示问题的最简单方法)。
那么你如何显示透明区域?这是你需要融合的颜色。或者更好。也混合alpha通道。 –
透明区域的alpha设置为0.我只调整alpha通道,而不是其他任何通道。 –
看来,您可能只是想将“GL_CONSTANT_ALPHA”和“GL_ONE_MINUS_CONSTANT_ALPHA”用于混合功能。并用'glBlendColor'指定衰落时间。 –