Search code examples
swiftscenekitscnnode

How to create a neon material using SCNMaterial in swift?


I've been experimenting with SCNMaterials, focussing on emission to try and create a neon material. Not sure if it is possible, but if it could emit light, that would be great. Thanks :)


Solution

  • It's simple:

    material.emission.contents = [NSColor greenColor];
    

    all this does is make the material glow in it's own light.
    If you wish to make other objects affected by this neon light,
    you could add a light to your neon node like so:

    SCNLight *mylight = [SCNLight light];
    mylight.type = SCNLightTypeOmni;
    mylight.color = [NSColor greenColor];
    myNeonNode.light = mylight;
    

    Hope that helped!

    Note:

    the power of the light can be controlled by the color you use:
    Dark green will seem like a green light that is not so powerful.
    Light green will seem like a green light that is more powerful.