|
@@ -22,8 +22,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
|
|
|
_viewport = new Vector4(),
|
|
|
|
|
|
- _depthMaterials = [],
|
|
|
- _distanceMaterials = [],
|
|
|
+ _depthMaterial = new MeshDepthMaterial( { depthPacking: RGBADepthPacking } ),
|
|
|
+ _distanceMaterial = new MeshDistanceMaterial(),
|
|
|
|
|
|
_materialCache = {},
|
|
|
|
|
@@ -228,81 +228,19 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function getDepthMaterialVariant( useMorphing ) {
|
|
|
-
|
|
|
- const index = useMorphing << 0;
|
|
|
-
|
|
|
- let material = _depthMaterials[ index ];
|
|
|
-
|
|
|
- if ( material === undefined ) {
|
|
|
-
|
|
|
- material = new MeshDepthMaterial( {
|
|
|
-
|
|
|
- depthPacking: RGBADepthPacking,
|
|
|
-
|
|
|
- morphTargets: useMorphing
|
|
|
-
|
|
|
- } );
|
|
|
-
|
|
|
- _depthMaterials[ index ] = material;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return material;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- function getDistanceMaterialVariant( useMorphing ) {
|
|
|
-
|
|
|
- const index = useMorphing << 0;
|
|
|
-
|
|
|
- let material = _distanceMaterials[ index ];
|
|
|
-
|
|
|
- if ( material === undefined ) {
|
|
|
-
|
|
|
- material = new MeshDistanceMaterial( {
|
|
|
-
|
|
|
- morphTargets: useMorphing
|
|
|
-
|
|
|
- } );
|
|
|
-
|
|
|
- _distanceMaterials[ index ] = material;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return material;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {
|
|
|
|
|
|
let result = null;
|
|
|
|
|
|
- let getMaterialVariant = getDepthMaterialVariant;
|
|
|
- let customMaterial = object.customDepthMaterial;
|
|
|
+ const customMaterial = ( light.isPointLight === true ) ? object.customDistanceMaterial : object.customDepthMaterial;
|
|
|
|
|
|
- if ( light.isPointLight === true ) {
|
|
|
+ if ( customMaterial !== undefined ) {
|
|
|
|
|
|
- getMaterialVariant = getDistanceMaterialVariant;
|
|
|
- customMaterial = object.customDistanceMaterial;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( customMaterial === undefined ) {
|
|
|
-
|
|
|
- let useMorphing = false;
|
|
|
-
|
|
|
- if ( material.morphTargets === true ) {
|
|
|
-
|
|
|
- useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- result = getMaterialVariant( useMorphing );
|
|
|
+ result = customMaterial;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- result = customMaterial;
|
|
|
+ result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
|
|
|
|
|
|
}
|
|
|
|