OutlinePass.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /**
  2. * @author spidersharma / http://eduperiment.com/
  3. */
  4. THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
  5. this.renderScene = scene;
  6. this.renderCamera = camera;
  7. this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
  8. this.visibleEdgeColor = new THREE.Color( 1, 1, 1 );
  9. this.hiddenEdgeColor = new THREE.Color( 0.1, 0.04, 0.02 );
  10. this.edgeGlow = 0.0;
  11. this.usePatternTexture = false;
  12. this.edgeThickness = 1.0;
  13. this.edgeStrength = 3.0;
  14. this.downSampleRatio = 2;
  15. this.pulsePeriod = 0;
  16. THREE.Pass.call( this );
  17. this.resolution = ( resolution !== undefined ) ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );
  18. var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
  19. var resx = Math.round( this.resolution.x / this.downSampleRatio );
  20. var resy = Math.round( this.resolution.y / this.downSampleRatio );
  21. this.maskBufferMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff } );
  22. this.maskBufferMaterial.side = THREE.DoubleSide;
  23. this.renderTargetMaskBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
  24. this.renderTargetMaskBuffer.texture.generateMipmaps = false;
  25. this.depthMaterial = new THREE.MeshDepthMaterial();
  26. this.depthMaterial.side = THREE.DoubleSide;
  27. this.depthMaterial.depthPacking = THREE.RGBADepthPacking;
  28. this.depthMaterial.blending = THREE.NoBlending;
  29. this.prepareMaskMaterial = this.getPrepareMaskMaterial();
  30. this.prepareMaskMaterial.side = THREE.DoubleSide;
  31. this.renderTargetDepthBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
  32. this.renderTargetDepthBuffer.texture.generateMipmaps = false;
  33. this.renderTargetMaskDownSampleBuffer = new THREE.WebGLRenderTarget( resx, resy, pars );
  34. this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
  35. this.renderTargetBlurBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
  36. this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
  37. this.renderTargetBlurBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
  38. this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
  39. this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
  40. this.renderTargetEdgeBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
  41. this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
  42. this.renderTargetEdgeBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
  43. this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
  44. var MAX_EDGE_THICKNESS = 4;
  45. var MAX_EDGE_GLOW = 4;
  46. this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
  47. this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
  48. this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = 1;
  49. this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
  50. this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( Math.round( resx / 2 ), Math.round( resy / 2 ) );
  51. this.separableBlurMaterial2.uniforms[ "kernelRadius" ].value = MAX_EDGE_GLOW;
  52. // Overlay material
  53. this.overlayMaterial = this.getOverlayMaterial();
  54. // copy material
  55. if ( THREE.CopyShader === undefined )
  56. console.error( "THREE.OutlinePass relies on THREE.CopyShader" );
  57. var copyShader = THREE.CopyShader;
  58. this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
  59. this.copyUniforms[ "opacity" ].value = 1.0;
  60. this.materialCopy = new THREE.ShaderMaterial( {
  61. uniforms: this.copyUniforms,
  62. vertexShader: copyShader.vertexShader,
  63. fragmentShader: copyShader.fragmentShader,
  64. blending: THREE.NoBlending,
  65. depthTest: false,
  66. depthWrite: false,
  67. transparent: true
  68. } );
  69. this.enabled = true;
  70. this.needsSwap = false;
  71. this.oldClearColor = new THREE.Color();
  72. this.oldClearAlpha = 1;
  73. this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  74. this.scene = new THREE.Scene();
  75. this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
  76. this.scene.add( this.quad );
  77. this.tempPulseColor1 = new THREE.Color();
  78. this.tempPulseColor2 = new THREE.Color();
  79. this.textureMatrix = new THREE.Matrix4();
  80. };
  81. THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  82. constructor: THREE.OutlinePass,
  83. dispose: function () {
  84. this.renderTargetMaskBuffer.dispose();
  85. this.renderTargetDepthBuffer.dispose();
  86. this.renderTargetMaskDownSampleBuffer.dispose();
  87. this.renderTargetBlurBuffer1.dispose();
  88. this.renderTargetBlurBuffer2.dispose();
  89. this.renderTargetEdgeBuffer1.dispose();
  90. this.renderTargetEdgeBuffer2.dispose();
  91. },
  92. setSize: function ( width, height ) {
  93. this.renderTargetMaskBuffer.setSize( width, height );
  94. var resx = Math.round( width / this.downSampleRatio );
  95. var resy = Math.round( height / this.downSampleRatio );
  96. this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
  97. this.renderTargetBlurBuffer1.setSize( resx, resy );
  98. this.renderTargetEdgeBuffer1.setSize( resx, resy );
  99. this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
  100. resx = Math.round( resx / 2 );
  101. resy = Math.round( resy / 2 );
  102. this.renderTargetBlurBuffer2.setSize( resx, resy );
  103. this.renderTargetEdgeBuffer2.setSize( resx, resy );
  104. this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
  105. },
  106. changeVisibilityOfSelectedObjects: function ( bVisible ) {
  107. function gatherSelectedMeshesCallBack( object ) {
  108. if ( object instanceof THREE.Mesh ) object.visible = bVisible;
  109. }
  110. for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
  111. var selectedObject = this.selectedObjects[ i ];
  112. selectedObject.traverse( gatherSelectedMeshesCallBack );
  113. }
  114. },
  115. changeVisibilityOfNonSelectedObjects: function ( bVisible ) {
  116. var selectedMeshes = [];
  117. function gatherSelectedMeshesCallBack( object ) {
  118. if ( object instanceof THREE.Mesh ) selectedMeshes.push( object );
  119. }
  120. for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
  121. var selectedObject = this.selectedObjects[ i ];
  122. selectedObject.traverse( gatherSelectedMeshesCallBack );
  123. }
  124. function VisibilityChangeCallBack( object ) {
  125. if ( object instanceof THREE.Mesh ) {
  126. var bFound = false;
  127. for ( var i = 0; i < selectedMeshes.length; i ++ ) {
  128. var selectedObjectId = selectedMeshes[ i ].id;
  129. if ( selectedObjectId === object.id ) {
  130. bFound = true;
  131. break;
  132. }
  133. }
  134. if ( ! bFound ) {
  135. var visibility = object.visible;
  136. if ( ! bVisible || object.bVisible ) object.visible = bVisible;
  137. object.bVisible = visibility;
  138. }
  139. }
  140. }
  141. this.renderScene.traverse( VisibilityChangeCallBack );
  142. },
  143. updateTextureMatrix: function () {
  144. this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
  145. 0.0, 0.5, 0.0, 0.5,
  146. 0.0, 0.0, 0.5, 0.5,
  147. 0.0, 0.0, 0.0, 1.0 );
  148. this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
  149. this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
  150. },
  151. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  152. if ( this.selectedObjects.length === 0 ) return;
  153. this.oldClearColor.copy( renderer.getClearColor() );
  154. this.oldClearAlpha = renderer.getClearAlpha();
  155. var oldAutoClear = renderer.autoClear;
  156. renderer.autoClear = false;
  157. if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
  158. renderer.setClearColor( 0xffffff, 1 );
  159. // Make selected objects invisible
  160. this.changeVisibilityOfSelectedObjects( false );
  161. // 1. Draw Non Selected objects in the depth buffer
  162. this.renderScene.overrideMaterial = this.depthMaterial;
  163. renderer.render( this.renderScene, this.renderCamera, this.renderTargetDepthBuffer, true );
  164. // Make selected objects visible
  165. this.changeVisibilityOfSelectedObjects( true );
  166. // Update Texture Matrix for Depth compare
  167. this.updateTextureMatrix();
  168. // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
  169. this.changeVisibilityOfNonSelectedObjects( false );
  170. this.renderScene.overrideMaterial = this.prepareMaskMaterial;
  171. this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new THREE.Vector2( this.renderCamera.near, this.renderCamera.far );
  172. this.prepareMaskMaterial.uniforms[ "depthTexture" ].value = this.renderTargetDepthBuffer.texture;
  173. this.prepareMaskMaterial.uniforms[ "textureMatrix" ].value = this.textureMatrix;
  174. renderer.render( this.renderScene, this.renderCamera, this.renderTargetMaskBuffer, true );
  175. this.renderScene.overrideMaterial = null;
  176. this.changeVisibilityOfNonSelectedObjects( true );
  177. // 2. Downsample to Half resolution
  178. this.quad.material = this.materialCopy;
  179. this.copyUniforms[ "tDiffuse" ].value = this.renderTargetMaskBuffer.texture;
  180. renderer.render( this.scene, this.camera, this.renderTargetMaskDownSampleBuffer, true );
  181. this.tempPulseColor1.copy( this.visibleEdgeColor );
  182. this.tempPulseColor2.copy( this.hiddenEdgeColor );
  183. if ( this.pulsePeriod > 0 ) {
  184. var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
  185. this.tempPulseColor1.multiplyScalar( scalar );
  186. this.tempPulseColor2.multiplyScalar( scalar );
  187. }
  188. // 3. Apply Edge Detection Pass
  189. this.quad.material = this.edgeDetectionMaterial;
  190. this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture;
  191. this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new THREE.Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
  192. this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1;
  193. this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2;
  194. renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer1, true );
  195. // 4. Apply Blur on Half res
  196. this.quad.material = this.separableBlurMaterial1;
  197. this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
  198. this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX;
  199. this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = this.edgeThickness;
  200. renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer1, true );
  201. this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer1.texture;
  202. this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY;
  203. renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer1, true );
  204. // Apply Blur on quarter res
  205. this.quad.material = this.separableBlurMaterial2;
  206. this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
  207. this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX;
  208. renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer2, true );
  209. this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer2.texture;
  210. this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY;
  211. renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer2, true );
  212. // Blend it additively over the input texture
  213. this.quad.material = this.overlayMaterial;
  214. this.overlayMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskBuffer.texture;
  215. this.overlayMaterial.uniforms[ "edgeTexture1" ].value = this.renderTargetEdgeBuffer1.texture;
  216. this.overlayMaterial.uniforms[ "edgeTexture2" ].value = this.renderTargetEdgeBuffer2.texture;
  217. this.overlayMaterial.uniforms[ "patternTexture" ].value = this.patternTexture;
  218. this.overlayMaterial.uniforms[ "edgeStrength" ].value = this.edgeStrength;
  219. this.overlayMaterial.uniforms[ "edgeGlow" ].value = this.edgeGlow;
  220. this.overlayMaterial.uniforms[ "usePatternTexture" ].value = this.usePatternTexture;
  221. if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
  222. renderer.render( this.scene, this.camera, readBuffer, false );
  223. renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
  224. renderer.autoClear = oldAutoClear;
  225. },
  226. getPrepareMaskMaterial: function () {
  227. return new THREE.ShaderMaterial( {
  228. uniforms: {
  229. "depthTexture": { value: null },
  230. "cameraNearFar": { value: new THREE.Vector2( 0.5, 0.5 ) },
  231. "textureMatrix": { value: new THREE.Matrix4() }
  232. },
  233. vertexShader:
  234. "varying vec2 vUv;\
  235. varying vec4 projTexCoord;\
  236. varying vec4 vPosition;\
  237. uniform mat4 textureMatrix;\
  238. void main() {\
  239. vUv = uv;\
  240. vPosition = modelViewMatrix * vec4( position, 1.0 );\
  241. vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\
  242. projTexCoord = textureMatrix * worldPosition;\
  243. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
  244. }",
  245. fragmentShader:
  246. "#include <packing>\
  247. varying vec2 vUv;\
  248. varying vec4 vPosition;\
  249. varying vec4 projTexCoord;\
  250. uniform sampler2D depthTexture;\
  251. uniform vec2 cameraNearFar;\
  252. \
  253. void main() {\
  254. float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\
  255. float viewZ = -perspectiveDepthToViewZ( depth, cameraNearFar.x, cameraNearFar.y );\
  256. float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\
  257. gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\
  258. }"
  259. } );
  260. },
  261. getEdgeDetectionMaterial: function () {
  262. return new THREE.ShaderMaterial( {
  263. uniforms: {
  264. "maskTexture": { value: null },
  265. "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) },
  266. "visibleEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) },
  267. "hiddenEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) },
  268. },
  269. vertexShader:
  270. "varying vec2 vUv;\n\
  271. void main() {\n\
  272. vUv = uv;\n\
  273. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
  274. }",
  275. fragmentShader:
  276. "varying vec2 vUv;\
  277. uniform sampler2D maskTexture;\
  278. uniform vec2 texSize;\
  279. uniform vec3 visibleEdgeColor;\
  280. uniform vec3 hiddenEdgeColor;\
  281. \
  282. void main() {\n\
  283. vec2 invSize = 1.0 / texSize;\
  284. vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\
  285. vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\
  286. vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\
  287. vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\
  288. vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\
  289. float diff1 = (c1.r - c2.r)*0.5;\
  290. float diff2 = (c3.r - c4.r)*0.5;\
  291. float d = length( vec2(diff1, diff2) );\
  292. float a1 = min(c1.g, c2.g);\
  293. float a2 = min(c3.g, c4.g);\
  294. float visibilityFactor = min(a1, a2);\
  295. vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\
  296. gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\
  297. }"
  298. } );
  299. },
  300. getSeperableBlurMaterial: function ( maxRadius ) {
  301. return new THREE.ShaderMaterial( {
  302. defines: {
  303. "MAX_RADIUS": maxRadius,
  304. },
  305. uniforms: {
  306. "colorTexture": { value: null },
  307. "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) },
  308. "direction": { value: new THREE.Vector2( 0.5, 0.5 ) },
  309. "kernelRadius": { value: 1.0 }
  310. },
  311. vertexShader:
  312. "varying vec2 vUv;\n\
  313. void main() {\n\
  314. vUv = uv;\n\
  315. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
  316. }",
  317. fragmentShader:
  318. "#include <common>\
  319. varying vec2 vUv;\
  320. uniform sampler2D colorTexture;\
  321. uniform vec2 texSize;\
  322. uniform vec2 direction;\
  323. uniform float kernelRadius;\
  324. \
  325. float gaussianPdf(in float x, in float sigma) {\
  326. return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
  327. }\
  328. void main() {\
  329. vec2 invSize = 1.0 / texSize;\
  330. float weightSum = gaussianPdf(0.0, kernelRadius);\
  331. vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\
  332. vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\
  333. vec2 uvOffset = delta;\
  334. for( int i = 1; i <= MAX_RADIUS; i ++ ) {\
  335. float w = gaussianPdf(uvOffset.x, kernelRadius);\
  336. vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\
  337. vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\
  338. diffuseSum += ((sample1 + sample2) * w);\
  339. weightSum += (2.0 * w);\
  340. uvOffset += delta;\
  341. }\
  342. gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\
  343. }"
  344. } );
  345. },
  346. getOverlayMaterial: function () {
  347. return new THREE.ShaderMaterial( {
  348. uniforms: {
  349. "maskTexture": { value: null },
  350. "edgeTexture1": { value: null },
  351. "edgeTexture2": { value: null },
  352. "patternTexture": { value: null },
  353. "edgeStrength": { value: 1.0 },
  354. "edgeGlow": { value: 1.0 },
  355. "usePatternTexture": { value: 0.0 }
  356. },
  357. vertexShader:
  358. "varying vec2 vUv;\n\
  359. void main() {\n\
  360. vUv = uv;\n\
  361. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
  362. }",
  363. fragmentShader:
  364. "varying vec2 vUv;\
  365. uniform sampler2D maskTexture;\
  366. uniform sampler2D edgeTexture1;\
  367. uniform sampler2D edgeTexture2;\
  368. uniform sampler2D patternTexture;\
  369. uniform float edgeStrength;\
  370. uniform float edgeGlow;\
  371. uniform bool usePatternTexture;\
  372. \
  373. void main() {\
  374. vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\
  375. vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\
  376. vec4 maskColor = texture2D(maskTexture, vUv);\
  377. vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\
  378. float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\
  379. vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\
  380. vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\
  381. if(usePatternTexture)\
  382. finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\
  383. gl_FragColor = finalColor;\
  384. }",
  385. blending: THREE.AdditiveBlending,
  386. depthTest: false,
  387. depthWrite: false,
  388. transparent: true
  389. } );
  390. }
  391. } );
  392. THREE.OutlinePass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
  393. THREE.OutlinePass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );