|
4962 | 4962 |
|
4963 | 4963 | var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
|
4964 | 4964 |
|
4965 |
| - var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n#endif\n"; |
| 4965 | + var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n"; |
4966 | 4966 |
|
4967 | 4967 | var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n";
|
4968 | 4968 |
|
|
7200 | 7200 | this.depthWrite = true;
|
7201 | 7201 |
|
7202 | 7202 | this.clippingPlanes = null;
|
| 7203 | + this.clipIntersection = false; |
7203 | 7204 | this.clipShadows = false;
|
7204 | 7205 |
|
7205 | 7206 | this.colorWrite = true;
|
|
7463 | 7464 |
|
7464 | 7465 | this.visible = source.visible;
|
7465 | 7466 | this.clipShadows = source.clipShadows;
|
| 7467 | + this.clipIntersection = source.clipIntersection; |
7466 | 7468 |
|
7467 | 7469 | var srcPlanes = source.clippingPlanes,
|
7468 | 7470 | dstPlanes = null;
|
|
16406 | 16408 | parameters.flipSided ? '#define FLIP_SIDED' : '',
|
16407 | 16409 |
|
16408 | 16410 | '#define NUM_CLIPPING_PLANES ' + parameters.numClippingPlanes,
|
| 16411 | + '#define UNION_CLIPPING_PLANES ' + (parameters.numClippingPlanes - parameters.numClipIntersection), |
16409 | 16412 |
|
16410 | 16413 | parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',
|
16411 | 16414 | parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',
|
|
16645 | 16648 | "maxMorphTargets", "maxMorphNormals", "premultipliedAlpha",
|
16646 | 16649 | "numDirLights", "numPointLights", "numSpotLights", "numHemiLights",
|
16647 | 16650 | "shadowMapEnabled", "shadowMapType", "toneMapping", 'physicallyCorrectLights',
|
16648 |
| - "alphaTest", "doubleSided", "flipSided", "numClippingPlanes", "depthPacking" |
| 16651 | + "alphaTest", "doubleSided", "flipSided", "numClippingPlanes", "numClipIntersection", "depthPacking" |
16649 | 16652 | ];
|
16650 | 16653 |
|
16651 | 16654 |
|
|
16717 | 16720 |
|
16718 | 16721 | }
|
16719 | 16722 |
|
16720 |
| - this.getParameters = function ( material, lights, fog, nClipPlanes, object ) { |
| 16723 | + this.getParameters = function ( material, lights, fog, nClipPlanes, nClipIntersection, object ) { |
16721 | 16724 |
|
16722 | 16725 | var shaderID = shaderIDs[ material.type ];
|
16723 | 16726 |
|
|
16794 | 16797 | numHemiLights: lights.hemi.length,
|
16795 | 16798 |
|
16796 | 16799 | numClippingPlanes: nClipPlanes,
|
| 16800 | + numClipIntersection: nClipIntersection, |
16797 | 16801 |
|
16798 | 16802 | shadowMapEnabled: renderer.shadowMap.enabled && object.receiveShadow && lights.shadows.length > 0,
|
16799 | 16803 | shadowMapType: renderer.shadowMap.type,
|
|
19205 | 19209 |
|
19206 | 19210 | this.uniform = uniform;
|
19207 | 19211 | this.numPlanes = 0;
|
| 19212 | + this.numIntersection = 0; |
19208 | 19213 |
|
19209 | 19214 | this.init = function( planes, enableLocalClipping, camera ) {
|
19210 | 19215 |
|
|
19239 | 19244 |
|
19240 | 19245 | };
|
19241 | 19246 |
|
19242 |
| - this.setState = function( planes, clipShadows, camera, cache, fromCache ) { |
| 19247 | + this.setState = function( planes, clipIntersection, clipShadows, camera, cache, fromCache ) { |
19243 | 19248 |
|
19244 | 19249 | if ( ! localClippingEnabled ||
|
19245 | 19250 | planes === null || planes.length === 0 ||
|
|
19274 | 19279 | }
|
19275 | 19280 |
|
19276 | 19281 | cache.clippingState = dstArray;
|
| 19282 | + this.numIntersection = clipIntersection ? this.numPlanes : 0; |
19277 | 19283 | this.numPlanes += nGlobal;
|
19278 | 19284 |
|
19279 | 19285 | }
|
|
19291 | 19297 | }
|
19292 | 19298 |
|
19293 | 19299 | scope.numPlanes = numGlobalPlanes;
|
| 19300 | + scope.numIntersection = 0; |
19294 | 19301 |
|
19295 | 19302 | }
|
19296 | 19303 |
|
|
19335 | 19342 | }
|
19336 | 19343 |
|
19337 | 19344 | scope.numPlanes = nPlanes;
|
| 19345 | + |
19338 | 19346 | return dstArray;
|
19339 | 19347 |
|
19340 | 19348 | }
|
|
20851 | 20859 | var materialProperties = properties.get( material );
|
20852 | 20860 |
|
20853 | 20861 | var parameters = programCache.getParameters(
|
20854 |
| - material, _lights, fog, _clipping.numPlanes, object ); |
| 20862 | + material, _lights, fog, _clipping.numPlanes, _clipping.numIntersection, object ); |
20855 | 20863 |
|
20856 | 20864 | var code = programCache.getProgramCode( material, parameters );
|
20857 | 20865 |
|
|
20954 | 20962 | material.clipping === true ) {
|
20955 | 20963 |
|
20956 | 20964 | materialProperties.numClippingPlanes = _clipping.numPlanes;
|
| 20965 | + materialProperties.numIntersection = _clipping.numIntersection; |
20957 | 20966 | uniforms.clippingPlanes = _clipping.uniform;
|
20958 | 20967 |
|
20959 | 20968 | }
|
|
21029 | 21038 | // object instead of the material, once it becomes feasible
|
21030 | 21039 | // (#8465, #8379)
|
21031 | 21040 | _clipping.setState(
|
21032 |
| - material.clippingPlanes, material.clipShadows, |
| 21041 | + material.clippingPlanes, material.clipIntersection, material.clipShadows, |
21033 | 21042 | camera, materialProperties, useCache );
|
21034 | 21043 |
|
21035 | 21044 | }
|
|
21051 | 21060 | material.needsUpdate = true;
|
21052 | 21061 |
|
21053 | 21062 | } else if ( materialProperties.numClippingPlanes !== undefined &&
|
21054 |
| - materialProperties.numClippingPlanes !== _clipping.numPlanes ) { |
| 21063 | + ( materialProperties.numClippingPlanes !== _clipping.numPlanes || |
| 21064 | + materialProperties.numIntersection !== _clipping.numIntersection ) ) { |
21055 | 21065 |
|
21056 | 21066 | material.needsUpdate = true;
|
21057 | 21067 |
|
|
0 commit comments