5

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?

justking14
  • 105
  • 2
  • 7
  • There isn't enough information in your question to make it meaningfully answerable. Include an example of your existing code. – Robert Harvey Apr 16 '15 at 05:04
  • 1
    Yes there is a way, but it would involve using SCNTechnique to perform multi pass rendering. It would involve rendering the color and depth of the scene in one pass and then do edge detection on the depth (for example a Sobel filter) and composite the edges on top of the colors from the first render pass. An answer that goes into detail on all of that would likely be too long for a good answer. – David Rönnqvist Apr 16 '15 at 08:03

3 Answers3

2

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.

mnuages
  • 13,049
  • 2
  • 23
  • 40
1

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.

Morty
  • 1,436
  • 14
  • 12
0

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.

blueberries
  • 71
  • 1
  • 4