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
- "Errors during XML parse" warnings are thrown when building project for the Android platform
- Shader transparency, discard, and clip are not working when using the Player
- Error is thrown when clicking on warning in the console
- Long IL2CPP build time when project has a .ufbx library wrapper
- Cursor doesn't change to the resizing when using the Rect Tool and the Sprite is too close to the bottom of the Scene View
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;