How to get sun at noon shadow with SKLightNode

1k Views Asked by At

I'm playing around with SKLightNode. I'm trying to create shadows so that it would look like the sun is at noon. So basically something like this:

enter image description here

However all I can get SKLightNode to render for me is this:

enter image description here

So the problem is that it looks like the light is coming from right next to the object and from the same level.

I have played around with the SKLightNode configuration but this is what I have for the moment (I've tried many configurations that don't seem to have any effect)

   var light = SKLightNode()
    //testing lightnodes
    light.name = "light"
    light.categoryBitMask = 3
    light.position = point
    light.zPosition = 100.0
    light.falloff = 100.00;
    light.enabled = true
    light.lightColor = UIColor(red:  86/255, green: 128/255, blue: 45/255, alpha: 0.5) //initWithRed:1.0 green:1.0 blue:0.0 alpha:0.5];
    light.shadowColor = UIColor(red:  220/255, green: 220/255, blue: 220/255, alpha: 0.3)//[[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.3];
    light.ambientColor = UIColor(red:  220/255, green: 220/255, blue: 220/255, alpha: 0.3)//[[UIColor alloc] initWithRed:0.0
    addChild(light)
1

There are 1 best solutions below

4
On

You can't achieve the effect you want with SKLightNode. Remember that SK is a 2D platform. Your desired effect is 3D. You can probably achieve the effect you want by adding a child to your node with a position offset and custom alpha settings.