Hey guys, I am having problems finding any good documentation or well… anything really regarding compute shaders on android. Seems like its mostly a neglected area of the docs and… everywhere else?
I don’t know much about writing shaders, but I have been looking into using a compute shader on android to do heavy texture editing at runtime. The author of this asset pointed out to me how it can be used for that sort of thing (he does a similar thing with his asset as he explains here: LINK ) and I have been tinkering with it for a few days now. It is a little fractal toy, but demonstrates how to modify textures on a compute shader (on the GPU) instead of doing things like Texture2D.SetPixels() and Texture2D.Apply() which are frankly painfully slow (must upload texture from cpu side to gpu side… blah blah so on…).
Now this asset works just fine in the editor, when on android platform, as long as the settings are setup right in the player settings (no auto graphics api, no opengl 2 in the list, checkbox for 3.1 selected) and you disable “graphics emulation” under the edit menu. See HERE for the settings I used for android player settings.
The problem is it won’t work right when built for android (specifically my galaxy note 4) and produces an error saying “Kernel at index (0) is invalid” when it gets to the part (if you own the asset you can see the code) where it applies changes in the shader, to the “textureOut” which is a RWTexture2D. If I comment out the lines where it does changes to this texture (like: textureOut[id.xy] = colors[itn]; ) then the built version of the app does not spit out any errors, but of course it doesn’t show anything happening.
What gives? I don’t know much about shader code, but what I do know is that on unity 5.4 this wouldn’t work even that far, and would start having problems sooner, but after I updated to 5.5 it seems to work better but still gets hung up on this part.
Does android not support RWTexture2D for some reason? Has anybody else done something similar with a compute shader on android? Is it possible that it should work, but the glitches aren’t all ironed out yet? Anybody who happens to own (or is willing to spend 2 dollars on) that asset and wants to try it themselves?
NOTE: I would provide exact code for the shader and c# script I’m using but being that it is an asset I purchased I can’t exactly do that, but if you click the link to view the authors post in his thread, you will see that it basically explains what is happening in the asset package.