Light (dynamic?)

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
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: Light (dynamic?)

Post by The Burrito »

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.
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Light (dynamic?)

Post by rokit boy »

How do I do that?
u wot m8
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Light (dynamic?)

Post by MarekkPie »

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.
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Light (dynamic?)

Post by rokit boy »

I'm just trying to say that I don't know how to find the corners of a drawn object...
u wot m8
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Light (dynamic?)

Post by coffee »

rokit boy wrote:I'm just trying to say that I don't know how to find the corners of a drawn object...
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?
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Light (dynamic?)

Post by MarekkPie »

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.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Light (dynamic?)

Post by Taehl »

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:
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+.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 53 guests