|
@@ -240,37 +240,37 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
|
|
|
result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
|
|
|
|
|
|
- }
|
|
|
+ if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
|
+ ( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
|
+ ( material.alphaMap && material.alphaTest > 0 ) ||
|
|
|
+ ( material.map && material.alphaTest > 0 ) ) {
|
|
|
|
|
|
- if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
|
- ( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
|
- ( material.alphaMap && material.alphaTest > 0 ) ||
|
|
|
- ( material.map && material.alphaTest > 0 ) ) {
|
|
|
+ // in this case we need a unique material instance reflecting the
|
|
|
+ // appropriate state
|
|
|
|
|
|
- // in this case we need a unique material instance reflecting the
|
|
|
- // appropriate state
|
|
|
+ const keyA = result.uuid, keyB = material.uuid;
|
|
|
|
|
|
- const keyA = result.uuid, keyB = material.uuid;
|
|
|
+ let materialsForVariant = _materialCache[ keyA ];
|
|
|
|
|
|
- let materialsForVariant = _materialCache[ keyA ];
|
|
|
+ if ( materialsForVariant === undefined ) {
|
|
|
|
|
|
- if ( materialsForVariant === undefined ) {
|
|
|
+ materialsForVariant = {};
|
|
|
+ _materialCache[ keyA ] = materialsForVariant;
|
|
|
|
|
|
- materialsForVariant = {};
|
|
|
- _materialCache[ keyA ] = materialsForVariant;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ let cachedMaterial = materialsForVariant[ keyB ];
|
|
|
|
|
|
- let cachedMaterial = materialsForVariant[ keyB ];
|
|
|
+ if ( cachedMaterial === undefined ) {
|
|
|
|
|
|
- if ( cachedMaterial === undefined ) {
|
|
|
+ cachedMaterial = result.clone();
|
|
|
+ materialsForVariant[ keyB ] = cachedMaterial;
|
|
|
|
|
|
- cachedMaterial = result.clone();
|
|
|
- materialsForVariant[ keyB ] = cachedMaterial;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ result = cachedMaterial;
|
|
|
|
|
|
- result = cachedMaterial;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|