|
@@ -91,6 +91,12 @@ THREE.CullFaceFrontBack = 3;
|
|
THREE.FrontFaceDirectionCW = 0;
|
|
THREE.FrontFaceDirectionCW = 0;
|
|
THREE.FrontFaceDirectionCCW = 1;
|
|
THREE.FrontFaceDirectionCCW = 1;
|
|
|
|
|
|
|
|
+// SHADOWING TYPES
|
|
|
|
+
|
|
|
|
+THREE.BasicShadowMap = 0;
|
|
|
|
+THREE.PCFShadowMap = 1;
|
|
|
|
+THREE.PCFSoftShadowMap = 2;
|
|
|
|
+
|
|
// MATERIAL CONSTANTS
|
|
// MATERIAL CONSTANTS
|
|
|
|
|
|
// side
|
|
// side
|
|
@@ -4296,17 +4302,8 @@ THREE.Rectangle = function () {
|
|
|
|
|
|
THREE.Sphere = function ( center, radius ) {
|
|
THREE.Sphere = function ( center, radius ) {
|
|
|
|
|
|
- if ( center === undefined && radius === undefined ) {
|
|
|
|
-
|
|
|
|
- this.center = new THREE.Vector3();
|
|
|
|
- this.radius = 0;
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- this.center = center.clone();
|
|
|
|
- this.radius = radius || 0;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ this.center = center === undefined ? new THREE.Vector3() : center.clone();
|
|
|
|
+ this.radius = radius === undefined ? 0 : radius;
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -7104,30 +7101,26 @@ THREE.Geometry.prototype = {
|
|
|
|
|
|
computeBoundingBox: function () {
|
|
computeBoundingBox: function () {
|
|
|
|
|
|
- if ( ! this.boundingBox ) {
|
|
|
|
|
|
+ if ( this.boundingBox === null ) {
|
|
|
|
|
|
- this.boundingBox = new THREE.Box3().setFromPoints( this.vertices );
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- this.boundingBox.setFromPoints( this.vertices );
|
|
|
|
|
|
+ this.boundingBox = new THREE.Box3();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.boundingBox.setFromPoints( this.vertices );
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
computeBoundingSphere: function () {
|
|
computeBoundingSphere: function () {
|
|
|
|
|
|
- if ( ! this.boundingSphere ) {
|
|
|
|
-
|
|
|
|
- this.boundingSphere = new THREE.Sphere().setFromCenterAndPoints( new THREE.Vector3(), this.vertices );
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
|
|
+ if ( this.boundingSphere === null ) {
|
|
|
|
|
|
- this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
|
|
|
|
|
|
+ this.boundingSphere = new THREE.Sphere();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -7348,7 +7341,7 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
computeBoundingBox: function () {
|
|
computeBoundingBox: function () {
|
|
|
|
|
|
- if ( ! this.boundingBox ) {
|
|
|
|
|
|
+ if ( this.boundingBox === null ) {
|
|
|
|
|
|
this.boundingBox = new THREE.Box3();
|
|
this.boundingBox = new THREE.Box3();
|
|
|
|
|
|
@@ -7420,8 +7413,10 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
computeBoundingSphere: function () {
|
|
computeBoundingSphere: function () {
|
|
|
|
|
|
- if ( ! this.boundingSphere ) {
|
|
|
|
|
|
+ if ( this.boundingSphere === null ) {
|
|
|
|
+
|
|
this.boundingSphere = new THREE.Sphere();
|
|
this.boundingSphere = new THREE.Sphere();
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
var positions = this.attributes[ "position" ].array;
|
|
var positions = this.attributes[ "position" ].array;
|
|
@@ -7530,15 +7525,15 @@ THREE.BufferGeometry.prototype = {
|
|
ab.sub( pA, pB );
|
|
ab.sub( pA, pB );
|
|
cb.crossSelf( ab );
|
|
cb.crossSelf( ab );
|
|
|
|
|
|
- normals[ vA * 3 ] += cb.x;
|
|
|
|
|
|
+ normals[ vA * 3 ] += cb.x;
|
|
normals[ vA * 3 + 1 ] += cb.y;
|
|
normals[ vA * 3 + 1 ] += cb.y;
|
|
normals[ vA * 3 + 2 ] += cb.z;
|
|
normals[ vA * 3 + 2 ] += cb.z;
|
|
|
|
|
|
- normals[ vB * 3 ] += cb.x;
|
|
|
|
|
|
+ normals[ vB * 3 ] += cb.x;
|
|
normals[ vB * 3 + 1 ] += cb.y;
|
|
normals[ vB * 3 + 1 ] += cb.y;
|
|
normals[ vB * 3 + 2 ] += cb.z;
|
|
normals[ vB * 3 + 2 ] += cb.z;
|
|
|
|
|
|
- normals[ vC * 3 ] += cb.x;
|
|
|
|
|
|
+ normals[ vC * 3 ] += cb.x;
|
|
normals[ vC * 3 + 1 ] += cb.y;
|
|
normals[ vC * 3 + 1 ] += cb.y;
|
|
normals[ vC * 3 + 2 ] += cb.z;
|
|
normals[ vC * 3 + 2 ] += cb.z;
|
|
|
|
|
|
@@ -16038,7 +16033,7 @@ THREE.ShaderChunk = {
|
|
|
|
|
|
"shadowCoord.z += shadowBias[ i ];",
|
|
"shadowCoord.z += shadowBias[ i ];",
|
|
|
|
|
|
- "#ifdef SHADOWMAP_SOFT",
|
|
|
|
|
|
+ "#if defined( SHADOWMAP_TYPE_PCF )",
|
|
|
|
|
|
// Percentage-close filtering
|
|
// Percentage-close filtering
|
|
// (9 pixel kernel)
|
|
// (9 pixel kernel)
|
|
@@ -16108,6 +16103,76 @@ THREE.ShaderChunk = {
|
|
|
|
|
|
"shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );",
|
|
"shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );",
|
|
|
|
|
|
|
|
+ "#elif defined( SHADOWMAP_TYPE_PCF_SOFT )",
|
|
|
|
+
|
|
|
|
+ // Percentage-close filtering
|
|
|
|
+ // (9 pixel kernel)
|
|
|
|
+ // http://fabiensanglard.net/shadowmappingPCF/
|
|
|
|
+
|
|
|
|
+ "float shadow = 0.0;",
|
|
|
|
+
|
|
|
|
+ "float xPixelOffset = 1.0 / shadowMapSize[ i ].x;",
|
|
|
|
+ "float yPixelOffset = 1.0 / shadowMapSize[ i ].y;",
|
|
|
|
+
|
|
|
|
+ "float dx0 = -1.0 * xPixelOffset;",
|
|
|
|
+ "float dy0 = -1.0 * yPixelOffset;",
|
|
|
|
+ "float dx1 = 1.0 * xPixelOffset;",
|
|
|
|
+ "float dy1 = 1.0 * yPixelOffset;",
|
|
|
|
+
|
|
|
|
+ "mat3 shadowKernel;",
|
|
|
|
+ "mat3 depthKernel;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );",
|
|
|
|
+ "if ( depthKernel[0][0] < shadowCoord.z ) shadowKernel[0][0] = 0.25;",
|
|
|
|
+ "else shadowKernel[0][0] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );",
|
|
|
|
+ "if ( depthKernel[0][1] < shadowCoord.z ) shadowKernel[0][1] = 0.25;",
|
|
|
|
+ "else shadowKernel[0][1] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i], shadowCoord.xy + vec2( dx0, dy1 ) ) );",
|
|
|
|
+ "if ( depthKernel[0][2] < shadowCoord.z ) shadowKernel[0][2] = 0.25;",
|
|
|
|
+ "else shadowKernel[0][2] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );",
|
|
|
|
+ "if ( depthKernel[1][0] < shadowCoord.z ) shadowKernel[1][0] = 0.25;",
|
|
|
|
+ "else shadowKernel[1][0] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );",
|
|
|
|
+ "if ( depthKernel[1][1] < shadowCoord.z ) shadowKernel[1][1] = 0.25;",
|
|
|
|
+ "else shadowKernel[1][1] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );",
|
|
|
|
+ "if ( depthKernel[1][2] < shadowCoord.z ) shadowKernel[1][2] = 0.25;",
|
|
|
|
+ "else shadowKernel[1][2] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );",
|
|
|
|
+ "if ( depthKernel[2][0] < shadowCoord.z ) shadowKernel[2][0] = 0.25;",
|
|
|
|
+ "else shadowKernel[2][0] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );",
|
|
|
|
+ "if ( depthKernel[2][1] < shadowCoord.z ) shadowKernel[2][1] = 0.25;",
|
|
|
|
+ "else shadowKernel[2][1] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );",
|
|
|
|
+ "if ( depthKernel[2][2] < shadowCoord.z ) shadowKernel[2][2] = 0.25;",
|
|
|
|
+ "else shadowKernel[2][2] = 0.0;",
|
|
|
|
+
|
|
|
|
+ "vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );",
|
|
|
|
+
|
|
|
|
+ "shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );",
|
|
|
|
+ "shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );",
|
|
|
|
+
|
|
|
|
+ "vec4 shadowValues;",
|
|
|
|
+ "shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );",
|
|
|
|
+ "shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );",
|
|
|
|
+ "shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );",
|
|
|
|
+ "shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );",
|
|
|
|
+
|
|
|
|
+ "shadow = dot( shadowValues, vec4( 1.0 ) );",
|
|
|
|
+
|
|
|
|
+ "shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );",
|
|
|
|
+
|
|
"#else",
|
|
"#else",
|
|
|
|
|
|
"vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );",
|
|
"vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );",
|
|
@@ -17006,7 +17071,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
this.shadowMapEnabled = false;
|
|
this.shadowMapEnabled = false;
|
|
this.shadowMapAutoUpdate = true;
|
|
this.shadowMapAutoUpdate = true;
|
|
- this.shadowMapSoft = true;
|
|
|
|
|
|
+ this.shadowMapType = THREE.PCFShadowMap;
|
|
this.shadowMapCullFace = THREE.CullFaceFront;
|
|
this.shadowMapCullFace = THREE.CullFaceFront;
|
|
this.shadowMapDebug = false;
|
|
this.shadowMapDebug = false;
|
|
this.shadowMapCascade = false;
|
|
this.shadowMapCascade = false;
|
|
@@ -21877,7 +21942,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
maxShadows: maxShadows,
|
|
maxShadows: maxShadows,
|
|
shadowMapEnabled: this.shadowMapEnabled && object.receiveShadow,
|
|
shadowMapEnabled: this.shadowMapEnabled && object.receiveShadow,
|
|
- shadowMapSoft: this.shadowMapSoft,
|
|
|
|
|
|
+ shadowMapType: this.shadowMapType,
|
|
shadowMapDebug: this.shadowMapDebug,
|
|
shadowMapDebug: this.shadowMapDebug,
|
|
shadowMapCascade: this.shadowMapCascade,
|
|
shadowMapCascade: this.shadowMapCascade,
|
|
|
|
|
|
@@ -23180,6 +23245,18 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var shadowMapTypeDefine = "SHADOWMAP_TYPE_BASIC";
|
|
|
|
+
|
|
|
|
+ if ( parameters.shadowMapType === THREE.PCFShadowMap ) {
|
|
|
|
+
|
|
|
|
+ shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF";
|
|
|
|
+
|
|
|
|
+ } else if ( parameters.shadowMapType === THREE.PCFSoftShadowMap ) {
|
|
|
|
+
|
|
|
|
+ shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF_SOFT";
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//console.log( "building new program " );
|
|
//console.log( "building new program " );
|
|
|
|
|
|
//
|
|
//
|
|
@@ -23232,7 +23309,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
parameters.flipSided ? "#define FLIP_SIDED" : "",
|
|
parameters.flipSided ? "#define FLIP_SIDED" : "",
|
|
|
|
|
|
parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
|
|
parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
|
|
- parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "",
|
|
|
|
|
|
+ parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
|
|
parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
|
|
parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
|
|
parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
|
|
parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
|
|
|
|
|
|
@@ -23331,7 +23408,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
parameters.flipSided ? "#define FLIP_SIDED" : "",
|
|
parameters.flipSided ? "#define FLIP_SIDED" : "",
|
|
|
|
|
|
parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
|
|
parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
|
|
- parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "",
|
|
|
|
|
|
+ parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
|
|
parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
|
|
parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
|
|
parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
|
|
parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
|
|
|
|
|
|
@@ -35691,7 +35768,15 @@ THREE.ShadowMapPlugin = function ( ) {
|
|
|
|
|
|
if ( ! light.shadowMap ) {
|
|
if ( ! light.shadowMap ) {
|
|
|
|
|
|
- var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
|
|
|
|
|
|
+ var shadowFilter = THREE.LinearFilter;
|
|
|
|
+
|
|
|
|
+ if ( _renderer.shadowMapType === THREE.PCFSoftShadowMap ) {
|
|
|
|
+
|
|
|
|
+ shadowFilter = THREE.NearestFilter;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var pars = { minFilter: shadowFilter, magFilter: shadowFilter, format: THREE.RGBAFormat };
|
|
|
|
|
|
light.shadowMap = new THREE.WebGLRenderTarget( light.shadowMapWidth, light.shadowMapHeight, pars );
|
|
light.shadowMap = new THREE.WebGLRenderTarget( light.shadowMapWidth, light.shadowMapHeight, pars );
|
|
light.shadowMapSize = new THREE.Vector2( light.shadowMapWidth, light.shadowMapHeight );
|
|
light.shadowMapSize = new THREE.Vector2( light.shadowMapWidth, light.shadowMapHeight );
|