I'm at a point where I need to do some serious optimization.
My biggest issue is with rendering large amounts of objects. I would appreciate any tips or tricks. Like, do you use SpriteBatches? Perhaps a clever use of canvases? I know I'm being super vague, but any general tips would be awesome. Just for example if you want to have as many animated enemies on screen as you can.
Now for a specific question. I'm applying a shader to every object in play. Instead of doing that, if I take a screenshot of the stage, render that image, and apply the shader on it, would I have effectively gone from running my shader on thousands of objects to 1? Sounds a bit too good to be true. Any foreseeable drawbacks?
Optimization tips
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
Re: Optimization tips
Using a screenshot instead of a canvas doesn't seem a good idea to me, taking a screenshot and converting it into an image every frame is quite slow, and it uses lots and lots of RAM, forcing the garbage collector to run way more frequently than normal
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Optimization tips
As for the "shader optimization" (which really shouldn't affect you too much unless you've got tons and tons of overlap), this does in fact work this way. I would recommend using a canvas for it instead, though, as Nixola mentioned.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Optimization tips
Though be careful as a bunch of our users (Not me) have computers that can't use Canvases because their video cards are old or they have outdated drivers or random other reasons. So its best to include a Canvas-less mode for them and detect whether they support them by using the isSupported() function.
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
Re: Optimization tips
Thanks for the replies Nixola and bartbes!
My first priority is actually getting the game to work correctly on my machines, then I can start to worry about making it work for everyone, even if I have to rewrite some things.
I am planning on doing that, but I'm having doubts on whether it's worth it. There's a lot of stuff that would be dependent on shaders and/or canvases, and without it the game would either look horrible or have really bad performance. We could try to fake some things and cut some corners just so people without the hardware can play.Jasoco wrote:Though be careful as a bunch of our users (Not me) have computers that can't use Canvases because their video cards are old or they have outdated drivers or random other reasons. So its best to include a Canvas-less mode for them and detect whether they support them by using the isSupported() function.
My first priority is actually getting the game to work correctly on my machines, then I can start to worry about making it work for everyone, even if I have to rewrite some things.
-
- Prole
- Posts: 22
- Joined: Sat Dec 22, 2012 11:59 pm
Re: Optimization tips
Omar I had a look at some concerned joe videos and I love his face getting more and more anxious when he's standing still. Very expressive sprite work!
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Optimization tips
Don't let it deter you from using shaders and canvases; almost all games use things like that nowadays. I'd recommend giving people the option to not run it with those features, but only if it's not too much of a hassle.OmarShehata wrote:I am planning on doing that, but I'm having doubts on whether it's worth it. There's a lot of stuff that would be dependent on shaders and/or canvases, and without it the game would either look horrible or have really bad performance. We could try to fake some things and cut some corners just so people without the hardware can play.
My first priority is actually getting the game to work correctly on my machines, then I can start to worry about making it work for everyone, even if I have to rewrite some things.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Optimization tips
Yeah. A lot of games will let you turn settings off to get better performance or for compatibility reasons. It's always nice to have really high settings and something that can still be enjoyed by others.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Optimization tips
That's what I'm doing with my arena shooter, although the game looks terrible without bloom on.
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
Re: Optimization tips
Ok so, as far limitations go, all objects rendered with one SpriteBatch need to share the same:
-Alpha & color
-Depth (as in, something outside the sprite batch can't be between two things inside a sprite batch)
-Shader effect
So I just need to be smart about which objects I group into an atlas.
There doesn't seem to be a way to remove individual items from a Batch, would I have to clear everything and add them all back if I wanted to remove 1?
So so far it seems Sprite Batches are really good for things that won't move or get changed often, that don't need to be updated every frame.
Also, is there any way I can use canvases to speed things up even more? I keep thinking I could draw the backgrounds and static tiles onto a canvas, so that I only draw it once, and only redraw that canvas when I change anything, but then I could do the same thing with a sprite batch and update the sprite batch when I need to.
-Alpha & color
-Depth (as in, something outside the sprite batch can't be between two things inside a sprite batch)
-Shader effect
So I just need to be smart about which objects I group into an atlas.
There doesn't seem to be a way to remove individual items from a Batch, would I have to clear everything and add them all back if I wanted to remove 1?
So so far it seems Sprite Batches are really good for things that won't move or get changed often, that don't need to be updated every frame.
Also, is there any way I can use canvases to speed things up even more? I keep thinking I could draw the backgrounds and static tiles onto a canvas, so that I only draw it once, and only redraw that canvas when I change anything, but then I could do the same thing with a sprite batch and update the sprite batch when I need to.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests