From 1ad6a64a81b78a825d381f92e419ba0bb7085010 Mon Sep 17 00:00:00 2001 From: Ben Richards Date: Fri, 2 Feb 2024 16:52:50 +1300 Subject: [PATCH] Ensure that Shader render target is correctly updated. --- src/gameobjects/shader/Shader.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gameobjects/shader/Shader.js b/src/gameobjects/shader/Shader.js index f49987f2c..d0d60c2e7 100644 --- a/src/gameobjects/shader/Shader.js +++ b/src/gameobjects/shader/Shader.js @@ -916,6 +916,8 @@ var Shader = new Class({ if (data && !uniform.value.isRenderTexture) { + var wrapper = uniform.value; + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D // mag / minFilter can be: gl.LINEAR, gl.LINEAR_MIPMAP_LINEAR or gl.NEAREST @@ -944,6 +946,8 @@ var Shader = new Class({ // texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels) gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null); + wrapper.width = width; + wrapper.height = height; } else { @@ -955,6 +959,15 @@ var Shader = new Class({ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + + // Update texture wrapper. + wrapper.magFilter = magFilter; + wrapper.minFilter = minFilter; + wrapper.wrapS = wrapS; + wrapper.wrapT = wrapT; + wrapper.format = format; + wrapper.flipY = !!data.flipY; + wrapper.pixels = uniform.source; } this.renderer.setProgram(this.program);