Destination alpha blending on Android device

I have a set of shaders that accumulates values in the framebuffer alpha channel over multiple passes (using ColorMask A / Blend SrcAlpha One), then uses Blend DstAlpha OneMinusDstAlpha to render semitransparent geometry.

This works just fine on the desktop, but the final render becomes fully opaque when I run on an actual Android phone.

If I turn off the final pass, comment out the ColorMasks and write alpha to the colour channels, I get the same, correct, greyscale output on desktop and mobile, so the intermediate pass shaders are compiling and working correctly.

Are there known issues with destination alpha blending on Android? Does the default framebuffer on Android have an alpha channel, and if not, how do I change that? Not having either destination alpha or the stencil buffer exposed to us would make a lot of effects very difficult to implement sensibly, can this really be the case? What am I missing?


After Jessy’s comment and reading the section on plugins, I can confirm that the default framebuffer on mobile Android devices does not in fact contain an alpha channel. This can be fixed (in a version of Unity that allows plugins) as follows:

  • create a Plugins/Android directory in Assets
  • take a copy of (by default in C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidplayer\src\com\unity3d\player) and AndroidManifest.xml (by default in C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidplayer)
  • Rename UnityPlayerActivity to something else (both the filename and the class name inside the file). Find the line boolean trueColor8888 = false;, change to true. Change the class name inside the manifest to the new class name.
  • Compile with javac, making sure to include the Unity playback classes (in c:/Program Files (x86)/Unity/Editor/Data/PlaybackEngines/androidplayer/bin/classes.jar by default) in the classpath, and also the Android SDK class library (e.g. -bootclasspath \android\android-sdk\platforms\android-11\android.jar)
  • Pack the resulting binaries into a file called classes.jar in the Plugins/Android directory