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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
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;