Lighting and Shadow System

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lighting and Shadow System

Post 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.
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Lighting and Shadow System

Post by slime »

argh
Prole
Posts: 11
Joined: Fri Jan 31, 2014 7:07 am

Re: Lighting and Shadow System

Post by argh »

Yes I believe a Teleglitch-like viewcone can be achieved with a subtractive shadow casting algorithm as the starting point.

Image
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post by Ranguna259 »

Has this been discontinued ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post 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:
Image

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
Attachments
polyshadow.love
(8.7 KiB) Downloaded 347 times
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post 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 ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post 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. :awesome:

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.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post 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:
Image

How to use:

Code: Select all

light.setSmooth(0.5)
light.setGlowSize(0.1) -- 0.1 = 10%
light.setGlowStrength(0.5) -- 0.5 = 50%
Attachments
polyshadow.love
Version 2
(9.06 KiB) Downloaded 123 times
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Lighting and Shadow System

Post 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.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post by Ranguna259 »

PriorBlue, do you have a git for this ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests