https://github.com/codeandweb/cocos2d-dynamic-lighting-with-normal-maps
Dynamic Lighting Demo for Cocos2D with Normal Maps
https://github.com/codeandweb/cocos2d-dynamic-lighting-with-normal-maps
Last synced: 5 months ago
JSON representation
Dynamic Lighting Demo for Cocos2D with Normal Maps
- Host: GitHub
- URL: https://github.com/codeandweb/cocos2d-dynamic-lighting-with-normal-maps
- Owner: CodeAndWeb
- Created: 2015-02-23T15:36:23.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-23T15:00:01.000Z (about 11 years ago)
- Last Synced: 2025-01-07T21:09:38.091Z (over 1 year ago)
- Language: HTML
- Size: 10.5 MB
- Stars: 7
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dynamic Lighting Demo for Cocos2D with Normal Maps
Tutorial by Andreas Loew / CodeAndWeb GmbH
Thanks for collidernyc from Cocos2d Forum for the Swift port
This demo uses the same normal mapped sprite in different dynamic light scenarios.
The light source can be dragged do light the sprite from different angles.
Read the full tutorial: [Cocos2d Dynamic Lighting Tutorial](https://www.codeandweb.com/blog/2015/03/17/cocos2d-dynamic-lighting-tutorial)
#### Summer scene (directonal light)
* Bright yellow directional light
* Bright ambient light

#### Winter scene (directional light, particles)
* Bright light blue directional light
* Bright light blue ambient light
* Snow particles (no light effect, just for the fun)

#### Point light scene (point light)
* White point light (restricted radius)
* Dark gray ambient light

#### Camp fire scene (animated point light + particles)
* Orange point light (restricted radius)
* Dark blue ambient light
* Fire particles (no light effect, just for the fun)
* Animated ligth source position (flickering)

All light effects are calculated in real time using Cocos2D's lighting system.
## Normal Maps
A normal mapped sprite consists of 2 files:


The texture itself is used for the sprite's color.
The pixels in the normal map represent a direction - the direction in which the normal vector of a given pixel is pointing. It's encoded into the color channe - this is where the strange color scheme comes from.
The normal maps were generated using SpriteIlluminator - our [Normal Map Generator](https://www.codeandweb.com/normal-map-generator).
Read the full tutorial: [Cocos2d Dynamic Lighting Tutorial](https://www.codeandweb.com/blog/2015/03/17/cocos2d-dynamic-lighting-tutorial)