Have been looking at lighting on Scenekit, and while I can now apply a lighting node to light something I'm looking for a way to light from within an object.
As an example imagine a neon glow, or a lightbulb that casts light on other objects.
Any ideas how to achieve this?
Many thanks.
As @DavidRönnqvist hints in comments, there are multiple ways to make an object appear to glow. You can do these together or individually — you'll probably need to tweak how you combine them to get the effect you want.
For an object that emits light, you probably don't want shading from other light sources in the scene. Work with the emission
channel of your material to give the object a color or texture that overrides shading from other light sources. (If you use a texture, the brighter parts will appear to glow, as seen in the example from the aforelinked documentation.)
You might want other elements in your scene to be lit by the glowing object. The emission
material property just keeps the object from being darkened by lighting/shading, it doesn't make it a light source. To get a light source, you'll need to add at least one SCNLight
to the node tree containing your object.
Depending on your scene, you might be able to get away with just one light source; e.g. if the object is a light bulb, you can place a light at its center and be done with it. (Well, you might also need to play with the category bit masks of the node and the light to make sure the light shines out through the light bulb instead of being occluded by it.) If you have a large, complicated neon sign, you might need to create multiple light sources — otherwise, the lighting on objects near the sign will betray that it's a single point light. (If there isn't anything close to the sign being lit by it, a single point light might be good enough.)
If you're looking to have a glowing halo around the light source, things get a bit harder. That's volumetric lighting, and it's not something that SceneKit can do for you out of the box. But there are a few ways you might fake it:
SCNParticleSystem
, since that can spawn particles all along the surface of a geometry.emission
to the rescue.)EDIT: woops, I may have misunderstod the question... Rickster's answer is more adapted to your needs.
Glowy 3D is my domain!
There are a few ways you can make an object glow in SceneKit.
The most straightforward way is to set it up in GLSL using SCNTechnique
. You will need multiple passes, to render the illumination then blur it on succesively X and Y (faster than both at once). There is a great article about it on GPU Gems. However this one is quite heavy if you overuse it, and I'm not quite sure if you can target the illumination only in SCNTechnique
.
The second way is using CI filters. Simply add a Gaussian Blur and composite it on top. You may need additional effects to select/boost the glowing elements. If you're looking for a glow around the object this question might help you as well.
Third way is to fake the glow using billboards. Make a stencil in photoshop or your 3D software, put it on a plane that always faces the camera. Change its blending mode to Screen and you have a very inexpensive glow!
Finally, for your light shining effect, you might want to look into godrays. They're pretty easy to set up using GLSL as well, so SCNTechnique
should do the trick. Here is an article about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With