Skip to content

Commit a01383b

Browse files
committed
add an additional sample
1 parent 0e364c4 commit a01383b

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

articles/getting_to_know/howto/content_pipeline/HowTo_PackageTextures_On_Android.md

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ requireMSLicense: false
55
---
66

77
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 guarentee what graphics card a user will be using. For this reason
9-
Android needs to have some special attention when shipping your game.
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.
1010

1111
## Texture Compression
1212

1313
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.
1414
The graphics cards on mobile phones do not have the same kind of capabilities as those on the PC or Consoles.
1515
They regularly have less memory and less power. So you need to make use of what you have in a more efficient way.
1616
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.
17+
textures on the graphics card than you could if you just used raw `RGBA` textures.
1818

1919
## How Android deals with textures
2020

21-
Fortunately the Android engineers recognised that supporting all of these texture compresison formats
22-
was not an easy task. So with the introduction of the `.aab` file format they added the ability to
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
2323
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.
24+
`.apk`. The final `.apk` will be built from the `.aab` when the game is delivered to the end user device.
2525
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.
26+
`.so` files for other cpu types, and yes, texture formats.
2727

28-
The `.aab` supports the following directory suffixes for texture compresison
28+
The `.aab` supports the following directory suffixes for texture compression
2929

3030
| Texture Format | Suffix |
3131
| -------------- | ------ |
@@ -37,9 +37,9 @@ The `.aab` supports the following directory suffixes for texture compresison
3737
| ETC1 | #tcf_etc1 |
3838
| ETC2 | #tcf_etc2 |
3939

40-
see https://developer.android.com/guide/playcore/asset-delivery/texture-compression
40+
see [https://developer.android.com/guide/playcore/asset-delivery/texture-compression](https://developer.android.com/guide/playcore/asset-delivery/texture-compression)
4141

42-
MonoGame has its own [TextureProcessorOutputFormat](https://docs.monogame.net/api/Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.html) enumeration which describes the type of Texture Compression
42+
MonoGame has its own [TextureProcessorOutputFormat](https://docs.monogame.net/api/Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.html) enumeration which describes the type of Texture Compression
4343
you use when processing an image. This following table shows you how to map that to the Suffix
4444

4545
| TextureProcessorOutputFormat | Suffix |
@@ -54,10 +54,10 @@ you use when processing an image. This following table shows you how to map that
5454

5555
## Adding Texture Compression Suffixes
5656

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

60-
In the Content Editor
60+
In the Content Editor
6161

6262
1. Add a new folder for your desired Suffix. This is usually in the form of `Textures<suffix>`.
6363
2. Right click on the new folder and Add an Existing File.
@@ -71,14 +71,39 @@ In the `.mgcb` file directly you can do the following
7171
/build:Textures/LogoOnly_64px.png;Textures#tcf_pvrtc/LogoOnly_64px
7272
```
7373

74-
As documented the [/build](https://docs.monogame.net/articles/getting_started/tools/mgcb.html#build-content-file) command takes
75-
an optional `<destination_filepath>` after the `<content_filepath>`. We can use this to provide the target folder for our output.
74+
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.
7675
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`.
7776

7877
> !Important
7978
> Some texture formats have specific size requirements. For example PVRTC Compressed Textures MUST be a Power of 2 and Square (e.g 1024x1024).
8079
> 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.
8180
81+
## Supporting Multiple Texture Compression Types
82+
83+
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.
84+
85+
```bash
86+
#begin Textures/LogoOnly_64px.png for PvrCompressed
87+
/importer:TextureImporter
88+
/processor:TextureProcessor
89+
/processorParam:TextureFormat=PvrCompressed
90+
/build:Textures/LogoOnly_64px.png;Textures#tcf_pvrtc/LogoOnly_64px
91+
92+
#begin Textures/LogoOnly_64px.png for DxtCompressed
93+
/importer:TextureImporter
94+
/processor:TextureProcessor
95+
/processorParam:TextureFormat=DxtCompressed
96+
/build:Textures/LogoOnly_64px.png;Textures#tcf_s3tc/LogoOnly_64px
97+
```
98+
99+
In the Content Editor
100+
101+
1. Add a new folder for your new desired Suffix. This is usually in the form of `Textures<suffix>`.
102+
2. Right click on the new folder and Add an Existing File.
103+
3. Select the file you want to use for this Suffix and Add it
104+
4. In the Properties of the new file change the TextureFormat to be the one which matches the desired Suffix.
105+
106+
As you can see, supporting multiple texture compression formats is now quite easy.
82107

83108
## Sample `.mgcb`
84109

0 commit comments

Comments
 (0)