Dynamic lighting and shadows
Posted: Tue Jul 15, 2014 11:19 am
Hi, I wanted to share my lights.
It's pretty simple:
It's all runs smoothly, even with many lights and many Box2D bodies.
I just wanted to share and see what you guys think
Well I just saw this: viewtopic.php?f=5&t=77418
Code on GitHub in case anyone wants to see:
https://github.com/jacobbrunson/Love-Lights
Here's a standalone .love if you want it:
https://github.com/jacobbrunson/Love-Li ... ights.love
Controls:
https://github.com/jacobbrunson/BasicLighting
http://jacobbrunson.me/lights.html
It's pretty simple:
Code: Select all
For every light
For every block
Iterate over edges of block, calculating the shadow for each edge
Draw the shadows to the inverted stencil
Turn on shader and additive blending
Draw a fullscreen rectangle (shader renders the light with some simple math)
Change blending mode to multiply
Render every block with color
I just wanted to share and see what you guys think
Well I just saw this: viewtopic.php?f=5&t=77418
Code on GitHub in case anyone wants to see:
https://github.com/jacobbrunson/Love-Lights
Here's a standalone .love if you want it:
https://github.com/jacobbrunson/Love-Li ... ights.love
Controls:
- Left-Click: Place light
- Right-Click: Drag block
- A/D: Cycle light hue
- W/S: Change light sizes
- Z: Remove light
- F: Spawn blocks
- R: Remove blocks
- G: Toggle gravity
- Arrow keys: Move blocks
https://github.com/jacobbrunson/BasicLighting
http://jacobbrunson.me/lights.html