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
- Mouse input is registered incorrectly in Custom RP when downscaling Render Target and rendering Overlay UI before final upscale
- Time.deltaTime is locked to the display's refresh rate when the built Player is moved to a Secondary Display and Windowed Mode is used
- Crash on RaiseException when importing a specific asset
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
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;