如何在Three.js中定义其他混合模式?

时间:2019-02-26 11:14:53

标签: javascript three.js blending

我想在Three.js中定义其他混合模式,就像在Photoshop中可以找到的那样。例如:

线性烧伤: 像素=(src + dst)-1.0

屏幕: 像素=(src + dst)-(src * dst)

我要添加的混合模式及其方程式的完整列表可以在以下链接中找到: Sublime text

ThreeJs仅在不使用“自定义混合模式”的情况下提供“正常”,“加法”,“减法”和“乘积”混合。但是,可以通过使用“ CustomBlending”和Three的混合方程轻松添加最亮和最暗。例如:

material.blending = THREE[ "CustomBlending" ];
if(blendMode === "Lightest"){
    material.blendEquation = THREE.MaxEquation;
}
if(blendMode === "Darkest"){
    material.blendEquation = THREE.MinEquation;
}

在此处阅读有关自定义混合方程式的更多信息: http://www.nutty.ca/articles/blend_modes/

我的问题是:如何定义其他blendEquations?

我一直在Github上查看“三”的src文件,尤其是其中似乎已定义blendEquations的WebGLState.js。下面是似乎在定义AddEquation的地方:

if ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {

    gl.blendEquation( gl.FUNC_ADD );

    currentBlendEquation = AddEquation;
    currentBlendEquationAlpha = AddEquation;

}

您可以在此处查看代码: https://threejs.org/docs/#api/en/constants/CustomBlendingEquations

不过,我似乎找不到其他blendFunctions定义的位置。谁能帮我这个忙吗?这是编辑Three.js src文件的最佳方法吗?定义源因素和目标因素(material.blendSrc = THREE.SrcAlphaFactor;)就是其中一部分吗?

谢谢!

0 个答案:

没有答案