线性光模式的Alpha混合层 [英] Alpha Blending Layers for Linear Light Mode

查看:134
本文介绍了线性光模式的Alpha混合层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重新创建一些Photoshop混合,并尝试使用线性光照模式。在Photoshop中,您将拥有100%不透明度的背景图层,然后是设置为线性光线作为混合模式的50%不透明顶层。



我找到了有关如何进行线性光线混合的信息,但仅适用于两个图层都处于不透明度100%的情况。



以下是将执行线性光线模式的着色器代码和当图层都处于100%不透明度时,它给出与Photoshop相同的结果:

  #define BlendLinearDodgef BlendAddf 
#define BlendLinearBurnf BlendSubstractf

#define BlendAddf(base,blend)min(base + blend,1.0)
#define BlendSubstractf(base,blend)max(base + blend - 1.0,0.0)


#define BlendLinearLightf(base,blend)(blend <0.5?BlendLinearBurnf(base,(2.0 * blend)):BlendLinearDodgef(base,(2.0 *(blend - 0.5)))))

我看了 http://en.wikipedia .org / wiki / Alpha_compositing ,但仍然存在问题。



如何让混合模式适用于半透明图层?

解决方案

您应该阅读 PDF规范,了解如何使用混合模式,当你有100%以外的阿尔法。具体请参见第7.2节基本合成计算。第414页上的公式应该解释你需要什么:

pre code> Cr =(1-as / ar)* Cb +(as / ar)* [(1-ab)* Cs + ab * B(Cb,Cs)]


I'm recreating some Photoshop blending and I'm trying to use Linear Light mode. In Photoshop you'd have a background layer at 100% opacity and then a 50% opacity top layer that is set to Linear Light as the blend mode.

I did find info on how to do the Linear Light blend, but it only works when both layers are at 100% opacity.

Here is the shader code that will do Linear Light mode and it gives the same result as Photoshop when layers are both at 100% opacity:

#define BlendLinearDodgef           BlendAddf
#define BlendLinearBurnf            BlendSubstractf

#define BlendAddf(base, blend)      min(base + blend, 1.0)
#define BlendSubstractf(base, blend)    max(base + blend - 1.0, 0.0)


#define BlendLinearLightf(base, blend)  (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5))))

I've looked at http://en.wikipedia.org/wiki/Alpha_compositing but am still having issues.

How can I get the blend mode to work for semi-transparent layers?

解决方案

You should read the PDF spec to learn about how to use blend modes when you have alpha other than 100%. In particular, see section 7.2, "Basic Compositing Computations." The formula on page 414 should explain what you need:

Cr= (1-as/ar) * Cb + (as/ar) * [(1-ab) * Cs + ab * B(Cb,Cs)]

这篇关于线性光模式的Alpha混合层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆