Search code examples
swiftscenekitscenescnnodescntext

How to change the color of text just on one (front) side SCNText?


I am working with SCNScene where I place the SCNText node, so as a result, I get 3d text on the scene, the problem is that if I change the depth of the text it looks like a block of solid color, so it is hard to see what exactly on the screen, there are a few examples

enter image description here

enter image description here

I need somehow came up with the idea of how to make the text understandable even when it has a big depth value

I thought about drow the edges like this (I am not a good artist:)

enter image description here

Hope you got the idea

Or make the front side of the text lighter or in a different color, like this, so it will be more obvious for the user what it is written

Is there a way to do something like this?

enter image description here


Solution

  • from the documentation:

    A text geometry may contain one, three, or five geometry elements:

    If its extrusion depth is greater than zero and its chamferRadius property is 0.0, the text geometry has three elements, corresponding to its front, back, and extruded sides.

    SceneKit can render each element using a different material. For details, see the description of the materials property in SCNGeometry.

    So you can set an array of materials, with one SCNMaterial instance for the front, and another material used twice for the back and sides.