If your character cast a shadow and your light is exactly on top of it, it will block out the light.
You need to position your light just at the edge of your character image.
When you change your light direction, you also need to move the light to the opposite edge of your character image in that direction.
Löve "Light vs. Shadow" Engine v2
Re: Löve "Light vs. Shadow" Engine v2
I don't think that's the problem. The lightWorld doesn't know about the player. I didn't see the need to register the player as a body. I tried giving the light an offset so it wouldn't be directly over the player as a test, and it still disappears when pointed to the lower left.giann wrote:If your character cast a shadow and your light is exactly on top of it, it will block out the light.
You need to position your light just at the edge of your character image.
When you change your light direction, you also need to move the light to the opposite edge of your character image in that direction.
- soulaymenc
- Prole
- Posts: 36
- Joined: Thu Jul 11, 2013 2:03 pm
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
Uhh, something wierd just happened, when I remove all light sources, when I move a sprite, it keeps redrawing and leave traces (just like when windows xp windows stops responding, and you move it with your mouse).
It only happens when I remove all lightsources. (It kinda happens with lightsources on, but the traces slowly fades away). Any idea how to fix it?
It only happens when I remove all lightsources. (It kinda happens with lightsources on, but the traces slowly fades away). Any idea how to fix it?
This world is so strange.
Re: Löve "Light vs. Shadow" Engine v2
Sounds like a canvas not being cleared.
- 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
The main problem is that there is no background to your world. The problem is that the shadows need to be drawn to something so there needs to be a background of some sort. That is why in most of the examples it draws a rectangle to the background. if you simply draw a background rectangle it will all go awaysoulaymenc wrote:Uhh, something wierd just happened, when I remove all light sources, when I move a sprite, it keeps redrawing and leave traces (just like when windows xp windows stops responding, and you move it with your mouse).
It only happens when I remove all lightsources. (It kinda happens with lightsources on, but the traces slowly fades away). Any idea how to fix it?
- 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
Please try the most recent version of the code, I just released a bunch of optimizations and one of them was to take out the complicated directional light math and use an arc stencil instead. That should clear up your issues.joedono wrote:I'm having a really weird issue. My top-down exploration game includes a character with a flashlight. When I start the flashlight with this code, it doesn't show up until I change the direction of the light. Then, if I try to swing the flashlight back to that direction, it vanishes again.
However, changing the angle of the flashlight to math.pi * 3/8 seems to solve the problem, but I'd like a 45degree light if I can manage it.Code: Select all
self.flashLight:setDirection(math.pi * 3/4); self.flashLight:setAngle(math.pi * 1/2);
I'll attach the project I have so far. Use WASD to move, the arrow keys to swing the flashlight around, and space to turn the flashlight on and off. If you try to shine the flashlight to the lower-left, it disappears when it gets there.
- 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
Please try the most recent version of the code. Through testing I realized that stenciling narrows the amount of area that shaders are applied, so by stenciling the area of each light I was able to get significant speed boosts. HOWEVER I have found that you still need to be wise how you use your lights and use of objects. Things turn out nice with a few lights and large shadow bodies (walls.)giann wrote:Do you think there's room for improvements in terms of performances ?
My FPS drops really quickly the more I add bodies and lights.
Edit: Another weird issue is that FPS seems to drops relative to the screen size regardless of the number of lights/bodies.
800x450: 50fps
1280x720: 20fps
with the same number of lights/bodies
- soulaymenc
- Prole
- Posts: 36
- Joined: Thu Jul 11, 2013 2:03 pm
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
Oh I actually noticed that, but on image objects backgrounds, never though of rectangles, this solves the issue, thank youdrunken_thor wrote:The main problem is that there is no background to your world. The problem is that the shadows need to be drawn to something so there needs to be a background of some sort. That is why in most of the examples it draws a rectangle to the background. if you simply draw a background rectangle it will all go away
![Smile :)](./images/smilies/ms-smile.png)
This world is so strange.
Re: Löve "Light vs. Shadow" Engine v2
Shadows are not blurred anymore.drunken_thor wrote:Please try the most recent version of the code. Through testing I realized that stenciling narrows the amount of area that shaders are applied, so by stenciling the area of each light I was able to get significant speed boosts. HOWEVER I have found that you still need to be wise how you use your lights and use of objects. Things turn out nice with a few lights and large shadow bodies (walls.)giann wrote:Do you think there's room for improvements in terms of performances ?
My FPS drops really quickly the more I add bodies and lights.
Edit: Another weird issue is that FPS seems to drops relative to the screen size regardless of the number of lights/bodies.
800x450: 50fps
1280x720: 20fps
with the same number of lights/bodies
Also bloom is not working even though drawBloom is called.
- 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
I have tested it all and the current code on master works for both shadow blur and bloom. can I see your code of how you are setting shadow blur and how you are setting bloom on the postshader?giann wrote: Shadows are not blurred anymore.
Also bloom is not working even though drawBloom is called.
Also any mention of optimizations? Have you noticed any performance gains?
Who is online
Users browsing this forum: No registered users and 8 guests