Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 399
justking14 Avatar asked Oct 19 '22 14:10

justking14


2 Answers

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.

like image 130
mnuages Avatar answered Oct 22 '22 22:10

mnuages


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.

like image 43
Morty Avatar answered Oct 22 '22 23:10

Morty