From 3b06e3c987c18a72359e54dc17afa20c75b518f9 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 28 Aug 2015 19:11:50 -0400 Subject: [PATCH 1/6] Handle uniform precision mismatches --- Source/Renderer/Context.js | 3 ++ Source/Renderer/ContextLimits.js | 15 +++++- Source/Renderer/ShaderProgram.js | 71 +++++++++++++++++++++++++---- Source/Renderer/ShaderSource.js | 3 ++ Specs/Renderer/ShaderProgramSpec.js | 28 +++++++++++- 5 files changed, 109 insertions(+), 11 deletions(-) diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index a713077342c5..7d0d3abc7562 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -263,6 +263,9 @@ define([ ContextLimits._maximumViewportWidth = maximumViewportDimensions[0]; ContextLimits._maximumViewportHeight = maximumViewportDimensions[1]; + var highp = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); + ContextLimits._highpSupported = highp.precision !== 0; + this._antialias = gl.getContextAttributes().antialias; // Query and initialize extensions diff --git a/Source/Renderer/ContextLimits.js b/Source/Renderer/ContextLimits.js index 6dc1736d002a..f46b9b045aa8 100644 --- a/Source/Renderer/ContextLimits.js +++ b/Source/Renderer/ContextLimits.js @@ -27,7 +27,8 @@ define([ _maximumViewportHeight : 0, _maximumTextureFilterAnisotropy : 0, _maximumDrawBuffers : 0, - _maximumColorAttachments : 0 + _maximumColorAttachments : 0, + _highpSupported : false }; defineProperties(ContextLimits, { @@ -264,7 +265,19 @@ define([ get: function () { return ContextLimits._maximumColorAttachments; } + }, + + /** + * High precision supported in fragment shaders + * @memberof ContextLimits + * @type {Boolean} + */ + highpSupported : { + get: function () { + return ContextLimits._highpSupported; + } } + }); return ContextLimits; diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index 6ff6ce0a582c..a6fab8df08fb 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -7,6 +7,7 @@ define([ '../Core/DeveloperError', '../Core/RuntimeError', './AutomaticUniforms', + './ContextLimits', './createUniform', './createUniformArray' ], function( @@ -17,6 +18,7 @@ define([ DeveloperError, RuntimeError, AutomaticUniforms, + ContextLimits, createUniform, createUniformArray) { "use strict"; @@ -27,7 +29,51 @@ define([ /** * @private */ + + function extractUniforms(shaderText) { + // TODO: regex doesn't work for inline structs + var uniformNames = []; + var uniformLines = shaderText.match(/uniform[\w\s]*(?=[=\[;])/g); + if (uniformLines) { + for (var i = 0; i < uniformLines.length; i++) { + var line = uniformLines[i].trim(); + var name = line.slice(line.lastIndexOf(' ') + 1); + uniformNames.push(name); + } + } + return uniformNames; + } + var ShaderProgram = function(options) { + // If a uniform exists in both the vertex and fragment shader but with different precision qualifiers, + // give the fragment shader uniform a different name. This fixes shader compilation errors on devices + // that only support mediump in the fragment shader. + var vertexShaderText = options.vertexShaderText; + var fragmentShaderText = options.fragmentShaderText; + var duplicateUniformNames = {}; + + if (!ContextLimits.highpSupported) { + var vertexShaderUniforms = extractUniforms(vertexShaderText); + var fragmentShaderUniforms = extractUniforms(fragmentShaderText); + + // Find uniforms used in both + var i, j; + var uniformName; + var duplicateName; + for (i = 0; i < vertexShaderUniforms.length; i++) { + for (j = 0; j < fragmentShaderUniforms.length; j++) { + if (vertexShaderUniforms[i] === fragmentShaderUniforms[j]) { + uniformName = vertexShaderUniforms[i]; + duplicateName = uniformName + "_f"; + // Update fragmentShaderText with renamed uniforms + var re = new RegExp(uniformName + "\\b", "g"); + fragmentShaderText = fragmentShaderText.replace(re, duplicateName); + duplicateUniformNames[duplicateName] = uniformName; + } + } + } + } + this._gl = options.gl; this._logShaderCompilation = options.logShaderCompilation; this._debugShaders = options.debugShaders; @@ -40,6 +86,7 @@ define([ this._uniforms = undefined; this._automaticUniforms = undefined; this._manualUniforms = undefined; + this._duplicateUniformNames = duplicateUniformNames; this._cachedShader = undefined; // Used by ShaderCache /** @@ -48,9 +95,9 @@ define([ this.maximumTextureUnitIndex = undefined; this._vertexShaderSource = options.vertexShaderSource; - this._vertexShaderText = options.vertexShaderText; + this._vertexShaderText = vertexShaderText; this._fragmentShaderSource = options.fragmentShaderSource; - this._fragmentShaderText = options.fragmentShaderText; + this._fragmentShaderText = fragmentShaderText; /** * @private @@ -346,20 +393,28 @@ define([ }; } - function partitionUniforms(uniforms) { + function partitionUniforms(shader, uniforms) { var automaticUniforms = []; var manualUniforms = []; - for ( var uniform in uniforms) { + for (var uniform in uniforms) { if (uniforms.hasOwnProperty(uniform)) { - var automaticUniform = AutomaticUniforms[uniform]; + var uniformObject = uniforms[uniform]; + var uniformName = uniform; + // if a duplicate uniform, use it's original name so it is updated correctly + var duplicateUniform = shader._duplicateUniformNames[uniformName]; + if (duplicateUniform) { + uniformObject.name = duplicateUniform; + uniformName = duplicateUniform; + } + var automaticUniform = AutomaticUniforms[uniformName]; if (automaticUniform) { automaticUniforms.push({ - uniform : uniforms[uniform], + uniform : uniformObject, automaticUniform : automaticUniform }); } else { - manualUniforms.push(uniforms[uniform]); + manualUniforms.push(uniformObject); } } } @@ -393,7 +448,7 @@ define([ var program = createAndLinkProgram(gl, shader, shader._debugShaders); var numberOfVertexAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); var uniforms = findUniforms(gl, program); - var partitionedUniforms = partitionUniforms(uniforms.uniformsByName); + var partitionedUniforms = partitionUniforms(shader, uniforms.uniformsByName); shader._program = program; shader._numberOfVertexAttributes = numberOfVertexAttributes; diff --git a/Source/Renderer/ShaderSource.js b/Source/Renderer/ShaderSource.js index beef3d4bc975..fd1827ae2263 100644 --- a/Source/Renderer/ShaderSource.js +++ b/Source/Renderer/ShaderSource.js @@ -14,6 +14,9 @@ define([ "use strict"; function removeComments(source) { + // remove inline comments + source = source.replace(/\/\/.*/g, ''); + // remove multiline comment block return source.replace(/\/\*\*[\s\S]*?\*\//gm, function(match) { // preserve the number of lines in the comment block so the line numbers will be correct when debugging shaders var numberOfLines = match.match(/\n/gm).length; diff --git a/Specs/Renderer/ShaderProgramSpec.js b/Specs/Renderer/ShaderProgramSpec.js index b74b43a19de8..f0a4d8d6121e 100644 --- a/Specs/Renderer/ShaderProgramSpec.js +++ b/Specs/Renderer/ShaderProgramSpec.js @@ -12,6 +12,7 @@ defineSuite([ 'Renderer/Buffer', 'Renderer/BufferUsage', 'Renderer/ClearCommand', + 'Renderer/ContextLimits', 'Renderer/DrawCommand', 'Renderer/ShaderSource', 'Renderer/VertexArray', @@ -29,6 +30,7 @@ defineSuite([ Buffer, BufferUsage, ClearCommand, + ContextLimits, DrawCommand, ShaderSource, VertexArray, @@ -77,7 +79,7 @@ defineSuite([ } }); - function renderFragment(context, shaderProgram) { + function renderFragment(context, shaderProgram, uniformMap) { va = new VertexArray({ context : context, attributes : [{ @@ -97,7 +99,8 @@ defineSuite([ var command = new DrawCommand({ primitiveType : PrimitiveType.POINTS, shaderProgram : shaderProgram, - vertexArray : va + vertexArray : va, + uniformMap : uniformMap }); command.execute(context); @@ -355,6 +358,27 @@ defineSuite([ expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]); }); + it('creates duplicate uniforms if precision of uniforms in vertex and fragment shader do not match', function() { + var highpSupported = ContextLimits.highpSupported; + ContextLimits._highpSupported = false; + var vs = 'attribute vec4 position; uniform float u_value; varying float v_value; void main() { gl_PointSize = 1.0; v_value = u_value + czm_viewport.z*0.2; gl_Position = position; }'; + var fs = 'uniform float u_value; varying float v_value; void main() { gl_FragColor = vec4(u_value + v_value + czm_viewport.z*0.2); }'; + sp = ShaderProgram.fromCache({ + context : context, + vertexShaderSource : vs, + fragmentShaderSource : fs + }); + var uniformMap = { + u_value : function() { + return 0.2; + } + }; + expect(sp.allUniforms.u_value).toBeDefined(); + expect(sp.allUniforms.u_value_f).toBeDefined(); + expect(renderFragment(context, sp, uniformMap)).toEqual([204, 204, 204, 204]); + ContextLimits._highpSupported = highpSupported; + }); + it('1 level function dependency', function() { var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }'; var fs = From e26d737beb83220e12d700e35180286ed71c620c Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Mon, 31 Aug 2015 06:16:54 -0400 Subject: [PATCH 2/6] Tweak doc --- Source/Renderer/ContextLimits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Renderer/ContextLimits.js b/Source/Renderer/ContextLimits.js index f46b9b045aa8..cd8e3b8bf73b 100644 --- a/Source/Renderer/ContextLimits.js +++ b/Source/Renderer/ContextLimits.js @@ -268,7 +268,7 @@ define([ }, /** - * High precision supported in fragment shaders + * High precision supported (highp) in fragment shaders. * @memberof ContextLimits * @type {Boolean} */ From 7c08b664eb5cb76c427c3438f1c1406943040c51 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Mon, 31 Aug 2015 06:53:19 -0400 Subject: [PATCH 3/6] Tweak comment --- Source/Renderer/ShaderProgram.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index a6fab8df08fb..cb87828dd6a7 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -401,7 +401,7 @@ define([ if (uniforms.hasOwnProperty(uniform)) { var uniformObject = uniforms[uniform]; var uniformName = uniform; - // if a duplicate uniform, use it's original name so it is updated correctly + // if it's a duplicate uniform, use its original name so it is updated correctly var duplicateUniform = shader._duplicateUniformNames[uniformName]; if (duplicateUniform) { uniformObject.name = duplicateUniform; From c9e9c64ebea1e6addc7b47f7b3ce6c000c163be6 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Aug 2015 11:05:42 -0400 Subject: [PATCH 4/6] Improvements to uniform mediump checking --- Source/Renderer/Context.js | 6 +- Source/Renderer/ContextLimits.js | 20 ++++-- Source/Renderer/ShaderProgram.js | 103 +++++++++++++++------------- Specs/Renderer/ShaderProgramSpec.js | 16 ++--- 4 files changed, 84 insertions(+), 61 deletions(-) diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 7d0d3abc7562..97fd75210780 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -263,8 +263,10 @@ define([ ContextLimits._maximumViewportWidth = maximumViewportDimensions[0]; ContextLimits._maximumViewportHeight = maximumViewportDimensions[1]; - var highp = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); - ContextLimits._highpSupported = highp.precision !== 0; + var highpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); + ContextLimits._highpFloatSupported = highpFloat.precision !== 0; + var highpInt = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT); + ContextLimits._highpIntSupported = highpInt.rangeMax !== 0; this._antialias = gl.getContextAttributes().antialias; diff --git a/Source/Renderer/ContextLimits.js b/Source/Renderer/ContextLimits.js index cd8e3b8bf73b..00c4bebce99a 100644 --- a/Source/Renderer/ContextLimits.js +++ b/Source/Renderer/ContextLimits.js @@ -28,7 +28,8 @@ define([ _maximumTextureFilterAnisotropy : 0, _maximumDrawBuffers : 0, _maximumColorAttachments : 0, - _highpSupported : false + _highpFloatSupported: false, + _highpIntSupported: false }; defineProperties(ContextLimits, { @@ -268,13 +269,24 @@ define([ }, /** - * High precision supported (highp) in fragment shaders. + * High precision float supported (highp) in fragment shaders. * @memberof ContextLimits * @type {Boolean} */ - highpSupported : { + highpFloatSupported : { get: function () { - return ContextLimits._highpSupported; + return ContextLimits._highpFloatSupported; + } + }, + + /** + * High precision int supported (highp) in fragment shaders. + * @memberof ContextLimits + * @type {Boolean} + */ + highpIntSupported : { + get: function () { + return ContextLimits._highpIntSupported; } } diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index cb87828dd6a7..5083aee851a1 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -2,6 +2,7 @@ define([ '../Core/defaultValue', '../Core/defined', + '../Core/definedNotNull', '../Core/defineProperties', '../Core/destroyObject', '../Core/DeveloperError', @@ -13,6 +14,7 @@ define([ ], function( defaultValue, defined, + definedNotNull, defineProperties, destroyObject, DeveloperError, @@ -29,50 +31,9 @@ define([ /** * @private */ - - function extractUniforms(shaderText) { - // TODO: regex doesn't work for inline structs - var uniformNames = []; - var uniformLines = shaderText.match(/uniform[\w\s]*(?=[=\[;])/g); - if (uniformLines) { - for (var i = 0; i < uniformLines.length; i++) { - var line = uniformLines[i].trim(); - var name = line.slice(line.lastIndexOf(' ') + 1); - uniformNames.push(name); - } - } - return uniformNames; - } - var ShaderProgram = function(options) { - // If a uniform exists in both the vertex and fragment shader but with different precision qualifiers, - // give the fragment shader uniform a different name. This fixes shader compilation errors on devices - // that only support mediump in the fragment shader. - var vertexShaderText = options.vertexShaderText; - var fragmentShaderText = options.fragmentShaderText; - var duplicateUniformNames = {}; - if (!ContextLimits.highpSupported) { - var vertexShaderUniforms = extractUniforms(vertexShaderText); - var fragmentShaderUniforms = extractUniforms(fragmentShaderText); - - // Find uniforms used in both - var i, j; - var uniformName; - var duplicateName; - for (i = 0; i < vertexShaderUniforms.length; i++) { - for (j = 0; j < fragmentShaderUniforms.length; j++) { - if (vertexShaderUniforms[i] === fragmentShaderUniforms[j]) { - uniformName = vertexShaderUniforms[i]; - duplicateName = uniformName + "_f"; - // Update fragmentShaderText with renamed uniforms - var re = new RegExp(uniformName + "\\b", "g"); - fragmentShaderText = fragmentShaderText.replace(re, duplicateName); - duplicateUniformNames[duplicateName] = uniformName; - } - } - } - } + var result = handleUniformPrecisionMismatches(options.vertexShaderText, options.fragmentShaderText); this._gl = options.gl; this._logShaderCompilation = options.logShaderCompilation; @@ -86,7 +47,7 @@ define([ this._uniforms = undefined; this._automaticUniforms = undefined; this._manualUniforms = undefined; - this._duplicateUniformNames = duplicateUniformNames; + this._duplicateUniformNames = result.duplicateUniformNames; this._cachedShader = undefined; // Used by ShaderCache /** @@ -95,9 +56,9 @@ define([ this.maximumTextureUnitIndex = undefined; this._vertexShaderSource = options.vertexShaderSource; - this._vertexShaderText = vertexShaderText; + this._vertexShaderText = options.vertexShaderText; this._fragmentShaderSource = options.fragmentShaderSource; - this._fragmentShaderText = fragmentShaderText; + this._fragmentShaderText = result.fragmentShaderText; /** * @private @@ -174,6 +135,54 @@ define([ } }); + function extractUniforms(shaderText) { + var uniformNames = []; + var uniformLines = shaderText.match(/uniform.*?(?![^{]*})(?=[=\[;])/g); + if (definedNotNull(uniformLines)) { + var len = uniformLines.length; + for (var i = 0; i < len; i++) { + var line = uniformLines[i].trim(); + var name = line.slice(line.lastIndexOf(' ') + 1); + uniformNames.push(name); + } + } + return uniformNames; + } + + function handleUniformPrecisionMismatches(vertexShaderText, fragmentShaderText) { + // If a uniform exists in both the vertex and fragment shader but with different precision qualifiers, + // give the fragment shader uniform a different name. This fixes shader compilation errors on devices + // that only support mediump in the fragment shader. + var duplicateUniformNames = {}; + + if (!ContextLimits.highpFloatSupported || !ContextLimits.highpIntSupported) { + var i, j; + var uniformName; + var duplicateName; + var vertexShaderUniforms = extractUniforms(vertexShaderText); + var fragmentShaderUniforms = extractUniforms(fragmentShaderText); + var vertexUniformsCount = vertexShaderUniforms.length; + var fragmentUniformsCount = fragmentShaderUniforms.length; + + for (i = 0; i < vertexUniformsCount; i++) { + for (j = 0; j < fragmentUniformsCount; j++) { + if (vertexShaderUniforms[i] === fragmentShaderUniforms[j]) { + uniformName = vertexShaderUniforms[i]; + duplicateName = "czm_mediump_" + uniformName; + // Update fragmentShaderText with renamed uniforms + var re = new RegExp(uniformName + "\\b", "g"); + fragmentShaderText = fragmentShaderText.replace(re, duplicateName); + duplicateUniformNames[duplicateName] = uniformName; + } + } + } + } + return { + fragmentShaderText : fragmentShaderText, + duplicateUniformNames : duplicateUniformNames + }; + } + var consolePrefix = '[Cesium WebGL] '; function createAndLinkProgram(gl, shader) { @@ -403,12 +412,12 @@ define([ var uniformName = uniform; // if it's a duplicate uniform, use its original name so it is updated correctly var duplicateUniform = shader._duplicateUniformNames[uniformName]; - if (duplicateUniform) { + if (defined(duplicateUniform)) { uniformObject.name = duplicateUniform; uniformName = duplicateUniform; } var automaticUniform = AutomaticUniforms[uniformName]; - if (automaticUniform) { + if (defined(automaticUniform)) { automaticUniforms.push({ uniform : uniformObject, automaticUniform : automaticUniform diff --git a/Specs/Renderer/ShaderProgramSpec.js b/Specs/Renderer/ShaderProgramSpec.js index f0a4d8d6121e..b263077425da 100644 --- a/Specs/Renderer/ShaderProgramSpec.js +++ b/Specs/Renderer/ShaderProgramSpec.js @@ -359,10 +359,10 @@ defineSuite([ }); it('creates duplicate uniforms if precision of uniforms in vertex and fragment shader do not match', function() { - var highpSupported = ContextLimits.highpSupported; - ContextLimits._highpSupported = false; - var vs = 'attribute vec4 position; uniform float u_value; varying float v_value; void main() { gl_PointSize = 1.0; v_value = u_value + czm_viewport.z*0.2; gl_Position = position; }'; - var fs = 'uniform float u_value; varying float v_value; void main() { gl_FragColor = vec4(u_value + v_value + czm_viewport.z*0.2); }'; + var highpFloatSupported = ContextLimits.highpFloatSupported; + ContextLimits._highpFloatSupported = false; + var vs = 'attribute vec4 position; uniform float u_value; varying float v_value; void main() { gl_PointSize = 1.0; v_value = u_value * czm_viewport.z; gl_Position = position; }'; + var fs = 'uniform float u_value; varying float v_value; void main() { gl_FragColor = vec4(u_value * v_value * czm_viewport.z); }'; sp = ShaderProgram.fromCache({ context : context, vertexShaderSource : vs, @@ -370,13 +370,13 @@ defineSuite([ }); var uniformMap = { u_value : function() { - return 0.2; + return 1.0; } }; expect(sp.allUniforms.u_value).toBeDefined(); - expect(sp.allUniforms.u_value_f).toBeDefined(); - expect(renderFragment(context, sp, uniformMap)).toEqual([204, 204, 204, 204]); - ContextLimits._highpSupported = highpSupported; + expect(sp.allUniforms.czm_mediump_u_value).toBeDefined(); + expect(renderFragment(context, sp, uniformMap)).not.toEqual([0, 0, 0, 0]); + ContextLimits._highpFloatSupported = highpFloatSupported; }); it('1 level function dependency', function() { From 53d8e480bd9fa7e256d0369aeb36e450fdd16e1a Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Mon, 31 Aug 2015 11:22:45 -0400 Subject: [PATCH 5/6] Tweak local naming and whitespace --- Source/Renderer/ShaderProgram.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index 5083aee851a1..6fb773864074 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -32,8 +32,7 @@ define([ * @private */ var ShaderProgram = function(options) { - - var result = handleUniformPrecisionMismatches(options.vertexShaderText, options.fragmentShaderText); + var modifiedFS = handleUniformPrecisionMismatches(options.vertexShaderText, options.fragmentShaderText); this._gl = options.gl; this._logShaderCompilation = options.logShaderCompilation; @@ -47,7 +46,7 @@ define([ this._uniforms = undefined; this._automaticUniforms = undefined; this._manualUniforms = undefined; - this._duplicateUniformNames = result.duplicateUniformNames; + this._duplicateUniformNames = modifiedFS.duplicateUniformNames; this._cachedShader = undefined; // Used by ShaderCache /** @@ -57,7 +56,7 @@ define([ this._vertexShaderSource = options.vertexShaderSource; this._vertexShaderText = options.vertexShaderText; - this._fragmentShaderSource = options.fragmentShaderSource; + this._fragmentShaderSource = modifiedFS.fragmentShaderSource; this._fragmentShaderText = result.fragmentShaderText; /** @@ -177,6 +176,7 @@ define([ } } } + return { fragmentShaderText : fragmentShaderText, duplicateUniformNames : duplicateUniformNames From 2af0301a9b122b371b63f95ea5f5d010d73306b5 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Mon, 31 Aug 2015 11:23:41 -0400 Subject: [PATCH 6/6] Fix rename --- Source/Renderer/ShaderProgram.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index 6fb773864074..bb5d450e7cfb 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -56,8 +56,8 @@ define([ this._vertexShaderSource = options.vertexShaderSource; this._vertexShaderText = options.vertexShaderText; - this._fragmentShaderSource = modifiedFS.fragmentShaderSource; - this._fragmentShaderText = result.fragmentShaderText; + this._fragmentShaderSource = options.fragmentShaderSource; + this._fragmentShaderText = modifiedFS.fragmentShaderText; /** * @private