There are several ways to do lights, since Löve supports stencils and framebuffers it's not too complicated even if you want multiple lights. I rely on the physics engine's features (here's what I wrote about it) to do dynamic lights. However my game's mechanic requires the lights to behave in a very specific way.
Generally speaking though, you need to find the corners / edges that are relevant. Then you'll either be filling the light sections in, or stenciling out the shadows in some way. I suppose if you only plan to use a triangular light in simple scenes you could use a method like I do, but it's generally easier to stencil out the shadows.
Light (dynamic?)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- The Burrito
- Party member
- Posts: 153
- Joined: Mon Sep 21, 2009 12:14 am
- Contact:
Re: Light (dynamic?)
I think you're looking for a hand to hold you, and I don't think you'll find it. We've linked to plenty of resources that tell you exactly how to make effective 2D lighting, you just need to apply it. It's like when a math teacher teaches you how to use the quadratic formula, then gives you this problem:
A garden measuring 12 meters by 16 meters is to have a pedestrian pathway installed all around it, increasing the total area to 285 square meters. What will be the width of the pathway?
It's your job to use the tools given to you to solve that problem, just like it's your job to use the tools freely available on the Internet to solve your problem.
A garden measuring 12 meters by 16 meters is to have a pedestrian pathway installed all around it, increasing the total area to 285 square meters. What will be the width of the pathway?
It's your job to use the tools given to you to solve that problem, just like it's your job to use the tools freely available on the Internet to solve your problem.
Re: Light (dynamic?)
I'm just trying to say that I don't know how to find the corners of a drawn object...
u wot m8
Re: Light (dynamic?)
You are being just "lazy" no? MarekkPie give the concept/formulas and ways to achieve that (http://forums.tigsource.com/index.php?topic=8803.0), Burrito also was kind enough for sharing his own advices and even I show you a thread with LOVE examples to peek and discover "how to find the corners" in LUA. (viewtopic.php?f=5&t=1871) And here it's another good LOVE example (viewtopic.php?f=4&t=5340&p=42674#p42738). So what you are complaining about? That someone didn't wrote the code for you?rokit boy wrote:I'm just trying to say that I don't know how to find the corners of a drawn object...
Re: Light (dynamic?)
When there is a simple problem, then you might get some actual code written out here. Many examples of that are found throughout the forums. But this isn't something simple, and all of us have other things that we do outside of lurking on these forums. So, the best you'll (probably) get is links to other people explaining how to do it.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Light (dynamic?)
Your technique depends on what you want out of the shadows, and their nature. For example, in Underlife, since there's only one light source in a world of equally-sized tiles and I want the shadows to be very soft, I basically project a simple cone of shadow (image) from each tile, oriented to face the light (the player), stretching according to distance, etc..
Here's an (outdated) demonstration of it:
Here's an (outdated) demonstration of it:
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Who is online
Users browsing this forum: DTmg, rabbitboots and 7 guests