Light beams - some kind of lighting system?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Larsii30
Party member
Posts: 267
Joined: Sun Sep 11, 2011 9:36 am
Location: Germany

Light beams - some kind of lighting system?

Post by Larsii30 »

Hey everyone.

atm I'm working on a 2D Puzzle Platformer and want to draw a light beam on every object which is able to shine ( and on the player, some kind of sight ).
My first idea maybe was the simplest. a image which is centered on the objects position.
yROuO.png
yROuO.png (83.41 KiB) Viewed 330 times
Problem: for the player only it does work with the image, but the image has to be much bigger then the screen because of the camera movement. ( and also the image file is big )

Now I want to let torches shine or laserbeams etc. as well. So the image variante does not work anymore.
Is there a way to use pixeleffects to let specific objects shine?
I've never tried something like this before and also don't know how pixeleffects work .
( is it even possible with pixel effects ? )

thanks.
User avatar
Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

Re: Light beams - some kind of lighting system?

Post by Saegor »

Larsii30 wrote:Is there a way to use pixeleffects to let specific objects shine?
i don't know if pixeleffect will work for that (i think that yes because IF i understand corectly, pixeleffect is a sort of layer (shader) who add an effect depending of the image drawed and some parameters) but if you choose it, don't forget to send me a graphic card by post with your .love game because i don't have any pixeleffect support :halloween:
Current work : Isömap
User avatar
Larsii30
Party member
Posts: 267
Joined: Sun Sep 11, 2011 9:36 am
Location: Germany

Re: Light beams - some kind of lighting system?

Post by Larsii30 »

hehe, too bad. I also would prefer a way to do it without pixeleffects ( because I don't know how to use it and didn't got much time to find it out :D )
I imagine such a lighting system in general isn't as easy.
I've seen something like this in a "game" called "Not a Game" by VRLD but I don't find the thread.
Need some guidence.
Did anyone else something like this before ?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Light beams - some kind of lighting system?

Post by Nixola »

lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
felix24
Party member
Posts: 163
Joined: Tue Jul 26, 2011 4:51 pm
Contact:

Re: Light beams - some kind of lighting system?

Post by felix24 »

you could use shaders alright to do this. don't ask me how cause i don't have a flaming clue :crazy: but this viewtopic.php?f=5&t=11076&hilit=lighting might help.

other than that, if you want specific objects to "shine", maybe you could make an "unlit" and "lit" image for each one. draw the "lit" image over the "unlit" one and update it's alpha depending on how far away the light source is.

For example: let's say you want a floor tile (grass in your case) to "reflect" the light of a torch, you could make two images for the tile. a normal one and a second one with the brightness on the grass turned up. then do a distance check between the grass tile and the torch. depending on the distance, set the alpha value of the "reflect" image. so the closer it is, the higher the alpha value, the brighter the grass looks. this would also mean you could move the light source on the fly and the lighting of your objects would change too. could be kinda cool.

i haven't tried this before, it just came to my head there. but it might give you an ok looking lighting effect without using shaders.

good luck! nice work so far btw ^^
User avatar
Larsii30
Party member
Posts: 267
Joined: Sun Sep 11, 2011 9:36 am
Location: Germany

Re: Light beams - some kind of lighting system?

Post by Larsii30 »

thanks felix.
I thing I will try something like this :)
Knaimhe
Prole
Posts: 34
Joined: Mon Jan 23, 2012 7:23 pm

Re: Light beams - some kind of lighting system?

Post by Knaimhe »

As far as the shadow image goes, you could just enlarge that. Might be a choppier gradient, but I don't think it really matters in a pixellated game.

For the "shining" of torches and the such, you could draw a glow effect (like a reverse shadow, see?) OVER the shadow. The glow effect wouldn't show any of the walls or things near the torch, but you can still see the torch's glow and whatnot.

That's the easiest way I can think of doing it.
User avatar
Larsii30
Party member
Posts: 267
Joined: Sun Sep 11, 2011 9:36 am
Location: Germany

Re: Light beams - some kind of lighting system?

Post by Larsii30 »

felix24 wrote: idea with distance and alpha value here
Great idea, there are only three little problems.
First, I can't use canvases anymore :/ ( could get fixed )
Second, my math is terrible :D Look :
Third , the result does not look exectly how I want it, but maybe this way looks also good enough
5jfVf.png
5jfVf.png (42.31 KiB) Viewed 332 times
here is my test file( just loads a map ):
LightingTest.love
(9.34 KiB) Downloaded 90 times
I search for some math to do this....
User avatar
felix24
Party member
Posts: 163
Joined: Tue Jul 26, 2011 4:51 pm
Contact:

Re: Light beams - some kind of lighting system?

Post by felix24 »

Larsii30 wrote:
felix24 wrote: idea with distance and alpha value here
Great idea, there are only three little problems.
First, I can't use canvases anymore :/ ( could get fixed )
Second, my math is terrible :D Look :
Third , the result does not look exectly how I want it, but maybe this way looks also good enough
Image

here is my test file( just loads a map ):
The attachment LightingTest.love is no longer available
I search for some math to do this....
ok so i fixed it up a bit with a quick and dirty solution. it now lights around the two torches and around the mouse cursor :)
i attached the updated love file
Attachments
LightingTest 2.love
(9.99 KiB) Downloaded 109 times
User avatar
Larsii30
Party member
Posts: 267
Joined: Sun Sep 11, 2011 9:36 am
Location: Germany

Re: Light beams - some kind of lighting system?

Post by Larsii30 »

I owe you. Thanks. ! :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests