You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/getting_to_know/howto/content_pipeline/HowTo_PackageTextures_On_Android.md
+30-35Lines changed: 30 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,26 +4,21 @@ description: Describes how to support multiple Texture Compression formats for A
4
4
requireMSLicense: false
5
5
---
6
6
7
-
The Android ecosystem is unique in that the hardware it runs on can be from many different manufactures.
8
-
Unlike iOS or PC, you cannot always guarantee what graphics card a user will be using. For this reason,
9
-
Android needs to have some special attention when shipping your game.
7
+
The Android ecosystem is unique in that the hardware it runs on can be from many different manufacturers.
8
+
Unlike iOS or PC, you cannot always guarantee what graphics card a user will be using. For this reason, Android needs to have some special attention when shipping your game.
10
9
11
10
## Texture Compression
12
11
13
12
As stated in "[Why use the Content Pipeline](https://docs.monogame.net/articles/getting_started/content_pipeline/why_content_pipeline.html)", you need to be aware of the performance limitations on mobile devices.
14
-
The graphics cards on mobile phones do not have the same kind of capabilities as those on the PC or Consoles.
15
-
They usually have less memory and less power. So you need to make use of what you have in a more efficient way.
16
-
One of these ways is to use Texture Compression. As stated in "[Why use the Content Pipeline](https://docs.monogame.net/articles/getting_started/content_pipeline/why_content_pipeline.html)", this allows you to fit more
17
-
textures on the graphics card than you could if you just used raw `RGBA` textures.
13
+
The graphics cards on mobile phones do not have the same kind of capabilities as those on the PC or Consoles. They usually have less memory and less power. So you need to make use of what you have in a more efficient way.
14
+
15
+
One of these ways is to use Texture Compression. As stated in "[Why use the Content Pipeline](https://docs.monogame.net/articles/getting_started/content_pipeline/why_content_pipeline.html)", this allows you to fit more textures on the graphics card than you could if you just used raw `RGBA` textures.
18
16
19
17
## How Android deals with textures
20
18
21
-
Fortunately the Android engineers recognized that supporting all of these texture compression formats
22
-
was not an easy task. So, with the introduction of the `.aab` file format, they added the ability to
23
-
add multiple texture format files to the package. The way the `.aab` works is that it is not the final
24
-
`.apk`. The final `.apk` will be built from the `.aab` when the game is delivered to the end user device.
25
-
As a result, not all of the files in the `.aab` will make it to the device. It will filter out things like
26
-
`.so` files for other cpu types, and yes, texture formats.
19
+
Fortunately, the Android engineers recognized that supporting all of these texture compression formats was not an easy task. So, with the introduction of the `.aab` file format, they added the ability to add multiple texture format files to the package. The way the `.aab` works is that it is not the final `.apk`. The final `.apk` will be built from the `.aab` when the game is delivered to the en- user device.
20
+
21
+
As a result, not all of the files in the `.aab` will make it to the device. It will filter out things like `.so` files for other cpu types, and yes, texture formats.
27
22
28
23
The `.aab` supports the following directory suffixes for texture compression:
29
24
@@ -37,10 +32,12 @@ The `.aab` supports the following directory suffixes for texture compression:
37
32
| ETC1 | #tcf_etc1 |
38
33
| ETC2 | #tcf_etc2 |
39
34
40
-
see [https://developer.android.com/guide/playcore/asset-delivery/texture-compression](https://developer.android.com/guide/playcore/asset-delivery/texture-compression)
35
+
> [!NOTE]
36
+
> see [https://developer.android.com/guide/playcore/asset-delivery/texture-compression](https://developer.android.com/guide/playcore/asset-delivery/texture-compression)
41
37
42
-
MonoGame has its own [TextureProcessorOutputFormat](https://docs.monogame.net/api/Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.html) enumeration. It describes the type of Texture Compression
43
-
you use when processing an image. This following table shows you how to map that to the Suffix:
38
+
MonoGame has its own [TextureProcessorOutputFormat](https://docs.monogame.net/api/Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.html) enumeration. It describes the type of Texture Compression you use when processing an image.
39
+
40
+
The following table shows you how to map that to the Suffix:
44
41
45
42
| TextureProcessorOutputFormat | Suffix |
46
43
| -------------- | ------ |
@@ -54,38 +51,37 @@ you use when processing an image. This following table shows you how to map that
54
51
55
52
## Adding Texture Compression Suffixes
56
53
57
-
With the latest MonoGame we added support for being able to have one texture with multiple outputs.
58
-
Previously it would only build the last item, but this has been fixed.
54
+
With the latest MonoGame we added support for being able to have one texture with multiple outputs. Previously it would only build the last item, but this has been fixed.
59
55
60
-
In the Content Editor
56
+
In the Content Editor:
61
57
62
58
1. Add a new folder for your desired Suffix. This is usually in the form of `Textures<suffix>`.
As documented the [/build](https://docs.monogame.net/articles/getting_started/tools/mgcb.html#build-content-file) command takes an optional `<destination_filepath>` after the `<content_filepath>`. We can use this to provide the target folder for our output.
78
74
So in the example above, the `LogoOnly_64px.png` file will be compressed using `PvrCompressed` and then the output will end up in `Textures#tcf_pvrtc`.
79
75
80
-
> !Important
76
+
> [!Important]
81
77
> Some texture formats have specific size requirements. For example PVRTC Compressed Textures MUST be a Power of 2 and Square (e.g 1024x1024).
82
78
> Many others need to be Power of 2. It is recommended that you make all your textures Power of 2 just to make life easier.
83
79
84
80
## Supporting Multiple Texture Compression Types
85
81
86
-
To allow your game to work on as many devices as possible we need to support multiple compression formats. Now that we know how to specify a specific texture compression format for a texture, how do we go about supporting multiple formats? It is really quite simple. We can duplicate the entry for each texture an specify a different `/processorParam:TextureFormat` and output path. For example the following code is how we would build both `pcrtc` and `dxt` formats.
82
+
To allow your game to work on as many devices as possible we need to support multiple compression formats. Now that we know how to specify a specific texture compression format for a texture, how do we go about supporting multiple formats? It is really quite simple. We can duplicate the entry for each texture and specify a different `/processorParam:TextureFormat` and output path. For example, the following code is how we would build both `pcrtc` and `dxt` formats.
87
83
88
-
```bash
84
+
```sh
89
85
#begin Textures/LogoOnly_64px.png for PvrCompressed
90
86
/importer:TextureImporter
91
87
/processor:TextureProcessor
@@ -99,21 +95,21 @@ To allow your game to work on as many devices as possible we need to support mul
As you can see, supporting multiple texture compression formats is now quite easy.
108
+
As you can see, supporting multiple texture compression formats is quite easy.
113
109
114
110
## Sample `.mgcb`
115
111
116
-
```bash
112
+
```sh
117
113
#begin Textures/LogoOnly_64px.png
118
114
/importer:TextureImporter
119
115
/processor:TextureProcessor
@@ -129,10 +125,9 @@ As you can see, supporting multiple texture compression formats is now quite eas
129
125
130
126
## Using Android Asset Packs
131
127
132
-
The Google Play Store has some fairly strick limited on the package sizes for Android apps. However they do have way to extend thise limits for large games and apps, these are known as `Asset Packs`. Simply put, an `Asset Pack` is a way to organise your game content/assets into seperate pieces which can be downloaded shortly after installation or dynamically at runtime.
133
-
For most games using the `Install Time` packs are the best option.
128
+
The Google Play Store has some fairly strict limitations on package sizes for Android apps. However there are ways to extend these limits for large games and apps, which are known as `Asset Packs`. Simply put, an `Asset Pack` is a way to organize your game content/assets into separate pieces which can be downloaded shortly after installation or dynamically at runtime. For most games using the `Install Time` packs are the best option.
134
129
135
-
Using them in your game can be quite straigh forward. It only requires a little bit of `MSBuild` markup in your Android platform `.csproj`.
130
+
Using them in your game can be quite straight forward. It only requires a little bit of `MSBuild` markup in your Android platform `.csproj`.
@@ -142,9 +137,9 @@ Using them in your game can be quite straigh forward. It only requires a little
142
137
</Target>
143
138
```
144
139
145
-
This adds an `MSBuild` target to your project which will process all the items in the `Content/Music` folder and subfolders. It will place them in an `Asset Pack` called `MyGameAssets`. You can change the name of this pack as you wish. By default this will be an `InstallTime` pack. So it will be installed at the same time as your game is. There is not need to do anything else, the assets will be placed in the usual location and opened via `Content.Load<T>`.
140
+
This adds an `MSBuild` target to your project which will process all the items in the `Content/Music` folder and subfolders. It will place them in an `Asset Pack` called `MyGameAssets`. You can change the name of this pack as you wish. By default, this will be an `InstallTime` pack. So it will be installed at the same time as your game is. There is no need to do anything else, the assets will be placed in the usual location and opened via `Content.Load<T>`.
146
141
147
-
If use dymanic delivery and install packs at runtime you will need to open the content from a different location. This is out of scope for this document.
142
+
If you are using dynamic delivery and install packs at runtime, you will need to open the content from a different location. This is out of scope for this document.
148
143
If you want to learn more about how to use these features please check out the following links:
0 commit comments