Skip to content

Commit 76918e7

Browse files
committed
ERASE tests
1 parent a1273e4 commit 76918e7

2 files changed

Lines changed: 98 additions & 10 deletions

File tree

src/gameobjects/rendertexture/RenderTexture.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -853,11 +853,23 @@ var RenderTexture = new Class({
853853
var prevX = gameObject.x;
854854
var prevY = gameObject.y;
855855

856+
if (this._eraseMode)
857+
{
858+
var blendMode = gameObject.blendMode;
859+
860+
gameObject.blendMode = BlendModes.ERASE;
861+
}
862+
856863
gameObject.setPosition(x, y);
857864

858865
gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null);
859866

860867
gameObject.setPosition(prevX, prevY);
868+
869+
if (this._eraseMode)
870+
{
871+
gameObject.blendMode = blendMode;
872+
}
861873
},
862874

863875
/**
@@ -905,19 +917,19 @@ var RenderTexture = new Class({
905917

906918
if (this.gl)
907919
{
908-
if (this._eraseMode)
909-
{
910-
var blendMode = this.renderer.currentBlendMode;
920+
// if (this._eraseMode)
921+
// {
922+
// var blendMode = this.renderer.currentBlendMode;
911923

912-
this.renderer.setBlendMode(BlendModes.ERASE);
913-
}
924+
// this.renderer.setBlendMode(BlendModes.ERASE);
925+
// }
914926

915927
this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null);
916928

917-
if (this._eraseMode)
918-
{
919-
this.renderer.setBlendMode(blendMode);
920-
}
929+
// if (this._eraseMode)
930+
// {
931+
// this.renderer.setBlendMode(blendMode);
932+
// }
921933
}
922934
else
923935
{

src/renderer/webgl/WebGLRenderer.js

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,87 @@ var WebGLRenderer = new Class({
510510
this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD });
511511
}
512512

513+
// ADD
513514
this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ];
515+
516+
// MULTIPLY
514517
this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ];
518+
519+
// SCREEN
515520
this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ];
521+
522+
// ERASE
516523
this.blendModes[17].func = [ gl.ZERO, gl.ONE_MINUS_SRC_ALPHA ];
517524

525+
// This is like an inversed erase! alpha areas go black
526+
// this.blendModes[17].func = [ gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE, gl.ONE ];
527+
528+
// src RGB
529+
// dst RGB
530+
// src Alpha
531+
// dst Alpha
532+
533+
// gl.ZERO,
534+
// gl.ONE,
535+
// gl.SRC_COLOR,
536+
// gl.ONE_MINUS_SRC_COLOR,
537+
// gl.DST_COLOR,
538+
// gl.ONE_MINUS_DST_COLOR,
539+
// gl.SRC_ALPHA,
540+
// gl.ONE_MINUS_SRC_ALPHA,
541+
// gl.DST_ALPHA,
542+
// gl.ONE_MINUS_DST_ALPHA,
543+
// gl.CONSTANT_COLOR,
544+
// gl.ONE_MINUS_CONSTANT_COLOR,
545+
// gl.CONSTANT_ALPHA,
546+
// gl.ONE_MINUS_CONSTANT_ALPHA,
547+
// gl.SRC_ALPHA_SATURATE
548+
549+
// BLACK (with ADD)
550+
551+
// this.blendModes[17].func = [
552+
// gl.ZERO,
553+
// gl.ONE_MINUS_SRC_ALPHA,
554+
// gl.ONE,
555+
// gl.ONE
556+
// ];
557+
558+
// this.blendModes[17].func = [
559+
// gl.ONE,
560+
// gl.ZERO,
561+
// gl.ONE,
562+
// gl.ZERO
563+
// ];
564+
565+
566+
// this.blendModes[17].equation = gl.FUNC_ADD;
567+
// this.blendModes[17].equation = gl.FUNC_SUBTRACT;
568+
this.blendModes[17].equation = gl.FUNC_REVERSE_SUBTRACT;
569+
570+
// 0, 1, 2, 3
571+
// blendFuncSeparate(this._srcRGB, this._dstRGB, this._srcAlpha, this._dstAlpha);
572+
573+
574+
// this._srcRGB = this.gl.SRC_ALPHA;
575+
// this._dstRGB = this.gl.ONE;
576+
// this._srcAlpha = this.gl.ONE;
577+
// this._dstAlpha = this.gl.ONE;
578+
// this._modeRGB = this.gl.FUNC_ADD;
579+
// this._modeAlpha = this.gl.FUNC_ADD;
580+
581+
582+
583+
584+
// this._srcRGB = this.gl.SRC_ALPHA;
585+
// this._dstRGB = this.gl.ONE_MINUS_SRC_ALPHA;
586+
// this._srcAlpha = this.gl.ONE;
587+
// this._dstAlpha = this.gl.ONE;
588+
// this._modeRGB = this.gl.FUNC_REVERSE_SUBTRACT;
589+
// this._modeAlpha = this.gl.FUNC_REVERSE_SUBTRACT;
590+
591+
// gl.blendEquationSeparate(this._modeRGB, this._modeAlpha);
592+
// gl.blendFuncSeparate(this._srcRGB, this._dstRGB, this._srcAlpha, this._dstAlpha);
593+
518594
this.glFormats[0] = gl.BYTE;
519595
this.glFormats[1] = gl.SHORT;
520596
this.glFormats[2] = gl.UNSIGNED_BYTE;
@@ -1016,7 +1092,7 @@ var WebGLRenderer = new Class({
10161092
this.flush();
10171093

10181094
gl.enable(gl.BLEND);
1019-
gl.blendEquation(blendMode.equation);
1095+
gl.blendEquation(blendMode.equation, blendMode.equation);
10201096

10211097
if (blendMode.func.length > 2)
10221098
{

0 commit comments

Comments
 (0)