mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
Merge branch 'photonstorm:master' into spatial-sound
This commit is contained in:
commit
3d636f5fac
11 changed files with 251 additions and 148 deletions
|
@ -570,6 +570,7 @@ Previously, `WebGLRenderer.whiteTexture` and `WebGLRenderer.blankTexture` had a
|
|||
|
||||
* The `RenderTarget` class will now create a Framebuffer that includes a Depth Stencil Buffer attachment by default. Previously, it didn't. By attaching a stencil buffer it allows things like Geometry Masks to work in combination with Post FX and other Pipelines. Fix #5802 (thanks @mijinc0)
|
||||
* When calling `PipelineManager.clear` and `rebind` it will now check if the vao extension is available, and if so, it'll bind a null vertex array. This helps clean-up from 3rd party libs that don't do this directly, such as ThreeJS.
|
||||
* The `mipmapFilter` property in the Game Config now defaults to '' (an empty string) instead of 'LINEAR'. The WebGLRenderer has been updated so that it will no longer create mipmaps at all with a default config. This potential saves a lot of VRAM (if your game has a lot of power-of-two textures) where before it was creating mipmaps that may never have been used. However, you may notice scaling doesn't look as crisp as it did before if you were using this feature without knowing it. To get it back, just add `mipmapFilter: 'LINEAR'` to your game config. Remember, as this is WebGL1 it _only_ works with power-of-two sized textures.
|
||||
|
||||
#### Mobile Pipeline
|
||||
|
||||
|
@ -856,6 +857,20 @@ The following are API-breaking, in that a new optional parameter has been insert
|
|||
|
||||
### Updates
|
||||
|
||||
* `ColorMatrix._matrix` and `_data` are now Float32Arrays.
|
||||
* Calling the `ColorMatrix.set`, `reset` and `getData` methods all now use the built-in Float32 Array operations, making them considerably faster.
|
||||
* `ColorMatrix.BLACK_WHITE` is a new constant used by blackwhite operations.
|
||||
* `ColorMatrix.NEGATIVE` is a new constant used by negative operations.
|
||||
* `ColorMatrix.DESATURATE_LUMINANCE` is a new constant used by desaturation operations.
|
||||
* `ColorMatrix.SEPIA` is a new constant used by sepia operations.
|
||||
* `ColorMatrix.LSD` is a new constant used by LSD operations.
|
||||
* `ColorMatrix.BROWN` is a new constant used by brown operations.
|
||||
* `ColorMatrix.VINTAGE` is a new constant used by vintage pinhole operations.
|
||||
* `ColorMatrix.KODACHROME` is a new constant used by kodachrome operations.
|
||||
* `ColorMatrix.TECHNICOLOR` is a new constant used by technicolor operations.
|
||||
* `ColorMatrix.POLAROID` is a new constant used by polaroid operations.
|
||||
* `ColorMatrix.SHIFT_BGR` is a new constant used by shift BGR operations.
|
||||
* If no Audio URLs match the given device a new warning is now displayed in the console (thanks @samme)
|
||||
* `Texture.has` will now return a strict boolean, rather than an object that can be cooerced into a boolean (thanks @samme)
|
||||
* The `CanvasTexture.draw` method has a new optional parameter `update` which allows you to control if the internal ImageData is recalculated, or not (thanks @samme)
|
||||
* The `CanvasTexture.drawFrame` method has a new optional parameter `update` which allows you to control if the internal ImageData is recalculated, or not (thanks @samme)
|
||||
|
|
|
@ -363,7 +363,7 @@ var Config = new Class({
|
|||
/**
|
||||
* @const {string} Phaser.Core.Config#mipmapFilter - Sets the `mipmapFilter` property when the WebGL renderer is created.
|
||||
*/
|
||||
this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', 'LINEAR', config);
|
||||
this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config);
|
||||
|
||||
/**
|
||||
* @const {boolean} Phaser.Core.Config#desynchronized - When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* @property {number} [batchSize=4096] - The default WebGL batch size. Represents the number of _quads_ that can be added to a single batch.
|
||||
* @property {number} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.
|
||||
* @property {number} [maxTextures=-1] - When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8.
|
||||
* @property {string} [mipmapFilter='LINEAR'] - The mipmap magFilter to be used when creating WebGL textures.
|
||||
* @property {string} [mipmapFilter=''] - The mipmap magFilter to be used when creating WebGL textures.
|
||||
* @property {Phaser.Types.Core.PipelineConfig} [pipeline] - The WebGL Pipeline configuration object.
|
||||
* @property {boolean} [autoMobilePipeline=true] - Automatically enable the Mobile Pipeline if iOS or Android detected?
|
||||
* @property {string} [defaultPipeline='MultiPipeline'] - The WebGL Pipeline that Game Objects will use by default. Set to 'MultiPipeline' as standard.
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
var Class = require('../utils/Class');
|
||||
|
||||
var tempMatrix = new Float32Array(20);
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics
|
||||
|
@ -29,16 +31,11 @@ var ColorMatrix = new Class({
|
|||
* Internal ColorMatrix array.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix#_matrix
|
||||
* @type {number[]}
|
||||
* @type {Float32Array}
|
||||
* @private
|
||||
* @since 3.50.0
|
||||
*/
|
||||
this._matrix = [
|
||||
1, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 0,
|
||||
0, 0, 1, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
];
|
||||
this._matrix = new Float32Array(20);
|
||||
|
||||
/**
|
||||
* The value that determines how much of the original color is used
|
||||
|
@ -70,7 +67,9 @@ var ColorMatrix = new Class({
|
|||
* @private
|
||||
* @since 3.50.0
|
||||
*/
|
||||
this._data;
|
||||
this._data = new Float32Array(20);
|
||||
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -79,13 +78,13 @@ var ColorMatrix = new Class({
|
|||
* @method Phaser.Display.ColorMatrix#set
|
||||
* @since 3.50.0
|
||||
*
|
||||
* @param {number[]} value - The ColorMatrix values to set.
|
||||
* @param {(number[]|Float32Array)} value - The ColorMatrix values to set. Must have 20 elements.
|
||||
*
|
||||
* @return {this} This ColorMatrix instance.
|
||||
*/
|
||||
set: function (value)
|
||||
{
|
||||
this._matrix = value;
|
||||
this._matrix.set(value);
|
||||
|
||||
this._dirty = true;
|
||||
|
||||
|
@ -93,7 +92,8 @@ var ColorMatrix = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Resets the ColorMatrix.
|
||||
* Resets the ColorMatrix to default values and also resets
|
||||
* the `alpha` property back to 1.
|
||||
*
|
||||
* @method Phaser.Display.ColorMatrix#reset
|
||||
* @since 3.50.0
|
||||
|
@ -102,34 +102,16 @@ var ColorMatrix = new Class({
|
|||
*/
|
||||
reset: function ()
|
||||
{
|
||||
// Long-winded, but saves on gc, which happens a lot in Post FX Shaders
|
||||
// that reset the ColorMatrix every frame.
|
||||
|
||||
var m = this._matrix;
|
||||
|
||||
m.fill(0);
|
||||
|
||||
m[0] = 1;
|
||||
m[1] = 0;
|
||||
m[2] = 0;
|
||||
m[3] = 0;
|
||||
m[4] = 0;
|
||||
|
||||
m[5] = 0;
|
||||
m[6] = 1;
|
||||
m[7] = 0;
|
||||
m[8] = 0;
|
||||
m[9] = 0;
|
||||
|
||||
m[10] = 0;
|
||||
m[11] = 0;
|
||||
m[12] = 1;
|
||||
m[13] = 0;
|
||||
m[14] = 0;
|
||||
|
||||
m[15] = 0;
|
||||
m[16] = 0;
|
||||
m[17] = 0;
|
||||
m[18] = 1;
|
||||
m[19] = 0;
|
||||
|
||||
this.alpha = 1;
|
||||
|
||||
this._dirty = true;
|
||||
|
||||
|
@ -148,21 +130,21 @@ var ColorMatrix = new Class({
|
|||
*/
|
||||
getData: function ()
|
||||
{
|
||||
var data = this._data;
|
||||
|
||||
if (this._dirty)
|
||||
{
|
||||
var f32 = new Float32Array(this._matrix);
|
||||
data.set(this._matrix);
|
||||
|
||||
f32[4] /= 255;
|
||||
f32[9] /= 255;
|
||||
f32[14] /= 255;
|
||||
f32[19] /= 255;
|
||||
|
||||
this._data = f32;
|
||||
data[4] /= 255;
|
||||
data[9] /= 255;
|
||||
data[14] /= 255;
|
||||
data[19] /= 255;
|
||||
|
||||
this._dirty = false;
|
||||
}
|
||||
|
||||
return this._data;
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -300,12 +282,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0.3, 0.6, 0.1, 0, 0,
|
||||
0.3, 0.6, 0.1, 0, 0,
|
||||
0.3, 0.6, 0.1, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.BLACK_WHITE, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -349,12 +326,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
-1, 0, 0, 1, 0,
|
||||
0, -1, 0, 1, 0,
|
||||
0, 0, -1, 1, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.NEGATIVE, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -371,12 +343,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0.2764723, 0.9297080, 0.0938197, 0, -37.1,
|
||||
0.2764723, 0.9297080, 0.0938197, 0, -37.1,
|
||||
0.2764723, 0.9297080, 0.0938197, 0, -37.1,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.DESATURATE_LUMINANCE, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -393,12 +360,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0.393, 0.7689999, 0.18899999, 0, 0,
|
||||
0.349, 0.6859999, 0.16799999, 0, 0,
|
||||
0.272, 0.5339999, 0.13099999, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.SEPIA, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -439,12 +401,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
2, -0.4, 0.5, 0, 0,
|
||||
-0.5, 2, -0.4, 0, 0,
|
||||
-0.4, -0.5, 3, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.LSD, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -461,12 +418,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873,
|
||||
-0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127,
|
||||
0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.BROWN, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -483,12 +435,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123,
|
||||
0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591,
|
||||
0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.VINTAGE, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -505,12 +452,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,
|
||||
-0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,
|
||||
-0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.KODACHROME, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -527,12 +469,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337,
|
||||
-0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398,
|
||||
-0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.TECHNICOLOR, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -549,12 +486,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
1.438, -0.062, -0.062, 0, 0,
|
||||
-0.122, 1.378, -0.122, 0, 0,
|
||||
-0.016, -0.016, 1.483, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.POLAROID, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -571,12 +503,7 @@ var ColorMatrix = new Class({
|
|||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
return this.multiply([
|
||||
0, 0, 1, 0, 0,
|
||||
0, 1, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
], multiply);
|
||||
return this.multiply(ColorMatrix.SHIFT_BGR, multiply);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -586,11 +513,14 @@ var ColorMatrix = new Class({
|
|||
* @since 3.50.0
|
||||
*
|
||||
* @param {number[]} a - The 5x4 array to multiply with ColorMatrix._matrix.
|
||||
* @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ?
|
||||
*
|
||||
* @return {this} This ColorMatrix instance.
|
||||
*/
|
||||
multiply: function (a, multiply)
|
||||
{
|
||||
if (multiply === undefined) { multiply = false; }
|
||||
|
||||
// Duplicate _matrix into c
|
||||
|
||||
if (!multiply)
|
||||
|
@ -599,40 +529,41 @@ var ColorMatrix = new Class({
|
|||
}
|
||||
|
||||
var m = this._matrix;
|
||||
var c = [];
|
||||
var c = tempMatrix;
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
c[i] = m[i];
|
||||
}
|
||||
// copy _matrix to tempMatrox
|
||||
c.set(m);
|
||||
|
||||
// R
|
||||
m[0] = (c[0] * a[0]) + (c[1] * a[5]) + (c[2] * a[10]) + (c[3] * a[15]);
|
||||
m[1] = (c[0] * a[1]) + (c[1] * a[6]) + (c[2] * a[11]) + (c[3] * a[16]);
|
||||
m[2] = (c[0] * a[2]) + (c[1] * a[7]) + (c[2] * a[12]) + (c[3] * a[17]);
|
||||
m[3] = (c[0] * a[3]) + (c[1] * a[8]) + (c[2] * a[13]) + (c[3] * a[18]);
|
||||
m[4] = (c[0] * a[4]) + (c[1] * a[9]) + (c[2] * a[14]) + (c[3] * a[19]) + c[4];
|
||||
m.set([
|
||||
// R
|
||||
(c[0] * a[0]) + (c[1] * a[5]) + (c[2] * a[10]) + (c[3] * a[15]),
|
||||
(c[0] * a[1]) + (c[1] * a[6]) + (c[2] * a[11]) + (c[3] * a[16]),
|
||||
(c[0] * a[2]) + (c[1] * a[7]) + (c[2] * a[12]) + (c[3] * a[17]),
|
||||
(c[0] * a[3]) + (c[1] * a[8]) + (c[2] * a[13]) + (c[3] * a[18]),
|
||||
(c[0] * a[4]) + (c[1] * a[9]) + (c[2] * a[14]) + (c[3] * a[19]) + c[4],
|
||||
|
||||
// G
|
||||
m[5] = (c[5] * a[0]) + (c[6] * a[5]) + (c[7] * a[10]) + (c[8] * a[15]);
|
||||
m[6] = (c[5] * a[1]) + (c[6] * a[6]) + (c[7] * a[11]) + (c[8] * a[16]);
|
||||
m[7] = (c[5] * a[2]) + (c[6] * a[7]) + (c[7] * a[12]) + (c[8] * a[17]);
|
||||
m[8] = (c[5] * a[3]) + (c[6] * a[8]) + (c[7] * a[13]) + (c[8] * a[18]);
|
||||
m[9] = (c[5] * a[4]) + (c[6] * a[9]) + (c[7] * a[14]) + (c[8] * a[19]) + c[9];
|
||||
// G
|
||||
(c[5] * a[0]) + (c[6] * a[5]) + (c[7] * a[10]) + (c[8] * a[15]),
|
||||
(c[5] * a[1]) + (c[6] * a[6]) + (c[7] * a[11]) + (c[8] * a[16]),
|
||||
(c[5] * a[2]) + (c[6] * a[7]) + (c[7] * a[12]) + (c[8] * a[17]),
|
||||
(c[5] * a[3]) + (c[6] * a[8]) + (c[7] * a[13]) + (c[8] * a[18]),
|
||||
(c[5] * a[4]) + (c[6] * a[9]) + (c[7] * a[14]) + (c[8] * a[19]) + c[9],
|
||||
|
||||
// B
|
||||
m[10] = (c[10] * a[0]) + (c[11] * a[5]) + (c[12] * a[10]) + (c[13] * a[15]);
|
||||
m[11] = (c[10] * a[1]) + (c[11] * a[6]) + (c[12] * a[11]) + (c[13] * a[16]);
|
||||
m[12] = (c[10] * a[2]) + (c[11] * a[7]) + (c[12] * a[12]) + (c[13] * a[17]);
|
||||
m[13] = (c[10] * a[3]) + (c[11] * a[8]) + (c[12] * a[13]) + (c[13] * a[18]);
|
||||
m[14] = (c[10] * a[4]) + (c[11] * a[9]) + (c[12] * a[14]) + (c[13] * a[19]) + c[14];
|
||||
// B
|
||||
(c[10] * a[0]) + (c[11] * a[5]) + (c[12] * a[10]) + (c[13] * a[15]),
|
||||
(c[10] * a[1]) + (c[11] * a[6]) + (c[12] * a[11]) + (c[13] * a[16]),
|
||||
(c[10] * a[2]) + (c[11] * a[7]) + (c[12] * a[12]) + (c[13] * a[17]),
|
||||
(c[10] * a[3]) + (c[11] * a[8]) + (c[12] * a[13]) + (c[13] * a[18]),
|
||||
(c[10] * a[4]) + (c[11] * a[9]) + (c[12] * a[14]) + (c[13] * a[19]) + c[14],
|
||||
|
||||
// A
|
||||
m[15] = (c[15] * a[0]) + (c[16] * a[5]) + (c[17] * a[10]) + (c[18] * a[15]);
|
||||
m[16] = (c[15] * a[1]) + (c[16] * a[6]) + (c[17] * a[11]) + (c[18] * a[16]);
|
||||
m[17] = (c[15] * a[2]) + (c[16] * a[7]) + (c[17] * a[12]) + (c[18] * a[17]);
|
||||
m[18] = (c[15] * a[3]) + (c[16] * a[8]) + (c[17] * a[13]) + (c[18] * a[18]);
|
||||
m[19] = (c[15] * a[4]) + (c[16] * a[9]) + (c[17] * a[14]) + (c[18] * a[19]) + c[19];
|
||||
// A
|
||||
(c[15] * a[0]) + (c[16] * a[5]) + (c[17] * a[10]) + (c[18] * a[15]),
|
||||
(c[15] * a[1]) + (c[16] * a[6]) + (c[17] * a[11]) + (c[18] * a[16]),
|
||||
(c[15] * a[2]) + (c[16] * a[7]) + (c[17] * a[12]) + (c[18] * a[17]),
|
||||
(c[15] * a[3]) + (c[16] * a[8]) + (c[17] * a[13]) + (c[18] * a[18]),
|
||||
(c[15] * a[4]) + (c[16] * a[9]) + (c[17] * a[14]) + (c[18] * a[19]) + c[19]
|
||||
|
||||
]);
|
||||
|
||||
this._dirty = true;
|
||||
|
||||
|
@ -641,4 +572,114 @@ var ColorMatrix = new Class({
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for black_white operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.BLACK_WHITE
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.BLACK_WHITE = [ 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for negative operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.NEGATIVE
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.NEGATIVE = [ -1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for desatured luminance operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.DESATURATE_LUMINANCE
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.DESATURATE_LUMINANCE = [ 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for sepia operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.SEPIA
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.SEPIA = [ 0.393, 0.7689999, 0.18899999, 0, 0, 0.349, 0.6859999, 0.16799999, 0, 0, 0.272, 0.5339999, 0.13099999, 0, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for lsd operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.LSD
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.LSD = [ 2, -0.4, 0.5, 0, 0, -0.5, 2, -0.4, 0, 0, -0.4, -0.5, 3, 0, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for brown operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.BROWN
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.BROWN = [ 0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for vintage pinhole operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.VINTAGE
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.VINTAGE = [ 0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for kodachrome operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.KODACHROME
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.KODACHROME = [ 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for technicolor operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.TECHNICOLOR
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.TECHNICOLOR = [ 1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for polaroid shift operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.POLAROID
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.POLAROID = [ 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
/**
|
||||
* A constant array used by the ColorMatrix class for shift BGR operations.
|
||||
*
|
||||
* @name Phaser.Display.ColorMatrix.SHIFT_BGR
|
||||
* @const
|
||||
* @type {number[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
ColorMatrix.SHIFT_BGR = [ 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 ];
|
||||
|
||||
module.exports = ColorMatrix;
|
||||
|
|
|
@ -15,7 +15,7 @@ var Graphics = require('./Graphics');
|
|||
* @method Phaser.GameObjects.GameObjectCreator#graphics
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Types.GameObjects.Graphics.Options} config - The configuration object this Game Object will use to create itself.
|
||||
* @param {Phaser.Types.GameObjects.Graphics.Options} [config] - The configuration object this Game Object will use to create itself.
|
||||
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} The Game Object that was created.
|
||||
|
|
|
@ -728,7 +728,7 @@ var ParticleEmitter = new Class({
|
|||
* @type {boolean}
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
* @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame
|
||||
* @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitterFrame
|
||||
*/
|
||||
this.randomFrame = true;
|
||||
|
||||
|
@ -739,7 +739,7 @@ var ParticleEmitter = new Class({
|
|||
* @type {number}
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
* @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame
|
||||
* @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitterFrame
|
||||
*/
|
||||
this.frameQuantity = 1;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @property {string} [fontFamily='Courier'] - The font the Text object will render with. This is a Canvas style font string.
|
||||
* @property {string} [fontSize='16px'] - The font size, as a CSS size string.
|
||||
* @property {(number|string)} [fontSize='16px'] - The font size, as a CSS size string.
|
||||
* @property {string} [fontStyle] - Any addition font styles, such as 'strong'.
|
||||
* @property {string} [font] - The font family or font settings to set. Overrides the other font settings.
|
||||
* @property {string} [backgroundColor] - A solid fill color that is rendered behind the Text object. Given as a CSS string color such as `#ff0`.
|
||||
|
@ -25,4 +25,5 @@
|
|||
* @property {number} [baselineY=1.4] - The amount of vertical padding added to the height of the text when calculating the font metrics.
|
||||
* @property {Phaser.Types.GameObjects.Text.TextWordWrap} [wordWrap] - The Text Word wrap configuration object.
|
||||
* @property {Phaser.Types.GameObjects.Text.TextMetrics} [metrics] - A Text Metrics object. Use this to avoid expensive font size calculations in text heavy games.
|
||||
* @property {number} [lineSpacing] - The amount to add to the font height to achieve the overall line height.
|
||||
*/
|
||||
|
|
|
@ -116,6 +116,8 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
|
|||
|
||||
if (!urlConfig)
|
||||
{
|
||||
console.warn('No audio URLs for "%s" matched this device', key);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -2465,11 +2465,13 @@ var Body = new Class({
|
|||
if (left)
|
||||
{
|
||||
blocked.left = true;
|
||||
blocked.none = false;
|
||||
}
|
||||
|
||||
if (right)
|
||||
{
|
||||
blocked.right = true;
|
||||
blocked.none = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2501,11 +2503,13 @@ var Body = new Class({
|
|||
if (up)
|
||||
{
|
||||
blocked.up = true;
|
||||
blocked.none = false;
|
||||
}
|
||||
|
||||
if (down)
|
||||
{
|
||||
blocked.down = true;
|
||||
blocked.none = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -526,6 +526,10 @@ var WebGLRenderer = new Class({
|
|||
*
|
||||
* For more details see https://webglfundamentals.org/webgl/lessons/webgl-3d-textures.html
|
||||
*
|
||||
* As of v3.60 no mipmaps will be generated unless a string is given in
|
||||
* the game config. This saves on VRAM use when it may not be required.
|
||||
* To obtain the previous result set the property to `LINEAR` in the config.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.WebGLRenderer#mipmapFilter
|
||||
* @type {GLenum}
|
||||
* @since 3.21.0
|
||||
|
@ -771,7 +775,10 @@ var WebGLRenderer = new Class({
|
|||
gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, clearColor.alphaGL);
|
||||
|
||||
// Mipmaps
|
||||
this.mipmapFilter = gl[config.mipmapFilter];
|
||||
if (config.mipmapFilter !== '')
|
||||
{
|
||||
this.mipmapFilter = gl[config.mipmapFilter];
|
||||
}
|
||||
|
||||
// Check maximum supported textures
|
||||
this.maxTextures = Utils.checkShaderMax(gl, config.maxTextures);
|
||||
|
@ -1694,7 +1701,7 @@ var WebGLRenderer = new Class({
|
|||
|
||||
if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias)
|
||||
{
|
||||
minFilter = (pow) ? this.mipmapFilter : gl.LINEAR;
|
||||
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
|
||||
magFilter = gl.LINEAR;
|
||||
}
|
||||
|
||||
|
@ -2665,7 +2672,7 @@ var WebGLRenderer = new Class({
|
|||
|
||||
if (this.config.antialias)
|
||||
{
|
||||
minFilter = (pow) ? this.mipmapFilter : gl.LINEAR;
|
||||
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
|
||||
magFilter = gl.LINEAR;
|
||||
}
|
||||
|
||||
|
@ -2755,7 +2762,7 @@ var WebGLRenderer = new Class({
|
|||
|
||||
if (this.config.antialias)
|
||||
{
|
||||
minFilter = (pow) ? this.mipmapFilter : gl.LINEAR;
|
||||
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
|
||||
magFilter = gl.LINEAR;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
var BlendModes = require('../../BlendModes');
|
||||
var CenterOn = require('../../../geom/rectangle/CenterOn');
|
||||
var Class = require('../../../utils/Class');
|
||||
var ColorMatrixFS = require('../shaders/ColorMatrix-frag.js');
|
||||
var GetFastValue = require('../../../utils/object/GetFastValue');
|
||||
var MultiPipeline = require('./MultiPipeline');
|
||||
var PostFXFS = require('../shaders/PostFX-frag.js');
|
||||
|
@ -71,6 +72,10 @@ var SpriteFXPipeline = new Class({
|
|||
name: 'DrawGame',
|
||||
fragShader: drawShader,
|
||||
vertShader: SingleQuadVS
|
||||
},
|
||||
{
|
||||
name: 'ColorMatrix',
|
||||
fragShader: ColorMatrixFS
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -133,6 +138,17 @@ var SpriteFXPipeline = new Class({
|
|||
*/
|
||||
this.gameShader;
|
||||
|
||||
/**
|
||||
* A reference to the Color Matrix Shader belonging to this Pipeline.
|
||||
*
|
||||
* This property is set during the `boot` method.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline#colorMatrixShader
|
||||
* @type {Phaser.Renderer.WebGL.WebGLShader}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.colorMatrixShader;
|
||||
|
||||
/**
|
||||
* Raw byte buffer of vertices used specifically during the copySprite method.
|
||||
*
|
||||
|
@ -219,6 +235,7 @@ var SpriteFXPipeline = new Class({
|
|||
this.drawSpriteShader = shaders[0];
|
||||
this.copyShader = shaders[1];
|
||||
this.gameShader = shaders[2];
|
||||
this.colorMatrixShader = shaders[3];
|
||||
|
||||
// Our full-screen target (exclusive to this pipeline)
|
||||
this.fsTarget = new RenderTarget(renderer, renderer.width, renderer.height, 1, 0, true, true);
|
||||
|
@ -455,18 +472,22 @@ var SpriteFXPipeline = new Class({
|
|||
* the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you
|
||||
* to use them to set shader uniforms and other values.
|
||||
*
|
||||
* You can optionally pass in a ColorMatrix. If so, it will use the ColorMatrix shader
|
||||
* during the copy, allowing you to manipulate the colors to a fine degree.
|
||||
* See the `ColorMatrix` class for more details.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline#copySprite
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGL.RenderTarget} source - The source Render Target being copied from.
|
||||
* @param {Phaser.Renderer.WebGL.RenderTarget} target - The target Render Target that will be copied to.
|
||||
* @param {Phaser.GameObjects.Sprite} gameObject - The Sprite being copied.
|
||||
* @param {boolean} [clear=true] - Clear the target before copying?
|
||||
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
|
||||
* @param {boolean} [eraseMode=false] - Erase source from target using ERASE Blend Mode?
|
||||
* @param {Phaser.Display.ColorMatrix} [colorMatrix] - Optional ColorMatrix to use when copying the Sprite.
|
||||
* @param {Phaser.Renderer.WebGL.WebGLShader} [shader] - The shader to use to copy the target. Defaults to the `copyShader`.
|
||||
*/
|
||||
copySprite: function (source, target, clear, clearAlpha, eraseMode, shader)
|
||||
copySprite: function (source, target, clear, clearAlpha, eraseMode, colorMatrix, shader)
|
||||
{
|
||||
if (clear === undefined) { clear = true; }
|
||||
if (clearAlpha === undefined) { clearAlpha = true; }
|
||||
|
@ -476,6 +497,11 @@ var SpriteFXPipeline = new Class({
|
|||
var gl = this.gl;
|
||||
var sprite = this.tempSprite;
|
||||
|
||||
if (colorMatrix)
|
||||
{
|
||||
shader = this.colorMatrixShader;
|
||||
}
|
||||
|
||||
this.currentShader = shader;
|
||||
|
||||
var wasBound = this.setVertexBuffer(this.quadVertexBuffer);
|
||||
|
@ -488,6 +514,12 @@ var SpriteFXPipeline = new Class({
|
|||
|
||||
this.onCopySprite(source, target, sprite);
|
||||
|
||||
if (colorMatrix)
|
||||
{
|
||||
this.set1fv('uColorMatrix', colorMatrix.getData());
|
||||
this.set1f('uAlpha', colorMatrix.alpha);
|
||||
}
|
||||
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, source.texture);
|
||||
|
||||
|
@ -811,6 +843,7 @@ var SpriteFXPipeline = new Class({
|
|||
this.drawSpriteShader = null;
|
||||
this.copyShader = null;
|
||||
this.gameShader = null;
|
||||
this.colorMatrixShader = null;
|
||||
|
||||
this.quadVertexData = null;
|
||||
this.quadVertexBuffer = null;
|
||||
|
|
Loading…
Reference in a new issue