<!--
{
  "documentType" : "article",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/lighting-a-sprite-with-light-nodes",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Lighting a Sprite with Light Nodes"
}
-->

# Lighting a Sprite with Light Nodes

Add lighting and shadows to your scene with light nodes.

## Discussion

You can use a sprite’s lighting properties, [`lightingBitMask`](/documentation/SpriteKit/SKSpriteNode/lightingBitMask), [`shadowCastBitMask`](/documentation/SpriteKit/SKSpriteNode/shadowCastBitMask) and [`shadowedBitMask`](/documentation/SpriteKit/SKSpriteNode/shadowedBitMask), to apply effects such as illumination and shadow casting and receiving. These can be used in conjunction with normal mapping to simulate 3D lighting.

The following figure shows a normal mapped sprite node acting as background and two shadow casting sprite nodes (each with a rabbit texture).

The [`SKLightNode`](/documentation/SpriteKit/SKLightNode) object’s [`categoryBitMask`](/documentation/SpriteKit/SKLightNode/categoryBitMask) matches the lighting bit mask of the background, and the lighting and shadow bit masks of the two rabbits:

```swift
// Create the background sprite node
let background = SKSpriteNode(texture: noiseTexture,
                              normalMap: noiseTexture.generatingNormalMap())
background.position = spriteKitViewController.center
background.lightingBitMask = 0b0001
scene.addChild(background)
     
let x: CGFloat = 150
let y = spriteKitViewController.scene.size.width - 150
     
// Create a light
let lightNode = SKLightNode()
lightNode.position = CGPoint(x: scene.size.width / 2, y: y)
lightNode.categoryBitMask = 0b0001
lightNode.lightColor = .white
scene.addChild(lightNode)
     
// Create two rabbit sprite nodes and assign them with both a lighting and a shadow cast bit mask.
for position in [CGPoint(x: x, y: y), CGPoint(x: y, y: y)] {
                    let rabbit = SKSpriteNode(imageNamed: "rabbit")
                    rabbit.position = position
                    spriteKitViewController.scene.addChild(rabbit)
                    rabbit.lightingBitMask = 0b0001
                    rabbit.shadowCastBitMask = 0b0001
}
```

The resulting scene shows the two rabbits casting shadows over the background (the light is rendered as a white circle). The noise texture gains a 3D look from the normal mapping:

![Shadow casting and normal mapping](images/com.apple.spritekit/media-2983060@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)