Does shadow for directional light even work in SceneKit? - ios

I can only get shadows to work for spotlight, but not for directional light.
Has anyone out there ever gotten it to work? (Using Swift, if that should matter.)

You need to set the scale property of the light e.g.
lightNode.light?.orthographicScale = 50

Try this:
lightNode.light?.automaticallyAdjustsShadowProjection = true

Related

Unwanted self shadowing

I have an ARKit App using SceneKit to render.
I am using a directional light that casts shadows onto an invisible floor plane. In order to do this I have to (?) use shadowMode = .deferred on the light. But this results in the ugly self shadowing in the image:
How can I avoid this and still keep the shadow on the floor plane? The lighting seems fine with shadowMode = .forward, but then I get no shadow on the floor.
There are few methods that could fix this problem.
To use .constant SCNMaterial.LightingModel.
To manipulate with SCNMaterialProperty
To manipulate with categoryBitMask of the node and the light source.
Hope it helps!

Casting shadows using a directional light, plane, and cast shadow

In the WWDC 2017 video, apple explains about a trick to add shadows by using a directional light. Adding a directional light will cast a shadow and adding a plane will show the shadow. But I cannot seem to find mode and colour options of the cast shadow property. I am not looking to do this programatically. So is there any way there is to change the shadow type to Deferred in Xcode?
https://developer.apple.com/videos/play/wwdc2017/604/?time=2715
If I understand your problem.... Then this image explains what you are trying to do using scen view in Xcode.
You are right, adding plane and directional light with Deferred property will cast shadow. You have to set the x,y and z values of all your scene objects accordingly to show this in a proper way.

SceneKit – material's colorBufferWriteMask

I'm working with SceneKit (swift) and found colorBufferWriteMask parameter that working with SCNMaterial. But it's still working with iOS11+.
So, have anyone know a parameter like colorBufferWriteMask that working with iOS9+?
Thanks.
After research about scenekit, i found a solution. The first, i create a SCNNode (A) that is setting with opacity = 0.000001 and renderingOrder = -1. The second, i create other SCNNode (B) that setting with renderingOrder = 100 and add A.
So, right now, Part of B will be hidden, and this is okie like colorBufferWriteMask.
Thanks.

SceneKit Directional Light causing flickering

I'm trying to add a directional light in Scenekit to cast shadows, but it is causing weird artefacts on objects.
The orange block below has a material with default settings and the diffuse set to orange.
The directional light is pointing downwards, and the scale is increased, otherwise it has default settings. (Making the scale smaller still has the same issue).
When I pan the camera around the texture is covered in flickering lines and dots, it looks terrible.
This isn't visible on the simulator, only the device. What is going on and how can I fix it?
Thanks to Toyos I now know that self-shadowing is what's causing the lines. The docs for shadowBias say setting this value should correct it, but for me it made no difference.
In the end I fixed it by rotating the directional light by 2 degrees. It was originally at -90, pointing straight down. Changing this to -88 has completely removed all the artefacts.
Configure the zNear/zFar range of your light to make it as small as possible (but not clipping your world). The smaller the zRange is the more precision you will get.
You can also play with the shadowBias to limit the self shadowing artefacts

Animate (pulse, glow) CPTPlotSymbol using Core Plot

I would like to animate (pulse, glow) the following plot symbol. What is the best way to achieve the desired behavior. Thanks
You cannot animate a plot symbol. What you can do is put a plot space annotation over the highlighted point. Make a custom CPTLayer subclass that draws your symbol shape and use that for the annotation's content layer. Animate the symbol layer using standard Core Animation methods.
I'm not sure about glowing but, I do that there is a method(that I can't seem to recall) that you can call that will do just that! It's like CGResize or something, it exists! Don't lose hope. Sorry i'm not able to help more.
Actually for glowing you could animate it with animationImages = [NSArray arrayWithObjects: then the picture you want to glow just make it dark to bright then bright to dark, then setAnimationRepeatCount:0 to it'll repeat! This way is a bit verbose but it'd work! Best of luck :]

Resources