- Home /
Will my huge sprites for a 2d game create performance issues?
I'm new to Unity, and have been confused about this issue for a while. Some people say that for 2D games you don't need to worry about performance (I'm making the game for PC, not mobile) while others report bad performance with larger sized sprites
I have a long scene with some large background sprites, measuring about 14552x3308 (weird resolution I know, would that also cause issues?) All methods of scaling it down and resizing in Unity lead to jagged edges (these are basically hills so I need them to be significantly bigger than the player character) I always keep the image size in the inspector similar to the resolution of the actual file, and set the filter mode to Point, so the jagged edges are not due to that, but only because of me scaling up a smaller file size to fit the scene.
If I use the original sprites of 14552x3308, it's perfectly smooth (image size set to 8192 in inspector) but each file takes about 120mb in the profiler. All combined, my assets are showing a usage of 1.25 GB for this scene. How bad is this? Should I be trying to keep it under 1GB?
I don't really know what the best practices are in this situation, so I don't know what to aim for. I'd ideally like to keep the sprites at this large size so that I don't have to redraw anything.
Those dimensions won't make it anyway. I think the biggest you can get is 8096. $$anonymous$$obile is likely to be 4096 max. So even though you provide a huge texture, it will be scaled down. Using power of two size allows for compression.
Answer by TheSOULDev · Aug 28, 2017 at 06:08 PM
Are you using the whole sprite at once? As in, do you need the whole sprite to be drawn because it is seen in the whole scene? If the answer is yes, well, then you can't really bypass it easily. But if you have a large sprite because you don't want to load it as you change position, then that is a bad thing for memory, I mean 1.25GB for a scene with sprites? Hello? In my opinion you should never surpass 100MB for a scene in a 2D game. Even the 100MB is a lot and you should try to keep it at 50-75 MB range.
In that case it would be better to split the sprites into blocks you can load on request, and despite it having delays due to memory access, it is still better than unnecessarily taxing the machine. Also, if that is the case, then your large sprite approach is VERY bad. It's so bad it will never work on non-flagship mobile devices, and mobile devices are pretty powerful nowadays. Just look at how well Mario Run is optimized - it consumes single digit MBs of RAM. Anyways, that's why people introduced levels in the first place - it was way better dividing the game into parts the machine could handle instead of making everything be a heap of content.
However, don't divide it into too many parts. Too many objects tax the machines as well, so you'll have to find a way to balance quantity and quality.
If you still need the whole sprites to be loaded at once, I would advise you to think of a way it doesn't need to all be loaded at once - there are no commerical screens that can show 48 megapixel resolutions anyways.
Hi, thanks for the response. Are you talking from a perspective of mobile devices only? What about PC? As I mentioned in the OP, this game is for PCs only. I'm not really sure how I could go about bringing the sizes down for a scene like this, but I'll have to think about my approach if this is a serious issue. For now, I've attached a screenshot of the profiler. The orange background is the large file size. There are 4 other backgrounds/ hills like it, and they're affected by parallax. I don't really know if I could load them in separately. Would breaking them into chunks help? (But the memory usage would just add up separately anyway right?)
Wait, you're using that large of a texture for a background? First thing you should do is introduce LOD for it then. Create background images for all your resolutions. The FHD image shouldn't be higher than 1080 pixels, because it can't be shown. That way someone who has an 8$$anonymous$$ screen won't miss out on it. Having such a large texture for a background is pure madness, especially in a world where effects such as upscaling exists. Also, I'm not talking about mobile performance purely. Have you ever seen a 2D game which eats 1.2 GB of RA$$anonymous$$ in a scene? Because I haven't, exactly.
It is just a background, crop it smaller and use a different camera to render only the background. This way you don't need a large texture and it still looks fine.
Answer by armaan8014 · Aug 29, 2017 at 08:03 AM
Somehow cropping the files closely to remove extra space has brought down the memory impact from 120 mb to 3 mb, which is insane considering that it was only the blank space causing all that memory usage. I have only done this for one sprite yet, and have seen no loss in quality.
I also tried splitting it into 4 parts, and it actually looks even better than my original huge files. But this takes a total of 12mb memory compared to the 3mb of the non-split file. The right solution is somewhere there between these new options. I'll be back here to report when I figure that out
Your answer
Follow this Question
Related Questions
Layer Sprites Based on Y axis 1 Answer
Get the sprite name attached to Source Image of UI Image 3 Answers
How come setting sprite tint/alpha does not increase draw calls? 0 Answers
2D Sprites scaling to multiple screen sizes - Colliders, 2D Sprite image sizes, SpawnPoints 0 Answers
Change a prefab's sprite in all scenes? 2 Answers