From b9c7b79add5502f382a144a0a39454bae84792cf Mon Sep 17 00:00:00 2001 From: gero3 Date: Tue, 21 Jul 2015 10:46:23 +0000 Subject: [PATCH] make sure uniforms don't get loaded when they are not in the shader --- src/renderers/WebGLRenderer.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 9c807a2791..1f4a830e45 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -2132,7 +2132,7 @@ THREE.WebGLRenderer = function ( parameters ) { material instanceof THREE.MeshPhongMaterial || material.envMap ) { - if ( p_uniforms.cameraPosition !== null ) { + if ( p_uniforms.cameraPosition !== undefined ) { _vector3.setFromMatrixPosition( camera.matrixWorld ); _gl.uniform3f( p_uniforms.cameraPosition, _vector3.x, _vector3.y, _vector3.z ); @@ -2147,10 +2147,9 @@ THREE.WebGLRenderer = function ( parameters ) { material instanceof THREE.ShaderMaterial || material.skinning ) { - if ( p_uniforms.viewMatrix !== null ) { + if ( p_uniforms.viewMatrix !== undefined ) { _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, camera.matrixWorldInverse.elements ); - } } @@ -2163,13 +2162,13 @@ THREE.WebGLRenderer = function ( parameters ) { if ( material.skinning ) { - if ( object.bindMatrix && p_uniforms.bindMatrix !== null ) { + if ( object.bindMatrix && p_uniforms.bindMatrix !== undefined ) { _gl.uniformMatrix4fv( p_uniforms.bindMatrix, false, object.bindMatrix.elements ); } - if ( object.bindMatrixInverse && p_uniforms.bindMatrixInverse !== null ) { + if ( object.bindMatrixInverse && p_uniforms.bindMatrixInverse !== undefined ) { _gl.uniformMatrix4fv( p_uniforms.bindMatrixInverse, false, object.bindMatrixInverse.elements ); @@ -2177,7 +2176,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( _supportsBoneTextures && object.skeleton && object.skeleton.useVertexTexture ) { - if ( p_uniforms.boneTexture !== null ) { + if ( p_uniforms.boneTexture !== undefined ) { var textureUnit = getTextureUnit(); @@ -2186,13 +2185,13 @@ THREE.WebGLRenderer = function ( parameters ) { } - if ( p_uniforms.boneTextureWidth !== null ) { + if ( p_uniforms.boneTextureWidth !== undefined ) { _gl.uniform1i( p_uniforms.boneTextureWidth, object.skeleton.boneTextureWidth ); } - if ( p_uniforms.boneTextureHeight !== null ) { + if ( p_uniforms.boneTextureHeight !== undefined ) { _gl.uniform1i( p_uniforms.boneTextureHeight, object.skeleton.boneTextureHeight ); @@ -2200,10 +2199,11 @@ THREE.WebGLRenderer = function ( parameters ) { } else if ( object.skeleton && object.skeleton.boneMatrices ) { - if ( p_uniforms.boneGlobalMatrices !== null ) { + if ( p_uniforms.boneGlobalMatrices !== undefined ) { _gl.uniformMatrix4fv( p_uniforms.boneGlobalMatrices, false, object.skeleton.boneMatrices ); + } } @@ -2301,10 +2301,10 @@ THREE.WebGLRenderer = function ( parameters ) { loadUniformsMatrices( p_uniforms, object ); - if ( p_uniforms.modelMatrix !== null ) { + if ( p_uniforms.modelMatrix !== undefined ) { _gl.uniformMatrix4fv( p_uniforms.modelMatrix, false, object.matrixWorld.elements ); - + } return program; -- GitLab