|
@@ -9,6 +9,7 @@ import { ShaderMaterial } from '../../materials/ShaderMaterial';
|
|
|
import { UniformsUtils } from '../shaders/UniformsUtils';
|
|
|
import { ShaderLib } from '../shaders/ShaderLib';
|
|
|
import { MeshDepthMaterial } from '../../materials/MeshDepthMaterial';
|
|
|
+import { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial';
|
|
|
import { Vector4 } from '../../math/Vector4';
|
|
|
import { Vector3 } from '../../math/Vector3';
|
|
|
import { Vector2 } from '../../math/Vector2';
|
|
@@ -55,34 +56,29 @@ function WebGLShadowMap( _renderer, _shadows, _objects, capabilities ) {
|
|
|
|
|
|
// init
|
|
|
|
|
|
- var depthMaterialTemplate = new MeshDepthMaterial();
|
|
|
- depthMaterialTemplate.depthPacking = RGBADepthPacking;
|
|
|
- depthMaterialTemplate.clipping = true;
|
|
|
-
|
|
|
- var distanceShader = ShaderLib[ "distanceRGBA" ];
|
|
|
- var distanceUniforms = UniformsUtils.clone( distanceShader.uniforms );
|
|
|
-
|
|
|
for ( var i = 0; i !== _NumberOfMaterialVariants; ++ i ) {
|
|
|
|
|
|
var useMorphing = ( i & _MorphingFlag ) !== 0;
|
|
|
var useSkinning = ( i & _SkinningFlag ) !== 0;
|
|
|
|
|
|
- var depthMaterial = depthMaterialTemplate.clone();
|
|
|
- depthMaterial.morphTargets = useMorphing;
|
|
|
- depthMaterial.skinning = useSkinning;
|
|
|
+ var depthMaterial = new MeshDepthMaterial( {
|
|
|
+
|
|
|
+ depthPacking: RGBADepthPacking,
|
|
|
+
|
|
|
+ morphTargets: useMorphing,
|
|
|
+ skinning: useSkinning
|
|
|
+
|
|
|
+ } );
|
|
|
|
|
|
_depthMaterials[ i ] = depthMaterial;
|
|
|
|
|
|
- var distanceMaterial = new ShaderMaterial( {
|
|
|
- defines: {
|
|
|
- 'USE_SHADOWMAP': ''
|
|
|
- },
|
|
|
- uniforms: distanceUniforms,
|
|
|
- vertexShader: distanceShader.vertexShader,
|
|
|
- fragmentShader: distanceShader.fragmentShader,
|
|
|
+ //
|
|
|
+
|
|
|
+ var distanceMaterial = new MeshDistanceMaterial( {
|
|
|
+
|
|
|
morphTargets: useMorphing,
|
|
|
- skinning: useSkinning,
|
|
|
- clipping: true
|
|
|
+ skinning: useSkinning
|
|
|
+
|
|
|
} );
|
|
|
|
|
|
_distanceMaterials[ i ] = distanceMaterial;
|
|
@@ -384,11 +380,11 @@ function WebGLShadowMap( _renderer, _shadows, _objects, capabilities ) {
|
|
|
result.wireframeLinewidth = material.wireframeLinewidth;
|
|
|
result.linewidth = material.linewidth;
|
|
|
|
|
|
- if ( isPointLight && result.uniforms.lightPos !== undefined ) {
|
|
|
+ if ( isPointLight && result.isMeshDistanceMaterial ) {
|
|
|
|
|
|
- result.uniforms.lightPos.value.copy( lightPositionWorld );
|
|
|
- result.uniforms.shadowCameraNear.value = shadowCameraNear;
|
|
|
- result.uniforms.shadowCameraFar.value = shadowCameraFar;
|
|
|
+ result.referencePosition.copy( lightPositionWorld );
|
|
|
+ result.nearDistance = shadowCameraNear;
|
|
|
+ result.farDistance = shadowCameraFar;
|
|
|
|
|
|
}
|
|
|
|