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.
Blend SrcAlpha One
Blend DstAlpha OneMinusDstAlpha
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?
I've got no idea how to fix it on Android, but I bet it's settable via the Editor in 3.4 like with iOS. http://answers.unity3d.com/questions/44333/what-shader-blending-modes-dont-work-on-ios.html
Answer by toothycat
Jun 17, 2011 at 01:59 PM
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 UnityPlayerActivity.java (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)
C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidplayer\src\com\unity3d\player
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.
boolean trueColor8888 = false;
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)
c:/Program Files (x86)/Unity/Editor/Data/PlaybackEngines/androidplayer/bin/classes.jar
Pack the resulting binaries into a file called classes.jar in the Plugins/Android directory
for the curious ones, UnityPlayerActivity.java is located here on MAC: /Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidPlayer/src/com/unity3d/player
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
3 People are following this question.
Shader Doesn't Work On Android
Android : safely using sprites w/ alpha channel?
Lightmap AlphaTest Shader not Working on Android
GUIText Alpha transparency not working on Android Table?
alpha channels in android?