Shaders don't work properly on android
Hello,
I am working on a way to create high resolution screenshots of a tilemap on android
in order to achieve this i am manually drawing the image using GetPixel/SetPixel, and subsequently i am feeding the resulting image through a shader to add certain details
This works just fine on PC, however on some android devices (samsung galaxy tab 2 to be precise) i've run into several issues
The first was that the image would render entirely black( http://imgur.com/JaAFqM3 ), entirely pink( http://imgur.com/2lgnMkA ), or transparent with a rectangle (black, pink, or blue) in the bottom-left corner(http://imgur.com/Et1Lndb , http://imgur.com/YnYT80p , http://imgur.com/giTmdJM ).
after about 2 full days of research on what was causing this i figured out it had to do with the fact that the shader used uint type uniform variables, which are apparently not supported in GLES 2
after fixing this, the image would REMAIN black as it was greater than 2048*2048, fixing that by splitting the image in half (which is what the code is designed to do anyway)
now after fixing that and disabling all of the working parts of the shader, it seemed to be returning the original image as expected, giving me the following output:
Left: http://imgur.com/egbHE6v
Right: http://imgur.com/mtxmHNV
however when i re-enabled the working parts of the shader and reducing the quality instead of splitting, the output became as such:
low-res: http://imgur.com/zdMFC8o
mid-res: http://imgur.com/7VWINg2
mid-res is a screenshot of the app window btw...
there is no code that works to actually read pixels from the screen in this process, so the only way i can see this happening is by the following code not working correctly:
Graphics.Blit(megascreenshot[x, y], finalTex, mat);
RenderTexture.active = finalTex;
megascreenshot[x, y].ReadPixels(new Rect(0, 0, megascreenshot[x, y].width, megascreenshot[x, y].height), 0, 0);
megascreenshot[x, y].Apply();
RenderTexture.active = null;
and the second line being skipped (resulting in the screen being transfered to the texture instead of the renderTexture)
however there is NO output in the debug log
for reference, here's the expected output:
Left: http://imgur.com/2sidm4c
Right: http://imgur.com/BqsizC2
Low-res:http://imgur.com/AwyQd25
Mid-res:http://imgur.com/nHtTYCR
(this is the exact same shader code as is running on the tablet, although it actually looks like my changing uints to floats has broken rendering of the numbers)
full shader code: http://pastebin.com/TrzNjbmw
any help as to what might be going on would be much appreciated
Your answer
Follow this Question
Related Questions
How do you port old shaders to hlsl so they work with the new post-processing stack? 1 Answer
Correct way to modify a Texture2d with a shader? 0 Answers
Broken HDRP Lit and Unlit Shaders 0 Answers
Making a Kuwahara Filter Post process Shader (I'm using HDRP) 0 Answers
purple(pink) screen on android 0 Answers