diff --git a/src/renderer/webgl/DrawingContext.js b/src/renderer/webgl/DrawingContext.js index 374a0b8f3..77762fda8 100644 --- a/src/renderer/webgl/DrawingContext.js +++ b/src/renderer/webgl/DrawingContext.js @@ -165,6 +165,30 @@ var DrawingContext = new Class({ */ this.inUse = false; + /** + * Whether to override the camera's roundPixels setting + * with the DrawingContext's own setting. + * + * @name Phaser.Renderer.WebGL.DrawingContext#overrideRoundPixels + * @type {boolean} + * @default false + * @since 3.90.0 + */ + this.overrideRoundPixels = false; + + /** + * Whether to round the camera's position before rendering. + * + * This value is taken from the camera's `roundPixels` property + * when `setCamera` is called if `overrideRoundPixels` is `false`. + * + * @name Phaser.Renderer.WebGL.DrawingContext#roundPixels + * @type {boolean} + * @default false + * @since 3.90.0 + */ + this.roundPixels = false; + if (options.autoResize) { this.renderer.on(Events.RESIZE, this.resize, this); @@ -254,6 +278,8 @@ var DrawingContext = new Class({ this.texture = source.texture; this.camera = source.camera; this.blendMode = source.blendMode; + this.overrideRoundPixels = source.overrideRoundPixels; + this.roundPixels = source.roundPixels; this.state = { bindings: @@ -362,6 +388,11 @@ var DrawingContext = new Class({ setCamera: function (camera) { this.camera = camera; + + if (!this.overrideRoundPixels) + { + this.roundPixels = camera ? camera.roundPixels : false; + } }, /** diff --git a/src/renderer/webgl/renderNodes/BatchHandlerQuad.js b/src/renderer/webgl/renderNodes/BatchHandlerQuad.js index 131128aed..84b31e78b 100644 --- a/src/renderer/webgl/renderNodes/BatchHandlerQuad.js +++ b/src/renderer/webgl/renderNodes/BatchHandlerQuad.js @@ -194,7 +194,7 @@ var BatchHandlerQuad = new Class({ { this.program.setUniform( 'uRoundPixels', - drawingContext.camera.roundPixels + drawingContext.roundPixels ); }, diff --git a/src/renderer/webgl/renderNodes/BatchHandlerQuadLight.js b/src/renderer/webgl/renderNodes/BatchHandlerQuadLight.js index 4ad11f27c..9a8755d97 100644 --- a/src/renderer/webgl/renderNodes/BatchHandlerQuadLight.js +++ b/src/renderer/webgl/renderNodes/BatchHandlerQuadLight.js @@ -149,6 +149,10 @@ var BatchHandlerQuadLight = new Class({ var vec = this._lightVector; var height = this.manager.renderer.height; + program.setUniform( + 'uRoundPixels', + drawingContext.roundPixels + ); program.setUniform( 'uCamera', [