Canvas + camera shake

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
ChicoGameDev
Citizen
Posts: 71
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Canvas + camera shake

Post by ChicoGameDev »

Hello,

New day, new ideas and new participants :D Hi pgimeno !

Thank you for your explanation, I go try this right now !
pgimeno wrote: Thu Feb 28, 2019 12:20 am Oops, I see you've dropped the shader.
Yes sadly I had to, it asked too much to machines. Actually if you don't have a graphic card the shader was really slow. And since my knowledge is limited, I tried to optimize it but I gain maybe 40 - 50 fps but was not enough when more lights was added.

grump wrote: Wed Feb 27, 2019 8:54 pm That's a slightly more efficient solution, because the lightmap is smaller and you don't have to render lights that are outside the normally visible area.
I actually want the background to shake, everything that I draw I want it to shake if only the lights would shake this will have a strange effect I think. But I have a question on what you said :

Should a draw call outside a canvas be avoided or LÖVE is smart and manage it fast ? So just to be clear. I draw all my actives lights even if their far away from my canvas.


Regards
Lionel Leeser

Luven : https://github.com/halsten-dev/Luven

--

Always keep Game Dev as a passion.
User avatar
ChicoGameDev
Citizen
Posts: 71
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Canvas + camera shake

Post by ChicoGameDev »

pgimeno strikes again !

I was totally aware that something stupid was going on, as I said in my first post :
I'm sure it's pretty simple [...]
And it was and again you've learned me something !

Thanks a lot.


Have a wonderful day.



Regards
Lionel Leeser

Luven : https://github.com/halsten-dev/Luven

--

Always keep Game Dev as a passion.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Canvas + camera shake

Post by grump »

ChicoGameDev wrote: Thu Feb 28, 2019 4:22 am
grump wrote: Wed Feb 27, 2019 8:54 pm That's a slightly more efficient solution, because the lightmap is smaller and you don't have to render lights that are outside the normally visible area.
I actually want the background to shake, everything that I draw I want it to shake if only the lights would shake this will have a strange effect I think.
It would shake the background and the lights, just the lightmap would remain stationary. My solution is the same as pgimeno's, I wasn't able to convey it here. Actually reading the code instead of guessing goes a long way, lol.
Should a draw call outside a canvas be avoided or LÖVE is smart and manage it fast ? So just to be clear. I draw all my actives lights even if their far away from my canvas.
Draw only what is actually visible on the screen for best performance. LÖVE does not perform culling, so it will be done much later in the graphics pipeline, which is suboptimal. Note that looping over all lights in every frame and doing this check is not the best way to do this. Determine and update the set of visible lights only when necessary. You may want to read up on spatial hashing techniques for that.
User avatar
ChicoGameDev
Citizen
Posts: 71
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Canvas + camera shake

Post by ChicoGameDev »

Hi grump,

Haha yeah it would have helped but I did not simplify that by giving you the full source x). Thanks however for you help.

grump wrote: Thu Feb 28, 2019 6:07 am Draw only what is actually visible on the screen for best performance. LÖVE does not perform culling, so it will be done much later in the graphics pipeline, which is suboptimal. Note that looping over all lights in every frame and doing this check is not the best way to do this. Determine and update the set of visible lights only when necessary. You may want to read up on spatial hashing techniques for that.
Ok I will take a look, but actually I think I will just release a new version of Luven with the current state which is fare better than before.
But I wonder how I could determine when to draw a light or not since the scale can change and they can affect the canvas even if there far away from it. I should think a bit about that. Thanks for insights.



Regards
Lionel Leeser

Luven : https://github.com/halsten-dev/Luven

--

Always keep Game Dev as a passion.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Canvas + camera shake

Post by grump »

ChicoGameDev wrote: Thu Feb 28, 2019 6:36 am But I wonder how I could determine when to draw a light or not since the scale can change and they can affect the canvas even if there far away from it.
The easiest way to determine visibility is to check if a light's axis aligned bounding box intersects the axis aligned bounding box of the camera. Since you already seem to have a Transform object, you can probably use transformPoint to take care of scaling (and rotation) of the bounding boxes for you. Searching the forum for "aabb" will probably turn up some useful results. It's not hard to implement, but the benefit can be huge.
User avatar
ChicoGameDev
Citizen
Posts: 71
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Canvas + camera shake

Post by ChicoGameDev »

Hum,

That's interesting. I'm surprised you'll add bounding box on every lights and on camera to check this, but why not. Of course in that case it's much simpler to understand.

I think this could be the subject of another post tho :rofl:


Regards
Lionel Leeser

Luven : https://github.com/halsten-dev/Luven

--

Always keep Game Dev as a passion.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest