Create light rays (like a spotlight) in SceneKit - scenekit

How would I go about creating a spotlight in SceneKit where you can actually see the cone of light, not just the light on the surface of the object it hits? Sort of like how you can see the Bat Signal's cone of light in the night sky.
It doesn't seem like SceneKit lights support this out of the box. The best I can come up with so far is adding cone geometry with material properties that sort of make it look light a light. But then how would I fade out the top part of the cone?

Related

Physically Based lighting lost after using metal shader on another model?

i got 2 models on my scene (using SceneKit) - ring and diamond. Ring is with gold pbr material (SCNLightingModelPhysicallyBased) - second is diamond with "custom" material using Metal shader (SCNProgram). Right after developing diamond shader my golden ring stopped working and is pure black. Why is that ? When i simply set my ring to yellow and drop pbr lighting model it works, just not pbr - with pbr its solid black. I cant use SCNProgram with PBR ?
Are you setting the scene's lightingEnvironment? You will need a light source in the scene for the object to be lit. You can either use point lights or leverage image-based lighting (IBL) which is what the lightingEnvironment is for.
You can also try the autoenablesDefaultLighting property. With it SceneKit will try to adjust and add light sources in the scene depending on its contents, but its behaviour is subject to changes.

Scenekit - add red tint to camera

Is it possible to add a red tint to a given camera in SceneKit? I would like to accomplish this without the (what I consider to be) hacky solution of just trying to shove a red object with < 1 opacity in front of the camera. That could be a solution but I haven't had great success in SceneKit showing an object right in front of the camera.
Also, ideally, I could fade the red tint in and out using SCNAction or some other way.
Finally, a perfect solution would work in ARKit, and give a red tint to the whole world around you. So it would have to be something more than a red scenekit light.
SCNCamera's colorGrading property can do that (that would be the most efficient option).
Using a SCNTechnique to apply a custom post process would work too but it requires an additional pass.
Both options would be faster than a blended node in front of the camera, or a red-ish spritekit overlay or a UIView on top of the SCNView.
Instead of adding a red-tinted SCNNode into the scene, you could just add a tinted UIView in front of the ARSCNView in the storyboard. With an outlet to that view fading it in and out would be easy.

What projection matrix does SceneKit use for directional light shadows?

I'm trying to prevent shadow swimming when moving the directional light around to cover only the visible part of my scene. Despite rounding the translation components in light space, they swimming artifacts are still there.
I even tried pointing the light directly down (with a scale of 2 and shadow map size of 32) and translated the directional light along the world x-axis by -1 and +1. The shadows still changed. I can only assume they aren't using normal orthographic projection. The shadows seem to move more when near the edge too.
Has anyone had luck preventing shadow swimming in SceneKit, or knows what projection matrix is being used for the directional light shadows?

How to implement halo effect with Wpf 3D?

I'm trying to build a 3D earth with Wpf Viewport3D. I have created the earth and it works pretty good. Then I want to add a halo effect around the earth like this attached image:
.
Some recommend to use diffuse material for the globe model. Then build a slight larger globe model with emissive material and little opacity. But the effect is not very good. It affects the color of diffusion material like this:
How can I implement the effect like the first screenshot?
I've done exactly this by creating a ring, inner radius the same radius as the planet and an outer radius to relect the atmospheric depth. Oriented to 'face me'. Using texture coordinates into a LinearGradientBrush to have the atmosphere fade from sky blue to transparent black.
Alternatively, there are some fairly good PNGs around of semi-transparent cloud layers you could use on the slightly larger sphere.

Light Map projection

What i'm trying to do is making a "light projector" with visible ray(like with fog) also called volumetric light;
and which project a image (bitmap) ;
Because i would like to keep this project connected with a wpf application ( to get brush, position, rotation from data), i've choose to use WPF 3D
But it seem that WPF can't handle light projection or render ray.
So to do that, i have extruded each pixel of my source bitmap into a polygon colored by a solidColorBrush of the pixel color.
and keep the pixel order with (x,y) position.
For performance issue, i've set all the bitmaps to 32x32 px ( 1024 polygon for only one light !!)
But the result is too pixelated as you can see on the picture.
Moreover, it probably take much memory for nothing ...
my question is, how can i make it smooth or even rethink the extrusion system to optimize performance ...
Is any other tehnology that can be integrated into a wpf application and do that better or easier ?
Thanks, and sorry my English is pretty bad ...
alt text http://www.visualdmx.fr/pic_example.png

Resources