Skip to content

Commit 45a7046

Browse files
Some corrections and formatting
1 parent f238814 commit 45a7046

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

articles/getting_to_know/howto/content_pipeline/HowTo_PackageTextures_On_Android.md

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@ description: Describes how to support multiple Texture Compression formats for A
44
requireMSLicense: false
55
---
66

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.
109

1110
## Texture Compression
1211

1312
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.
1816

1917
## How Android deals with textures
2018

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.
2722

2823
The `.aab` supports the following directory suffixes for texture compression:
2924

@@ -37,10 +32,12 @@ The `.aab` supports the following directory suffixes for texture compression:
3732
| ETC1 | #tcf_etc1 |
3833
| ETC2 | #tcf_etc2 |
3934

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)
4137
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:
4441

4542
| TextureProcessorOutputFormat | Suffix |
4643
| -------------- | ------ |
@@ -54,38 +51,37 @@ you use when processing an image. This following table shows you how to map that
5451

5552
## Adding Texture Compression Suffixes
5653

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.
5955

60-
In the Content Editor
56+
In the Content Editor:
6157

6258
1. Add a new folder for your desired Suffix. This is usually in the form of `Textures<suffix>`.
6359
![Add Folder](./images/HowTo_PackageTextures_Android_Add.png)
64-
2. Right click on the new folder and Add an Existing File.
60+
2. Right-click on the new folder and Add an Existing File.
6561
3. Select the file you want to use for this Suffix and Add it
6662
![Folder Structure](./images/HowTo_PackageTextures_Android_Folder.png)
67-
4. In the Properties of the new file change the TextureFormat to be the one which matches the desired Suffix.
63+
4. In the Properties of the new file change the TextureFormat to the one that matches the desired Suffix.
6864
![Change Properties](./images/HowTo_PackageTextures_AndroidATSC.png)
6965

7066
In the `.mgcb` file directly you can do the following
7167

72-
```bash
68+
```sh
7369
/processorParam:TextureFormat=PvrCompressed
7470
/build:Textures/LogoOnly_64px.png;Textures#tcf_pvrtc/LogoOnly_64px
7571
```
7672

7773
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.
7874
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`.
7975

80-
> !Important
76+
> [!Important]
8177
> Some texture formats have specific size requirements. For example PVRTC Compressed Textures MUST be a Power of 2 and Square (e.g 1024x1024).
8278
> 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.
8379
8480
## Supporting Multiple Texture Compression Types
8581

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.
8783

88-
```bash
84+
```sh
8985
#begin Textures/LogoOnly_64px.png for PvrCompressed
9086
/importer:TextureImporter
9187
/processor:TextureProcessor
@@ -99,21 +95,21 @@ To allow your game to work on as many devices as possible we need to support mul
9995
/build:Textures/LogoOnly_64px.png;Textures#tcf_s3tc/LogoOnly_64px
10096
```
10197

102-
In the Content Editor
98+
In the Content Editor:
10399

104100
1. Add a new folder for your desired Suffix. This is usually in the form of `Textures<suffix>`.
105101
![Add Folder](./images/HowTo_PackageTextures_Android_Add.png)
106102
2. Right click on the new folder and Add an Existing File.
107103
3. Select the file you want to use for this Suffix and Add it
108104
![Folder Structure](./images/HowTo_PackageTextures_Android_Folder.png)
109-
4. In the Properties of the new file change the TextureFormat to be the one which matches the desired Suffix.
105+
4. In the Properties of the new file change the TextureFormat to the one that matches the desired Suffix.
110106
![Change Properties](./images/HowTo_PackageTextures_AndroidATSC.png)
111107

112-
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.
113109

114110
## Sample `.mgcb`
115111

116-
```bash
112+
```sh
117113
#begin Textures/LogoOnly_64px.png
118114
/importer:TextureImporter
119115
/processor:TextureProcessor
@@ -129,10 +125,9 @@ As you can see, supporting multiple texture compression formats is now quite eas
129125

130126
## Using Android Asset Packs
131127

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.
134129

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`.
136131

137132
```xml
138133
<Target Name="_MoveContentIntoPacks" AfterTargets="IncludeContent">
@@ -142,9 +137,9 @@ Using them in your game can be quite straigh forward. It only requires a little
142137
</Target>
143138
```
144139

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>`.
146141

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.
148143
If you want to learn more about how to use these features please check out the following links:
149144

150145
- [Android Asset Packs](https://learn.microsoft.com/en-us/dotnet/maui/android/asset-packs?view=net-maui-9.0)
@@ -153,7 +148,7 @@ If you want to learn more about how to use these features please check out the f
153148

154149
## Sample `.mgcb` with Multiple Compression Formats
155150

156-
```bash
151+
```sh
157152
#----------------------------- Global Properties ----------------------------#
158153

159154
/outputDir:bin/$(Platform)

0 commit comments

Comments
 (0)