|
@@ -100,27 +100,15 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
|
|
|
var faceCount, isPointLight;
|
|
|
|
|
|
if ( scope.enabled === false ) return;
|
|
|
- if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;
|
|
|
-
|
|
|
- // set GL state for depth map
|
|
|
+ if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;
|
|
|
|
|
|
+ // Set GL state for depth map.
|
|
|
_gl.clearColor( 1, 1, 1, 1 );
|
|
|
_state.disable( _gl.BLEND );
|
|
|
-
|
|
|
_state.enable( _gl.CULL_FACE );
|
|
|
_gl.frontFace( _gl.CCW );
|
|
|
-
|
|
|
- if ( scope.cullFace === THREE.CullFaceFront ) {
|
|
|
-
|
|
|
- _gl.cullFace( _gl.FRONT );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _gl.cullFace( _gl.BACK );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _state.setDepthTest( true );
|
|
|
+ _gl.cullFace( scope.cullFace === THREE.CullFaceFront ? _gl.FRONT : _gl.BACK );
|
|
|
+ _state.setDepthTest( true );
|
|
|
|
|
|
// save the existing viewport so it can be restored later
|
|
|
_renderer.getViewport( _vector4 );
|
|
@@ -131,6 +119,8 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
|
|
|
|
|
|
var light = _lights[ i ];
|
|
|
|
|
|
+ if ( ! light.castShadow ) continue;
|
|
|
+
|
|
|
if ( light instanceof THREE.PointLight ) {
|
|
|
|
|
|
faceCount = 6;
|
|
@@ -172,8 +162,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( ! light.castShadow ) continue;
|
|
|
-
|
|
|
if ( ! light.shadowMap ) {
|
|
|
|
|
|
var shadowFilter = THREE.LinearFilter;
|
|
@@ -321,15 +309,17 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _renderer.setViewport( _vector4.x, _vector4.y, _vector4.z, _vector4.w );
|
|
|
+ //We must call _renderer.resetGLState() at the end of each iteration of
|
|
|
+ // the light loop in order to force material updates for each light.
|
|
|
+ _renderer.resetGLState();
|
|
|
|
|
|
}
|
|
|
|
|
|
- // restore GL state
|
|
|
+ _renderer.setViewport( _vector4.x, _vector4.y, _vector4.z, _vector4.w );
|
|
|
|
|
|
+ // Restore GL state.
|
|
|
var clearColor = _renderer.getClearColor(),
|
|
|
clearAlpha = _renderer.getClearAlpha();
|
|
|
-
|
|
|
_renderer.setClearColor( clearColor, clearAlpha );
|
|
|
_state.enable( _gl.BLEND );
|
|
|
|
|
@@ -339,7 +329,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _renderer.resetGLState();
|
|
|
+ _renderer.resetGLState();
|
|
|
|
|
|
scope.needsUpdate = false;
|
|
|
|