Page 5 of 12

Re: Löve "Light vs. Shadow" Engine [0.4.2]

Posted: Thu Apr 03, 2014 11:26 pm
by Wesleyyy
This is absolutely fantastic!

After a few hours of modifying code, I got it to work with a tower defense game I'm making. I have next to no experience with LÖVE but it was super easy to implement!
Image

Re: Löve "Light vs. Shadow" Engine [0.4.2]

Posted: Sun Apr 06, 2014 9:39 pm
by SNK1337
When trying the example.lua, I get this error:

Code: Select all

Error

light.lua:90: Value size of 2 does not match variable size of 3.


Traceback

[C]: in function 'send'
light.lua:90: in function 'update'
main.lua:49: in function 'draw'
[C]: in function 'xpcall'
(Here's a screenshot: http://puu.sh/7YJ6t.png)

I noticed that this error does not occur when I comment out

Code: Select all

lightMouse.setPosition(love.mouse.getX(), love.mouse.getY()) 
in love.update(). However, I obviously can't move the light then. It also happens if I try to set the position to static values such as 5, 5. The main.lua does work, by the way.


EDIT: Just found it a moment after posting this, while comparing main.lua and example.lua (because main.lua works). The function lightMouse.setPosition() needs 3 values instead of 2, because one is required for the z-value (height) of the light.

This should also be changed in the example code in the wiki, as the code there also only uses 2 values.


Also, any tips on how to implement this when using love.graphics.scale()?

Re: Löve "Light vs. Shadow" Engine [0.4.2]

Posted: Mon Apr 07, 2014 3:03 pm
by Luke100000
Great work! Maybe I can use this in my current game.
I found here an error: if light is exatly near a small object, there will be a strange shadow.
strange shadow.jpg
strange shadow.jpg (39.03 KiB) Viewed 6298 times
(bad resulution, but you know what I mean)

Re: Löve "Light vs. Shadow" Engine [0.4.2]

Posted: Mon Apr 07, 2014 7:46 pm
by davisdude
I think that could be the "z-level" of the light- imagine a sunrise. The light is "peaking" over the top of the box.
Or it could just be a bug. :)

Re: Löve "Light vs. Shadow" Engine [0.4.2]

Posted: Mon Apr 07, 2014 8:01 pm
by SNK1337
davisdude wrote:I think that could be the "z-level" of the light- imagine a sunrise. The light is "peaking" over the top of the box.
Or it could just be a bug. :)
It also happens when z is 0. I don't really know how the shader works yet, but I assume the shadow just isn't drawn far enough because it has a restriction on how big the surface of the shadow can be, or something similar to that.

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Posted: Tue Apr 08, 2014 5:55 pm
by PriorBlue
Luke100000 wrote:I found here an error: if light is exatly near a small object, there will be a strange shadow.
strange shadow.jpg
This problem is fixed now.

I also implemented the love2d browser for the examples.
Image

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Posted: Wed Apr 09, 2014 8:56 pm
by SNK1337
How exactly is translation used with this? If I use the lightWorld.setTranslation() before drawing everything, I get this: http://puu.sh/82uxo.jpg while it's supposed to look like this: http://puu.sh/82uyY.jpg

Do I also have to use love.graphics.translate() at some point? Or are there any other functions I need to get it working properly?

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Posted: Wed Apr 09, 2014 11:51 pm
by WetDesertRock
You will need to use lightWorld.setTranslation() if you are using love's translation. Some more information around here: viewtopic.php?f=5&t=77418&start=20#p164433

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Posted: Thu Apr 10, 2014 9:57 am
by SNK1337
WetDesertRock wrote:You will need to use lightWorld.setTranslation() if you are using love's translation. Some more information around here: viewtopic.php?f=5&t=77418&start=20#p164433


I still get very strange results with this. Do I have to use love's translation too? If so, when? And do I use the standard values there, or the ones your function returns?

I'm not using the Hump camera by the way, I'm using my own which is basically just love.graphics.translate() packed into nice functions and smooth movement.

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Posted: Thu Apr 10, 2014 4:11 pm
by WetDesertRock
If you set the light worlds translation by the same value you set loves translation, and it messes up, then its a bug I think. But you should set both values to the same.