diff --git a/src/graphics/shader.js b/src/graphics/shader.js index a893a6c4d00..aa043f4a5bd 100644 --- a/src/graphics/shader.js +++ b/src/graphics/shader.js @@ -62,10 +62,6 @@ class Shader { * @private */ init() { - this.attributes = []; - this.uniforms = []; - this.samplers = []; - this.ready = false; this.failed = false; } diff --git a/src/graphics/webgl/webgl-graphics-device.js b/src/graphics/webgl/webgl-graphics-device.js index ebc30ec8c16..3b8fcadbe3e 100644 --- a/src/graphics/webgl/webgl-graphics-device.js +++ b/src/graphics/webgl/webgl-graphics-device.js @@ -1761,8 +1761,8 @@ class WebglGraphicsDevice extends GraphicsDevice { const shader = this.shader; if (!shader) return; - const samplers = shader.samplers; - const uniforms = shader.uniforms; + const samplers = shader.impl.samplers; + const uniforms = shader.impl.uniforms; // vertex buffers if (!keepBuffers) { diff --git a/src/graphics/webgl/webgl-shader.js b/src/graphics/webgl/webgl-shader.js index dda9fd7661d..f5afc06415a 100644 --- a/src/graphics/webgl/webgl-shader.js +++ b/src/graphics/webgl/webgl-shader.js @@ -15,6 +15,10 @@ import { SHADERTAG_MATERIAL, semanticToLocation } from '../constants.js'; class WebglShader { constructor(shader) { + this.uniforms = []; + this.samplers = []; + this.attributes = []; + this.glProgram = null; this.glVertexShader = null; this.glFragmentShader = null; @@ -218,7 +222,7 @@ class WebglShader { shaderInput = new ShaderInput(device, definition.attributes[info.name], device.pcUniformType[info.type], location); - shader.attributes.push(shaderInput); + this.attributes.push(shaderInput); } // Query the program for each shader state (GLSL 'uniform') @@ -233,9 +237,9 @@ class WebglShader { if (info.type === gl.SAMPLER_2D || info.type === gl.SAMPLER_CUBE || (device.webgl2 && (info.type === gl.SAMPLER_2D_SHADOW || info.type === gl.SAMPLER_CUBE_SHADOW || info.type === gl.SAMPLER_3D)) ) { - shader.samplers.push(shaderInput); + this.samplers.push(shaderInput); } else { - shader.uniforms.push(shaderInput); + this.uniforms.push(shaderInput); } }