From 848377b8d8c9e372712cdbfa9f15269a106a043e Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 16 Jul 2020 16:59:53 +0100 Subject: [PATCH] The TileSprite Game Objects now support rendering with normal maps. --- .../tilesprite/TileSpriteWebGLRenderer.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js index 5d9545633..b3b46aab2 100644 --- a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js @@ -25,20 +25,32 @@ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, { src.updateCanvas(); + var width = src.width; + var height = src.height; var getTint = Utils.getTintAppendFloatAlpha; + var pipeline = this.pipeline; - this.pipeline.batchTexture( + if (width === 0 || height === 0) + { + return; + } + + renderer.setPipeline(pipeline, src); + + var textureUnit = pipeline.setTexture2D(src.fillPattern, src); + + pipeline.batchTexture( src, src.fillPattern, src.displayFrame.width * src.tileScaleX, src.displayFrame.height * src.tileScaleY, src.x, src.y, - src.width, src.height, + width, height, src.scaleX, src.scaleY, src.rotation, src.flipX, src.flipY, src.scrollFactorX, src.scrollFactorY, - src.originX * src.width, src.originY * src.height, - 0, 0, src.width, src.height, + src.originX * width, src.originY * height, + 0, 0, width, height, getTint(src._tintTL, camera.alpha * src._alphaTL), getTint(src._tintTR, camera.alpha * src._alphaTR), getTint(src._tintBL, camera.alpha * src._alphaBL), @@ -47,7 +59,9 @@ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, (src.tilePositionX % src.displayFrame.width) / src.displayFrame.width, (src.tilePositionY % src.displayFrame.height) / src.displayFrame.height, camera, - parentMatrix + parentMatrix, + false, + textureUnit ); };