Is there a way to add an outline in scene kit?

一笑奈何 提交于 2019-12-05 01:10:24

问题


I've been making a game in scene kit, but the edges of objects are difficult to see, making some of the games details impossible to see. Is there a way to make a black outline around all the game objects?


回答1:


you could use an SCNTechnique as mentioned in another answer (you can have a look at this article about cel shading, which has an edge-detection pass) but full-frame post-processes are quite expensive.

On OS X you can also leverage geometry shaders (see this article). But it's not available on iOS and might be harder to implement and get right.

I would go with a much easier technique, which only involves vertex and fragment shaders. You can take a look at this article, which gives an example that's easy to re-create in SceneKit using SCNProgram or shader modifiers.




回答2:


There is an example of making a glowing outline for nodes that uses SCNTechnique here: https://github.com/laanlabs/SCNTechniqueGlow

You could modify the color and blur method to achieve an stroked outline effect.




回答3:


Another SCNTechnique example, as referenced here: https://www.nurfacegames.com/everything-you-wanted-to-know-about-outline-shaders/, is to render your node slightly larger behind then again in front at regular size.

Here's a playground example of that: https://github.com/mackhowell/scenekit-outline-shader-scntechnique.



来源:https://stackoverflow.com/questions/29665700/is-there-a-way-to-add-an-outline-in-scene-kit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!