Löve "Light vs. Shadow" Engine v2

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Löve "Light vs. Shadow" Engine v2

Post by drunken_thor » Sun Jan 04, 2015 3:17 am

nucular wrote:Is it possible to apply the light/shine map to the drawn objects, so that tiles hidden behind other tiles (casting a shadow on them) are actually hidden (but objects the light shines on aren't)? I am using the engine together with STI if that is relevant.

To clarify, I marked the areas that I don't want to be lit in this image:
Image

I'd guess it would be possible if the light/shine map could be drawn on the shadow map additively.
I am pretty sure that is possible just play with ambient colors, just turn the ambient all the way to black.
Light_world.lua for all your lighting needs
Github
twitter

User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Löve "Light vs. Shadow" Engine v2

Post by drunken_thor » Sun Jan 04, 2015 3:20 am

giann wrote:I think I did it !
yes.png
I pass to the shadow shader an image with only the non-floor normals. I apply the shadow attenuation over normals only if not on a non-floor normal. I can do a pull request if you want ;)
Hey giann, I just pushed a change to do what you described in a more general way. Now objects that do not cast shadows have shadows applied over top of them. Give it a try and see how it works.
Light_world.lua for all your lighting needs
Github
twitter

giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

Re: Löve "Light vs. Shadow" Engine v2

Post by giann » Sun Jan 04, 2015 8:00 am

nucular wrote:Is it possible to apply the light/shine map to the drawn objects, so that tiles hidden behind other tiles (casting a shadow on them) are actually hidden (but objects the light shines on aren't)? I am using the engine together with STI if that is relevant.

To clarify, I marked the areas that I don't want to be lit in this image:
Image

I'd guess it would be possible if the light/shine map could be drawn on the shadow map additively.
What you want is to apply a field of vision from the point of view of your character/player. Light vs Shadow is from a top down point of view where everything is visible.

I use https://github.com/paulofmandown/rotLove to apply my own FOV:
fov.png
fov.png (65.9 KiB) Viewed 3794 times
Of course it's done cell by cell so if you want it to be done by pixel, you'll have to come up with another tweak.

User avatar
nucular
Prole
Posts: 22
Joined: Sun Mar 16, 2014 1:23 pm

Re: Löve "Light vs. Shadow" Engine v2

Post by nucular » Sun Jan 04, 2015 2:54 pm

drunken_thor wrote:I am pretty sure that is possible just play with ambient colors, just turn the ambient all the way to black.
Sorry that I didn't say so explicitly, but my problem is that the wall behind the other one is still lit by the "flashlight" of my player:
Image
This picture was taken with the ambient light being black.
giann wrote:What you want is to apply a field of vision from the point of view of your character/player. Light vs Shadow is from a top down point of view where everything is visible.

I use https://github.com/paulofmandown/rotLove to apply my own FOV:
fov.png
Of course it's done cell by cell so if you want it to be done by pixel, you'll have to come up with another tweak.
I was unsure if integrating yet another library would be a good idea (I'm already using Lightworld, HardonCollider and STI) but it seems like this is my only solution if I want the unlit tiles to be culled completly without taking up drawing time, so thanks for the help :)
Does it work with multiple light sources though?

giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

Re: Löve "Light vs. Shadow" Engine v2

Post by giann » Sun Jan 04, 2015 3:16 pm

It's independant from the light system.
You only have to feed a callback to the fov utility telling if light passes through each cell: http://paulofmandown.github.io/rotLove/ ... rsive.html

User avatar
~Tidal
Prole
Posts: 27
Joined: Sat Jan 10, 2015 8:19 pm

Re: Löve "Light vs. Shadow" Engine v2

Post by ~Tidal » Sat Jan 10, 2015 8:22 pm

Good evening everyone,
I'm using this library and seems everything is ok except for one thing...sometimes, the screen flickers, flashing in blue/violet. It works like this for the glows and ambient too. What am I doing wrong?

Relazy
Citizen
Posts: 51
Joined: Thu Jul 10, 2014 11:10 pm

Re: Löve "Light vs. Shadow" Engine v2

Post by Relazy » Sun Jan 25, 2015 2:13 am

Just out of curiosity but why do you draw normal maps/shadow objects like this:

Code: Select all

love.graphics.draw(self.normalMesh, self.x - self.nx, self.y - self.ny)
And not this:

Code: Select all

love.graphics.draw(self.normalMesh, self.x, self.y,self.rotation,1,1,self.nx,self.ny)
The only downside that I can see so far is that this will require the user to change their drawable offset ordinates to equal that of the shadow object. This allows for rotation and perhaps scaling if we assume that vectors are updated.

Note for rotation:
This doesn't quite work for rotation of the shadow(the one with self.ox and self.oy offsets) but it can be done by rotating the drawn polygon(by using love.graphics.rotate()). This is only a work-around as the vectors themselves need translating to update the tracking of the light source.

User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Löve "Light vs. Shadow" Engine v2

Post by drunken_thor » Mon Jan 26, 2015 3:09 pm

Relazy wrote:Just out of curiosity but why do you draw normal maps/shadow objects like this:

Code: Select all

love.graphics.draw(self.normalMesh, self.x - self.nx, self.y - self.ny)
And not this:

Code: Select all

love.graphics.draw(self.normalMesh, self.x, self.y,self.rotation,1,1,self.nx,self.ny)
The only downside that I can see so far is that this will require the user to change their drawable offset ordinates to equal that of the shadow object. This allows for rotation and perhaps scaling if we assume that vectors are updated.

Note for rotation:
This doesn't quite work for rotation of the shadow(the one with self.ox and self.oy offsets) but it can be done by rotating the drawn polygon(by using love.graphics.rotate()). This is only a work-around as the vectors themselves need translating to update the tracking of the light source.
That is a good question, I think that is just something that I inherited from the old codebase that I never re-thought. I have thought about including rotations in body settings in the future as well and I guess I would have to address that when I do. I will take a look at the code tonight.
Light_world.lua for all your lighting needs
Github
twitter

User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

Re: Löve "Light vs. Shadow" Engine v2

Post by drunken_thor » Thu Jan 29, 2015 9:55 pm

Just an update, I pretty much implemented scaling and rotating of light bodies, there is just some inaccuracy in them so the object get slightly smaller if you rotate them and scaling does not match up with how love.graphics.draw scales so it will be a different size depending on the scale.
Light_world.lua for all your lighting needs
Github
twitter

User avatar
soulaymenc
Prole
Posts: 34
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

Re: Löve "Light vs. Shadow" Engine v2

Post by soulaymenc » Thu Jan 29, 2015 10:26 pm

So i can rotate normal maps? :D
This world is so strange.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests