Hello everybody,
As you probably now I'm working on a light engine called Luven, I'm currently working on optimizing the lib and experimenting with canvases...
Everything is working insanely good BUT one thing I'm rolling my head on since 2 days and I just can't figure a way to solve it...
Have a look at this gif :
Look at the bottom left corner, you can see the limits of the canvas.
So I tried many many things like : making the canvas bigger and offset it, since I'm drawing it off the camera transform all my lights need an offset after that... I even try to draw an other canvas to create a kind of border with the ambient light color... I've lost count.
You can find the actual code in the experimental branch of the Luven project : https://github.com/chicogamedev/Luven/t ... perimental
Press space to make the camera shake.
I'm sure it's pretty simple, but since I'm in a learning process while working on Luven, I come seek the help of this lövely community!
Thanks all in advance.
Regards
Canvas + camera shake
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- ChicoGameDev
- Citizen
- Posts: 71
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Canvas + camera shake
Last edited by ChicoGameDev on Wed Feb 27, 2019 5:50 pm, edited 1 time in total.
Re: Canvas + camera shake
Are you still having the issue? I can't see the problem when I download the code and run it. it seems to work fine - there are no issues like in the gif.
- ChicoGameDev
- Citizen
- Posts: 71
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Canvas + camera shake
Hi,
Press space to shake the place
Sorry didn't precise that... My bad.
Thanks for trying at least.
Regards
Press space to shake the place
Sorry didn't precise that... My bad.
Thanks for trying at least.
Regards
Re: Canvas + camera shake
The problem is that you are drawing 2 layers :
- 1 with your image
- 1 with your lights and dark background
And then you try to move them at the same time.
ONe way to correct that would be to separate the lights from the transparent background and then draw:
-image first
-dark layer second
- lights third
And then, when you want to shake your camera, only move the image and lights, not the middle dark layer.
Also your code is a bit hard to follow, 600 loc is too much for what you do.
- 1 with your image
- 1 with your lights and dark background
And then you try to move them at the same time.
ONe way to correct that would be to separate the lights from the transparent background and then draw:
-image first
-dark layer second
- lights third
And then, when you want to shake your camera, only move the image and lights, not the middle dark layer.
Also your code is a bit hard to follow, 600 loc is too much for what you do.
- ChicoGameDev
- Citizen
- Posts: 71
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Canvas + camera shake
Hello,
Thanks for your participation.
Of course I'm drawing multiple layers, and since it's designed to be integrated in a game, there always will be multiple layers. No ?
And in your suggestion you want me to add a layer. But it seem a good idea, not sure to find the best way to do that but I'll try.
Thanks for your time.
Regards
Thanks for your participation.
Of course I'm drawing multiple layers, and since it's designed to be integrated in a game, there always will be multiple layers. No ?
And in your suggestion you want me to add a layer. But it seem a good idea, not sure to find the best way to do that but I'll try.
I can understand you have trouble going through that but I have no problem personally. I'm here to learn so if you could elaborate your point of view this could be a great opportunity for you to teach and for me to learn.
Thanks for your time.
Regards
Re: Canvas + camera shake
That wouldn't work. If you draw the layers in that order, the lights can't modulate the image color anymore, which is the whole point of the lightmap.
Edit: you could use a lightmap that is large enough to cover the screen area + the maximum shake area. Or you could use a scissor test to clip anything outside the bounds of the lightmap, which will result in a black border instead of a bright one when the camera shakes. Or you could zoom in by a small amount when the camera shakes.
Last edited by grump on Wed Feb 27, 2019 6:19 pm, edited 1 time in total.
- ChicoGameDev
- Citizen
- Posts: 71
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Canvas + camera shake
Hi grump,
Thanks for participating !
What you say is interesting, I think it's the problem I faced when I tried to add a border to the lightmap.
Regards
Thanks for participating !
What you say is interesting, I think it's the problem I faced when I tried to add a border to the lightmap.
Regards
Re: Canvas + camera shake
See my edit for possible solutions.
- ChicoGameDev
- Citizen
- Posts: 71
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Canvas + camera shake
I think I try that, do you mean :
Code: Select all
lightMap = love.graphics.newCanvas(screenWidth + Offset, screenHeight + Offset)
Code: Select all
love.graphics.draw(lightMap, -( Offset / 2), - (Offset / 2))
Regards
Re: Canvas + camera shake
You need to add the (half) offset to all light coordinates.
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 1 guest