From bc5c7cf7abc7471a80f07a7164c75f0a7b18b60b Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 19 Sep 2019 23:32:40 +0100 Subject: [PATCH] When calling `Shader.setRenderToTexture()` it will now draw the shader just once, immediately to the texture, to avoid the texture being blank for a single frame (thanks Kyle) --- CHANGELOG.md | 4 ++++ src/gameobjects/shader/Shader.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4afb3ea95..1c011abf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * `GameConfig.antialiasGL` is a new boolean that allows you to set the `antialias` property of the WebGL context during creation, without impacting any subsequent textures or the canvas CSS. +### Updates + +* When calling `Shader.setRenderToTexture()` it will now draw the shader just once, immediately to the texture, to avoid the texture being blank for a single frame (thanks Kyle) + ### Bug Fixes * `SpineCanvasPlugin.shutdown` would try to dispose of the `sceneRenderer`, but the property isn't set for Canvas. diff --git a/src/gameobjects/shader/Shader.js b/src/gameobjects/shader/Shader.js index 38814022f..ad879217a 100644 --- a/src/gameobjects/shader/Shader.js +++ b/src/gameobjects/shader/Shader.js @@ -454,6 +454,20 @@ var Shader = new Class({ } } + // And now render at least once, so our texture isn't blank on the first update + + if (this.shader) + { + var pipeline = renderer.currentPipeline; + + renderer.clearPipeline(); + + this.load(); + this.flush(); + + renderer.rebindPipeline(pipeline); + } + return this; },