ERASE tests

This commit is contained in:
Richard Davey 2018-11-13 10:32:24 +00:00
parent a1273e42b8
commit 76918e76b0
2 changed files with 98 additions and 10 deletions

View file

@ -853,11 +853,23 @@ var RenderTexture = new Class({
var prevX = gameObject.x;
var prevY = gameObject.y;
if (this._eraseMode)
{
var blendMode = gameObject.blendMode;
gameObject.blendMode = BlendModes.ERASE;
}
gameObject.setPosition(x, y);
gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null);
gameObject.setPosition(prevX, prevY);
if (this._eraseMode)
{
gameObject.blendMode = blendMode;
}
},
/**
@ -905,19 +917,19 @@ var RenderTexture = new Class({
if (this.gl)
{
if (this._eraseMode)
{
var blendMode = this.renderer.currentBlendMode;
// if (this._eraseMode)
// {
// var blendMode = this.renderer.currentBlendMode;
this.renderer.setBlendMode(BlendModes.ERASE);
}
// this.renderer.setBlendMode(BlendModes.ERASE);
// }
this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null);
if (this._eraseMode)
{
this.renderer.setBlendMode(blendMode);
}
// if (this._eraseMode)
// {
// this.renderer.setBlendMode(blendMode);
// }
}
else
{

View file

@ -510,11 +510,87 @@ var WebGLRenderer = new Class({
this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD });
}
// ADD
this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ];
// MULTIPLY
this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ];
// SCREEN
this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ];
// ERASE
this.blendModes[17].func = [ gl.ZERO, gl.ONE_MINUS_SRC_ALPHA ];
// This is like an inversed erase! alpha areas go black
// this.blendModes[17].func = [ gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE, gl.ONE ];
// src RGB
// dst RGB
// src Alpha
// dst Alpha
// gl.ZERO,
// gl.ONE,
// gl.SRC_COLOR,
// gl.ONE_MINUS_SRC_COLOR,
// gl.DST_COLOR,
// gl.ONE_MINUS_DST_COLOR,
// gl.SRC_ALPHA,
// gl.ONE_MINUS_SRC_ALPHA,
// gl.DST_ALPHA,
// gl.ONE_MINUS_DST_ALPHA,
// gl.CONSTANT_COLOR,
// gl.ONE_MINUS_CONSTANT_COLOR,
// gl.CONSTANT_ALPHA,
// gl.ONE_MINUS_CONSTANT_ALPHA,
// gl.SRC_ALPHA_SATURATE
// BLACK (with ADD)
// this.blendModes[17].func = [
// gl.ZERO,
// gl.ONE_MINUS_SRC_ALPHA,
// gl.ONE,
// gl.ONE
// ];
// this.blendModes[17].func = [
// gl.ONE,
// gl.ZERO,
// gl.ONE,
// gl.ZERO
// ];
// this.blendModes[17].equation = gl.FUNC_ADD;
// this.blendModes[17].equation = gl.FUNC_SUBTRACT;
this.blendModes[17].equation = gl.FUNC_REVERSE_SUBTRACT;
// 0, 1, 2, 3
// blendFuncSeparate(this._srcRGB, this._dstRGB, this._srcAlpha, this._dstAlpha);
// this._srcRGB = this.gl.SRC_ALPHA;
// this._dstRGB = this.gl.ONE;
// this._srcAlpha = this.gl.ONE;
// this._dstAlpha = this.gl.ONE;
// this._modeRGB = this.gl.FUNC_ADD;
// this._modeAlpha = this.gl.FUNC_ADD;
// this._srcRGB = this.gl.SRC_ALPHA;
// this._dstRGB = this.gl.ONE_MINUS_SRC_ALPHA;
// this._srcAlpha = this.gl.ONE;
// this._dstAlpha = this.gl.ONE;
// this._modeRGB = this.gl.FUNC_REVERSE_SUBTRACT;
// this._modeAlpha = this.gl.FUNC_REVERSE_SUBTRACT;
// gl.blendEquationSeparate(this._modeRGB, this._modeAlpha);
// gl.blendFuncSeparate(this._srcRGB, this._dstRGB, this._srcAlpha, this._dstAlpha);
this.glFormats[0] = gl.BYTE;
this.glFormats[1] = gl.SHORT;
this.glFormats[2] = gl.UNSIGNED_BYTE;
@ -1016,7 +1092,7 @@ var WebGLRenderer = new Class({
this.flush();
gl.enable(gl.BLEND);
gl.blendEquation(blendMode.equation);
gl.blendEquation(blendMode.equation, blendMode.equation);
if (blendMode.func.length > 2)
{