Hello, im trying to create 2 postprocess passes. First just draws background, then another one blends into the previous one.
According to docs I should use :
postProcess.autoClear = false;
postProcess.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
but it doesnt work. Previous post process is cleared completely anyway.
Pseudocode:
var postProcess = new BABYLON.PostProcess("bg", "./bg.shader", ["iResolution", "iTime",
"mouse"], ["iChannel0"], 1.0, camera);
var postProcess2 = new BABYLON.PostProcess("letters", "./letters.shader", ["iResolution", "iTime",
"mouse", "noktoFactor"], ["iChannel0"], 1.0, camera);
postProcess2.autoClear = false;
postProcess2.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
And just using
postProcess.onApply = function (effect) {} and postProcess2.onApply = function (effect) {}
Shaders:
bg:
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vUV;
uniform sampler2D iChannel0;
uniform vec2 mouse;
uniform vec2 iResolution;
void mainImage(out vec4 f, in vec2 w)
{
vec2 u = w/iResolution.xy; // left-bottom is (0,0)
float dist = distance(u, mouse);
float distFactor = 10.0;
vec4 black = vec4(0,0,0,1.0);
vec4 textureColor = texture2D(iChannel0, u);
f=mix(textureColor, black, dist * distFactor);
}
void main()
{
mainImage(gl_FragColor, vUV * iResolution.xy);
}
letters:
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vUV;
uniform sampler2D iChannel0;
uniform vec2 mouse;
uniform vec2 iResolution;
uniform float noktoFactor;
void mainImage(out vec4 f, in vec2 w)
{
vec2 uv=vUV;
float dist = distance(uv, mouse);
float distFactor = 10.0;
vec4 black = vec4(0,0,0,1.0);
vec4 textureColor = texture2D(iChannel0, vUV);
f=mix(textureColor, black, dist * distFactor);
f.a = 0.0; // I just want to preserve the old background.
}
void main()
{
mainImage(gl_FragColor, vUV * iResolution.xy);
}
Using latest v.