Best approach for complex background sprites

Dear Unity forum,

What is the best approach for building complex 2d backgrounds? I’m working on a game with 2D backgrounds that are fairly elaborate, and wanted to know if anyone has tried and succeeded with fairly heterogeneous 2d backgrounds in Unity.

Here are some basic aspects of my particular project. Let’s call them Requirements, but surely they are up for debate:

  • It’s a top-down game, where the player drifts upward continuously, passing a parallax background of 2-5 layers depending on the level.
  • Only the bottom-most layer is complex like this. Other layers hold the player, clouds, obstacles, etc.
  • I want to support fairly large levels: 2048 wide by 20000+ pixels tall. To think of it another way, each level when this was a vector-based Flash game was comprised of 10 to 20 1920x1080 tiles, which I am now rebuilding as sprites.
  • There are not many repeatable “tiles” in the game, but there are repeatable elements.
  • A level may have 50-100 different elements, or sprites for the background.
  • A single sprite might be used hundreds of times throughout a level or thorughout the game, such as a pine tree.

Here are the issues I’ve faced that led to making this cry for help on the forum:

  • Tiles become very big filewise, since I don’t repeat many tiles.
  • Tiles show seams between them when the camera moves.
  • Sprites don’t look very crisp.
  • Using the unity 2d sorting layer solution works, but it’s tedious, especially compared to changing layer depth of 2d elements in something like Photoshop, Illustrator, or Flash.
  • I’m not sure if the sprite-by-sprite approach (rebuilding each level from the ground up using game objects for every individual thing) is going to lead to performance problems, when there are, say, 2000 objects total, or 400 instances of the same pine tree in the level.

I thought I’d start with a call for a generally accepted best practice for high-detail, low redundancy backgrounds and go from there.

Any direction or help with this is vastly appreciated!

I’ve included an image of 1/3 of a background level so that you can see the size and nature of what I’m talking about.

Thanks,
Jon

You might want to look into SpriteTile, which doesn’t have any particular limitations on the size of each tile, and they can overlap and be individually rotated as you see fit. This allows a much less rigidly “tile” look, but still has the benefits of significantly reduced memory usage, since you only have to store the individual elements, rather than many huge unique textures. Since you’re only storing repeatable elements, they can be quite high-res and therefore crisp-looking. Performance is high, since only objects that are visible on-screen are created. The only thing I could see maybe still being an issue is your roads/trenches, which look unique.

–Eric

Thanks Eric! I will check this out for sure.

Are there best practices for exporting sprites / 2d assets into unity? I’m talking about all the little things that you might need to do in Photoshop, like dithering, nearest neighbor, etc. etc.

As someone who does not have a ton of experience with PS and coming from more of a vector-based background (Flash games), I’ve had a lot of trouble gracefully transitioning to bitmaps (Is that what you guys call them?).

I have a lot of issues with jittery sprites when the camera moves, a lack of resolution, etc. and it seems like I’m doing something incorrectly. Are there certain rules about camera scale or camera movement that can minimize artifacting, jittering pixel edges, etc?

Thanks!

Turn off pixel snap (you don’t need pixel perfect for this sort of thing), and use a high enough resolution for the sprite so it looks good. Turn off texture compression; 16-bit uncompressed would work well, and make sure bilinear filtering is used rather than point. You wouldn’t need any dithering as far as I can tell; just save as a standard PSD file.

–Eric

Thanks Eric! I didn’t even think that it might be possible to import PSD files into unity so I was bugging around in export options lol.

Yep, that’s my preferred format since I can keep layers and stuff, and just save files instead of exporting.

–Eric