Wiki
Clone wikiLove2D Light and Shadow Engine / Home
Functions
- love.light.newBody
- love.light.newCircle
- love.light.newImage
- love.light.newLight
- love.light.newRectangle
- love.light.newPolygon
- love.light.newWorld
Objects
Features
- Project Page (Forum)
- Preview (Video)
- polygon shadow calculation Preview
- circle shadow calculation
- image shadow calculation Preview
- shadow blur
- light color, range, smooth and glow Preview
- ambient light
- self shadowing on images with normal maps Preview
- dynamic glow effect on images and circle/poly objects Preview Preview
- generate flat or gradient normal maps Preview
- convert height maps to normal maps Preview
- generate a normal map directly from the image (usually gives poor results)
- can now be used with camera translation (use: lightWorld.setTranslation(x, y))
- shadow color and alpha (glass) Preview
- directional light Preview
- refractions (moveable) Preview
- chromatic aberration Preview
Example
#!lua require "postshader" require "light" function love.load() -- create light world lightWorld = love.light.newWorld() lightWorld.setAmbientColor(15, 15, 31) -- optional -- create light (x, y, red, green, blue, range) lightMouse = lightWorld.newLight(0, 0, 255, 127, 63, 300) lightMouse.setGlowStrength(0.3) -- optional -- create shadow bodys circleTest = lightWorld.newCircle(256, 256, 32) -- (x, y, radius) rectangleTest = lightWorld.newRectangle(512, 512, 64, 64) -- (x, y, width, height) end function love.update(dt) -- show FPS love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")") -- set light to mouse position lightMouse.setPosition(love.mouse.getX(), love.mouse.getY()) end function love.draw() -- update lightmap (doesn't need deltatime) lightWorld.update() -- draw background love.graphics.setColor(255, 255, 255) love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) -- draw lightmap shadows lightWorld.drawShadow() -- draw scene objects love.graphics.setColor(63, 255, 127) love.graphics.circle("fill", circleTest.getX(), circleTest.getY(), circleTest.getRadius()) love.graphics.polygon("fill", rectangleTest.getPoints()) -- draw lightmap shine lightWorld.drawShine() end
Updated