light_world.lua/README.md

76 lines
2.9 KiB
Markdown
Raw Normal View History

# light_world.lua
2021-11-08 21:36:38 +00:00
This is the light modeling done by Priorblue [here](https://bitbucket.org/PriorBlue/love2d-light-and-shadow-engine),
only it has been largely refactored and edited to allow for scaling and proper translation.
2016-04-26 13:24:49 +00:00
2019-09-10 09:24:54 +00:00
*Supports love 11.2(master branch), 0.10.1(commit 414b9b74c0eb95bfb8b5e26a11caf2b32beccca0)
2021-11-08 21:36:38 +00:00
## Installation
2021-11-08 21:36:38 +00:00
2014-10-27 12:10:25 +00:00
Copy and rename the lib folder into your project.
2021-11-08 21:36:38 +00:00
## How to use
```lua
2014-10-28 05:04:25 +00:00
local LightWorld = require "lib" --the path to where light_world is (in this repo "lib")
2014-12-05 14:52:16 +00:00
--create light world
function love.load()
lightWorld = LightWorld({
2019-09-10 09:24:54 +00:00
ambient = {55/255,55/255,55/255}, --the general ambient light in the environment
2014-12-05 14:52:16 +00:00
})
end
function love.update(dt)
lightWorld:update(dt)
2014-12-05 14:59:17 +00:00
lightWorld:setTranslation(x, y, scale)
2014-12-05 14:52:16 +00:00
end
function love.draw()
love.graphics.push()
love.graphics.translate(x, y)
love.graphics.scale(scale)
2014-12-05 14:52:16 +00:00
lightWorld:draw(function()
-- do your stuff
end)
love.graphics.pop()
end
```
2021-11-08 21:36:38 +00:00
For more information please check out the [wiki](https://github.com/tanema/light_world.lua/wiki) and see the examples directory to see how it is fully used. This project can be run with love to see the demonstrations in action.
2014-10-27 12:09:45 +00:00
2014-12-05 14:54:01 +00:00
### Gamera & HUMP
There are example in the example directory how to use both of these with the library.
2014-10-27 12:09:45 +00:00
## Features ##
* **[Preview (Video)](https://www.youtube.com/watch?v=6V5Dtsa6Nd4)**
* polygon shadow calculation [Preview](http://onepixelahead.de/love2d_polyshadow.png)
* circle shadow calculation
* image shadow calculation [Preview](http://onepixelahead.de/love2d_polyshadow18.png)
* shadow blur
* light color, range, smooth and glow [Preview](http://onepixelahead.de/love2d_polyshadow2.png)
* ambient light
* self shadowing on images with normal maps [Preview](http://onepixelahead.de/love2d_polyshadow_pixelshadow.png)
* dynamic glow effect on images and circle/poly objects [Preview](http://onepixelahead.de/love2d_polyshadow_glow.png) [Preview](http://onepixelahead.de/love2d_polyshadow15.gif)
* generate flat or gradient normal maps [Preview](http://onepixelahead.de/love2d_polyshadow7.png)
* convert height maps to normal maps [Preview](http://onepixelahead.de/love2d_polyshadow8.png)
* generate a normal map directly from the image (usually gives poor results)
* shadow color and alpha (glass) [Preview](http://onepixelahead.de/love2d_polyshadow9.png)
* directional light [Preview](http://onepixelahead.de/love2d_polyshadow12.png)
* refractions (moveable) [Preview](http://onepixelahead.de/love2d_polyshadow13.gif)
* chromatic aberration [Preview](http://onepixelahead.de/love2d_polyshadow16.gif)
* postshader with many included postshaders, plus easy to extend
2014-12-05 14:59:17 +00:00
* animations in tandem with normal maps thanks to [anim8](https://github.com/kikito/anim8)
2021-11-08 21:36:38 +00:00
## License
A License has been included in this project
2019-09-09 13:17:48 +00:00
## Contributors
2019-09-09 13:21:45 +00:00
- Jon @xiejiangzhi
2021-11-08 21:36:38 +00:00
- Brandon Blanker Lim-it @flamendless
2019-09-09 13:21:45 +00:00
- @Azorlogh
- Gustavo Kishima @gukiboy
- Rose L. Liverman @TangentFoxy
- Kyle McLamb @Alloyed