Large Terrain Textures (Photoshop Images As Terrain Textures), Packing Textures For Optimization

Hello! I’m close to releasing my first app and I wanted to get feedback from an experienced Unity dev. I have studied terrain textures and packing textures, but I was not able to find answers to these three questions. Thank you in advance!

First of all, should my terrain textures all be square?

Second question, should I try to pack textures (including terrain textures) the same way that sprites are packed (into a single graphic)? This question comes from my confusion after reading about info and docs about Texture Packer in regards to 2D sprites and then wondering if my 3D game needs the textures packed. I also had read some articles that say that my textures are going to be messed up by Unity and that I should try to pack them onto a single sheet? If this is so, does it apply to materials too? Or is this just older versions of Unity?

My third question is about having a super-large Photoshopped terrain texture. I made an awesome terrain graphic (an aerial view artistic creation) in Photoshop that looks amazing when applied to my terrain, but it is very large. At 2048 by 2048 it comes out to about 30 MB of png data just for the one texture graphic, which covers most of the terrain (and I really would like it to be 4096 x 4096 and 100 MB png). My rationale is that I’m actually saving CPU power and memory because it replaces my need for prefabs and game objects because a lot of elements are in the texture so it looks like a real place and is based on aerial photos and that sort of thing, like in the distance it looks like buildings, roads, and even some trees and corn fields are out there, in the hills of the terrain heightmap, because of this texture. So this question is if the 30 MB for one terrain texture is going to crash in mobile? Or do you think this was a good move, by making it all in Photoshop so that it’s really just one texture applied to the terrain? And should I upgrade it to be the 100 MB and 4096 x 4096 texture or will that crash mobile?

Thanks again.

They don’t have to be, but it’s highly advisable that textures you use on 3d objects for real time graphics are square for a number of reasons, as well as powers of 2 dimensions (2, 4, 8, 16, 32, etc). The main reason is for efficient mip mapping. If that’s not something you’re familiar with I suggest you look it up on your own as there are plenty of places that’ll explain it better than I.

Depends, but probably not for your case. If you’re going for a sprite-like look, or a minecraft-like voxel look, then using a texture atlas is generally a good idea. The problem with texture atlases and terrain is you usually want to have repeating textures, and this gets a lot harder when you use an atlas. The “correct” way to pack textures for terrain is a texture array, but this is something you have to handle manually in Unity as while the engine supports it, none of the included asset tools, terrain tools, or shaders do. Depending on the range of mobile platforms you plan on targeting, texture arrays may not even be an option for you though. There are a number of benefits to using texture atlases or texture arrays, like getting around the 16 sampler limit, but it’s not a hard requirement, and if you’re performance limited by mobile they may not be useful.

The file size of the source texture asset has little to do with the texture asset used by the game or sent to the GPU. Unity doesn’t care if you’re using a JPEG, PNG, TGA, or even PSD file, whatever the source format is is irrelevant as the textures need to be converted into compressed GPU texture formats, either DXTC/BC for consoles and desktop, or ETC, or ASTC, or PVRTC, or one of a few other options depending on what the hardware supports. Unity automatically handles most of this for you, but a 4096x4096 “ETC 4 bit” texture (the most commonly supported format) is about 11MB, regardless of the image content.

So, memory wise it’s probably not as bad as you think. Performance wise it might be a little slower to use a 4k texture, but you might just need to try.

That might make you think “Well, I’ll just use an 8k image then!” Mobile hardware often doesn’t support textures over 4096x4096.

2 Likes

Huge thanks to you bgolus. That helps me a lot.