4

I would like to modify the OutlinePass to outline all of the selected objects in the scene, including those contained within the bounds of the other in screen space (I also hope I just used that term correctly).

I am using three.js OutlinePass to indicate objects currently selected in the scene. With ray picking I append to the selected objects array, then update outlinePass.selectedObjects with said array.

The objects I select are PlaneBufferGeometry with MeshBasicMaterial. Each next drawn plane has increasing renderOrder as well as, just slightly, larger z axis offset (which in my case points upwards), so that you can correctly pick them.

  1. If I select two disjoint planes, the outline works correctly.
  2. If I select two intersecting planes, the outline works okay - it only draws around the two intersecting shapes -- this effect is actually nice, but would collide with fixing the next point anyway.
  3. If I select two planes, where one is contained within the other (contained in terms of view, looking from where the camera is), then only the outer shape is outlined. Yes, that's probably a feature of OutlinePass, not a bug.

Current outline behaviour matches what it's designed to do (linked easy to understand list of steps it does).

I've spent at least 1-2 hours following the OutlinePass source, but I'm not familiar with the subject of vertex shaders or depth masks and while I would like to learn about them in the future, I can't do that right now. I believe the OutlinePass could be modified to achieve what I need.

The OutlinePass currently overrides the scene material to prepare for the edge detection pass. I'm hoping by modifying that behavior (so different objects have different materials, hence can be detected by edge detection pass) could either be modified by changing one of the used shaders or depth parameters to distinguish different objects to outline (and not only their "encompassing shapes", so to speak).

JS fiddle here, look for the UNCOMMENT line at the bottom of JS to see the issue I described. Once you uncomment that line, I would like both of these planes to be outlined.

I'm aware there are other ways to show object outlines (like enlarging an object copy behind it), but I'm interested in using the OutlinePass :). Thank you!

gman
  • 100,619
  • 31
  • 269
  • 393
karni
  • 894
  • 8
  • 15
  • maybe EdgesHelper could help `new THREE.EdgesHelper( small, 0xff0000 )` etc. – George Mar 22 '18 at 02:19
  • Thanks @Noface , actually I intend to use the [EdgesGeometry](https://threejs.org/docs/index.html#api/geometries/EdgesGeometry) (I think that's what you meant), if I can't use the OutlinePass. However, the outline pass has a much nicer looking glow effect. – karni Mar 22 '18 at 09:47
  • perhaps you could get the x,y coordinates of the vertixies you want a glow affect around, and then create your own post processing glow effect? – George Mar 22 '18 at 17:20
  • Sadly I don't know much about post processing. I found OutlinePass in THREE examples and really liked it, but can't use it for selection for the reasons stated above. I studied it, but I'm not familiar with shaders :(. By giving up 50 of my reputation as a bounty, I was hoping someone could help me with what I didn't have time to learn right now. I think I'm left with EdgesGeometry and will just have to learn postprocessing/shaders to get the effect that I want. Thanks for commenting, @Noface – karni Mar 22 '18 at 18:08
  • I noticed that OutlinePass works but not as you indend, with [ small, large ] - the small plane is within the large plane, and therefore the outline for small and large combined is the large plane. if you move the small plane e.g. position.x = 250, you can see it outlines both, but not doesn't create a line inside of the planes (e.g. within large). Perhaps a solution would be to create 2 OutlinePasses, one for small and one for large - however that would be inefficient as it would be doing 2 post processing passes instead of 1. Good luck. – George Mar 22 '18 at 18:46
  • Right, that's exactly the problem. That solution doesn't scale to arbitrary number of planes and that's the exact issue here. I appreciate the time you took to understand my question, thank you @Noface, you have a great day! – karni Mar 23 '18 at 09:16

0 Answers0