Search Issue Tracker
By Design
Votes
0
Found in
2017.4.0f1
2018.4.0f1
2019.1.0a1
2019.2.0a1
2019.3.0a1
Issue ID
1172766
Regression
No
Unable to modify alpha channel of BC7 texture using OnPostProcessing when the texture's alpha channel is not modified/default
How to reproduce:
1. Open attached project "BC7AlphaOverride.zip"
2. In Project window, select "Test_L1x"
3. In Inspector window, enable Alpha view mode and observe the preview
Expected result: the alpha channel looks identical to "Test_mask" texture
Actual result: the alpha channel is completely white
Reproducible with: 2017.4.31f1, 2018.4.5f1, 2019.1.13f1, 2019.2.0f1, 2019.3.0a11
Additional notes:
Modifying the "Test_L1x" texture's alpha channel provides the expected results
Solution:
The issue is that the compressor ignores the alpha channel that was written during PostprocessTexture by the user script because the source asset did not have an alpha. The texture format is defined by the source image and the texture importer settings and cannot be modified from PostprocessTexture.
An easy workaround is to set the alpha source to "From Gray Scale" on the texture importer.
This generates an alpha equal to the grayscale representation of the image. This way, the source does have an alpha channel (which will be overwritten) and the changes in OnPostprocessTexture to this alpha channel will be included by the compressor in the encoded texture.
For example, you can configure the importer using AssetPostprocessor.OnPreprocessTexture:
textureImporter.alphaSource = TextureImporterAlphaSource.FromGrayScale;
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Shader warnings are thrown after building High Definition 3D template
- "EndLayoutGroup: BeginLayoutGroup must be called first" error is thrown when changing Shader Precision Model from the Build Profiles window
- White artifacts/outlines are visible in the Garden Scene when viewing at meshes from a distance
- Shader warnings "Sprite-Unlit-Default" are thrown after building 2D Platrformer Microgame Template
- [Android] HLSL shader becomes corrupted when running on an Android device
Resolution Note (2019.3.X):
The issue is that the compressor ignores the alpha channel that was written during PostprocessTexture by the user script because the source asset did not have an alpha. The texture format is defined by the source image and the texture importer settings and cannot be modified from PostprocessTexture.
An easy workaround is to set the alpha source to "From Gray Scale" on the texture importer.
This generates an alpha equal to the grayscale representation of the image. This way, the source does have an alpha channel (which will be overwritten) and the changes in OnPostprocessTexture to this alpha channel will be included by the compressor in the encoded texture.
For example, you can configure the importer using AssetPostprocessor.OnPreprocessTexture:
textureImporter.alphaSource = TextureImporterAlphaSource.FromGrayScale;