Complex shape character outline

后端 未结 5 2077
太阳男子
太阳男子 2020-12-05 01:07

Say I have this character and I want allow user to select it, so when it s selected I want to show an outline around it.

5条回答
  •  再見小時候
    2020-12-05 01:51

    What @spassvolgel wrote is correct;

    What I suspect needs to be done is something like this: 1. First the background needs to be rendered 2. Then, on a separate transparent layer, the character model with a flat color, slightly bigger than the original, 3. On another transparent layer the character with its normal material / texture 4. Finally, the character layer needs to go on top of the outline layer and them combined need to be placed in the bg

    You just create multiple scenes and combine them with sequential render passes:

    renderer.autoClear = false;
    . . . 
    
    renderer.render(scene, camera); // the entire scene
    renderer.clearDepth();
    renderer.render(scene2, camera); // just the selected item, larger, in a flat color
    renderer.render(scene3, camera); // the selected item again
    

    Here is a fiddle implemented with GPU picking, but it could just as easily be implemented with the more-familiar Raycaster:

    Fiddle: http://jsfiddle.net/Tcb3z/

    Screenshot of selected item outlined

    three.js.r.66

提交回复
热议问题