x


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?

Thanks

more ▼

asked Jun 17, 2011 at 09:43 AM

toothycat gravatar image

toothycat
121 20 16 30

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

Jun 17, 2011 at 01:12 PM Jessy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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) 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

more ▼

answered Jun 17, 2011 at 01:59 PM

toothycat gravatar image

toothycat
121 20 16 30

for the curious ones, UnityPlayerActivity.java is located here on MAC: /Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidPlayer/src/com/unity3d/player

Mar 11, 2013 at 04:10 PM madflyskills
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5106
x530
x13

asked: Jun 17, 2011 at 09:43 AM

Seen: 4850 times

Last Updated: Mar 11, 2013 at 04:10 PM