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
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
- EmptyAdditionalLightShadowmapTexture leaks from memory when URP quality level is changed using QualitySettings.SetQualityLevel
- Referenced ScriptableObject field does not get updated and cannot be set to "None" when there are no Objects of that type
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;