Page 10 of 15

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

Posted: Sun Jan 04, 2015 3:17 am
by drunken_thor
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.

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

Posted: Sun Jan 04, 2015 3:20 am
by drunken_thor
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.

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

Posted: Sun Jan 04, 2015 8:00 am
by giann
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 4026 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.

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

Posted: Sun Jan 04, 2015 2:54 pm
by nucular
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?

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

Posted: Sun Jan 04, 2015 3:16 pm
by giann
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

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

Posted: Sat Jan 10, 2015 8:22 pm
by ~Tidal
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?

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

Posted: Sun Jan 25, 2015 2:13 am
by Relazy
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.

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

Posted: Mon Jan 26, 2015 3:09 pm
by drunken_thor
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.

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

Posted: Thu Jan 29, 2015 9:55 pm
by drunken_thor
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.

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

Posted: Thu Jan 29, 2015 10:26 pm
by soulaymenc
So i can rotate normal maps? :D