Browse Source

Merge pull request #6367 from dubejf/dev

Reset GL state before rendering sprites and lens
Ricardo Cabello 10 years ago
parent
commit
75782e677d

+ 1 - 0
src/renderers/WebGLRenderer.js

@@ -1726,6 +1726,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		// custom render plugins (post pass)
 
+		this.resetGLState();
 		spritePlugin.render( scene, camera );
 		lensFlarePlugin.render( scene, camera, _currentWidth, _currentHeight );
 

+ 3 - 2
src/renderers/webgl/plugins/LensFlarePlugin.js

@@ -295,8 +295,9 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
 
 		gl.useProgram( program );
 
-		gl.enableVertexAttribArray( attributes.vertex );
-		gl.enableVertexAttribArray( attributes.uv );
+		renderer.state.disableUnusedAttributes();
+		renderer.state.enableAttribute( attributes.vertex );
+		renderer.state.enableAttribute( attributes.uv );
 
 		// loop through all lens flares to update their occlusion and positions
 		// setup gl and common used attribs/unforms

+ 3 - 2
src/renderers/webgl/plugins/SpritePlugin.js

@@ -98,8 +98,9 @@ THREE.SpritePlugin = function ( renderer, sprites ) {
 
 		gl.useProgram( program );
 
-		gl.enableVertexAttribArray( attributes.position );
-		gl.enableVertexAttribArray( attributes.uv );
+		renderer.state.disableUnusedAttributes();
+		renderer.state.enableAttribute( attributes.position );
+		renderer.state.enableAttribute( attributes.uv );
 
 		gl.disable( gl.CULL_FACE );
 		gl.enable( gl.BLEND );