WebGL-使用一个程序掩盖上一个程序



im运行着一个着色器程序,该程序会呈现一些顶点,然后在片段着色器中颜色。

我还有另一个程序正在运行,我想用来掩盖上一个渲染的形状。

到目前为止,第一个呈现这样的东西:

animate_() {
    requestAnimationFrame(() => this.animate_());
    this.gl_.clearColor(0, 0, 0, 0);
    this.gl_.clear(webgl.COLOR_BUFFER_BIT);
    this.gl_.useProgram(this.program_);
    // Runs enableVertexAttribArray, bindBuffer, vertexAttribPointer
    renderBufferAttribute(this.gl_, this.position_);
    // Pass through all my uniforms here
    // ...
    // Draw triangles
    this.gl_.drawArrays(webgl.TRIANGLES, 0,
        this.particleCount_.total * PARTICLE_ARRAY_COUNT / 2);
}

i然后有这样的第二个程序:

animate_() {
    requestAnimationFrame(() => this.animate_());
    // this.gl_.clearColor(0, 0, 0, 0);
    // this.gl_.clear(webgl.COLOR_BUFFER_BIT);
    this.gl_.useProgram(this.program_);
    renderBufferAttribute(this.gl_, this.position_);
    this.gl_.drawArrays(webgl.TRIANGLES, 0, 6);
}

ive尝试将不透明度设置在片段着色器中的所有方向上,然后使用gl.clearcolor和gl.clear.clear.clear.clear,但它要么清除整个东西,要么将其设置为颜色。

i然后仅尝试将第二个程序的顶点着色器中的一半超过一半的画布渲染,但仍然找不到解决方案。

在两个程序上也使用这些:

this.gl_.blendFunc(webgl.SRC_ALPHA, webgl.ONE_MINUS_SRC_ALPHA);
this.gl_.enable(webgl.BLEND);

这甚至可能吗?

编辑

我还需要淡入面膜的边缘。

谢谢!

从fragmentshader中删除像素彩的更好? ->根本没有调用fragmentshader。

您可能会阅读更多有关Scentilfunc的信息,该模具就像模板一样,并丢弃了碎片着色器的呼唤。因此显示颜色"下面"

或在这里进行一些openGL变体。

相关内容

最新更新