Page 3 of 5
Re: Lighting and Shadow System
Posted: Thu Feb 06, 2014 9:33 am
by Jasoco
Actually the way Teleglitch does "lighting" is not actual lighting. The camera is fixed always facing down and each wall has a black wall above it that reaches all the way up to the camera. It gives the illusion of being lighting.
It's just a fancy 3D trick. And a pretty unique one at that.
Re: Lighting and Shadow System
Posted: Thu Feb 06, 2014 10:21 am
by slime
Re: Lighting and Shadow System
Posted: Thu Feb 06, 2014 10:47 am
by argh
Yes I believe a Teleglitch-like viewcone can be achieved with a subtractive shadow casting algorithm as the starting point.
Re: Lighting and Shadow System
Posted: Sun Mar 02, 2014 1:07 pm
by Ranguna259
Has this been discontinued ?
Re: Lighting and Shadow System
Posted: Sun Mar 02, 2014 6:44 pm
by PriorBlue
Hi,
i don't know, if this project is canceled (because the screenshots and links are empty). So i post here my "own" light shadow engine. The code for the poly2shadow calculation is not from me, but i have added a circle shadow calculation, a functionality to blur the shadows, light interaction with the object surface (no self shadowing at the moment), better performance when only lights are moving and i packed all the code in an easy "love-like" module.
Here a colorful screenshot:
To use the engine, just implement these:
Code: Select all
require "light"
function love.load()
-- light world
lightWorld = love.light.newWorld()
lightWorld.setAmbientColor(15, 15, 15)
-- add light example (x, y, red, gree, blue, range)
mouseLight = lightWorld.newLight(x, y, 127, 63, 0, 400)
-- add a few shadowbody examples
shadowRect = lightWorld.newRectangle(0, 0, 32, 32) -- (x, y, width, height)
shadowCircle = lightWorld.newCircle(0, 0, 16) -- (x, y, radius)
shadowPoly = lightWorld.newPolygon(0, 0, 1, 0, 0, 1) -- (polygon data)
end
function love.update(dt)
-- example for change your light position
mouseLight.setPosition(love.mouse.getX(), love.mouse.getY())
-- a few examples for change the shadow bodys
shadowRect.setPosition(x, y)
shadowCircle.setRadius(64)
shadowPoly .setPoints(0, 0, 1, 0, 0, 1)
-- or get the poly direct from a physic object
shadowPoly .setPoints(phyExample.body:getWorldPoints(phyExample.shape:getPoints()))
-- update lightmap
lightWorld.update()
end
function love.draw()
-- draw lightmap shadows
lightWorld.drawShadow()
-- Draw your stuff here
-- draw lightmap shine (optional)
lightWorld.drawShine()
end
Have fun!
PS: just for your interest, i made a experimental pixel based shadow shader, check it out ->
http://love2d.org/forums/viewtopic.php? ... 20#p163757
Re: Lighting and Shadow System
Posted: Mon Mar 03, 2014 12:58 pm
by Ranguna259
You know what, I'm gonna drop my shadow and lightning project and I'm just going to use yours, would it be ok if I sent you the bugs (if I find any) of your code or some suggestions ?
Re: Lighting and Shadow System
Posted: Tue Mar 04, 2014 3:40 am
by PriorBlue
Ranguna259 wrote:You know what, I'm gonna drop my shadow and lightning project and I'm just going to use yours, would it be ok if I sent you the bugs (if I find any) of your code or some suggestions ?
Yes, of course and it would be nice if you post your improvements too.
I love the idea of an easy to use standard light library like the physics module and the more people are working on it, the better the result.
Re: Lighting and Shadow System
Posted: Tue Mar 04, 2014 4:02 am
by PriorBlue
So i have added a few new features:
- added optional glow
- glow size and strength can be changed
- added light smoothing (for discreet lighting or spot lights)
Preview:
How to use:
Code: Select all
light.setSmooth(0.5)
light.setGlowSize(0.1) -- 0.1 = 10%
light.setGlowStrength(0.5) -- 0.5 = 50%
Re: Lighting and Shadow System
Posted: Tue Mar 04, 2014 4:44 am
by ArchAngel075
Regarding the latest polyshadow :
I seemed to be unable to change the strength of the light (mouse wheel) after fiddling around, All i could achieve was scrolling alot to make it suddenly jump from no light intensity to maximum and then scrolling in the opposite direction just made it jump to 0 light intensity again instead of the smooth/gradual declining intensity.
Not sure how to replicate the issue though.
Re: Lighting and Shadow System
Posted: Tue Mar 04, 2014 12:54 pm
by Ranguna259
PriorBlue, do you have a git for this ?