- Home /
OpenGL ES 2.0 support breaks simple shader
Building with OpenGL ES2.0 support makes shader unusable - scene is not rendered correctly on OpenGl ES3.0 device (Android).
.
Graphics APIs configuration:
- OpenGL ES3.0 + Vulkan - works flawlessly on OpenGL ES3.2 device, can't test on OpenGL ES2.0 device obviously 
- OpenGL ES2.0 + OpenGL ES3.0 + Vulkan - works flawlessly on OpenGL ES2.0, but does not on OpenGL ES3.2 anymore, until I disable shader 
 .
I'm using simple shader:
 Shader "Hidden/Pixelation"
 {
     Properties
     {
         _MainTex ("Texture", 2D) = "white" {}
     }
     SubShader
     {
         Pass
         {
             CGPROGRAM
             #pragma vertex vert_img
             #pragma fragment frag
             
             #include "UnityCG.cginc"
 
             sampler2D _MainTex;
             float2 BlockCount;
             float2 BlockSize;
 
             fixed4 frag (v2f_img i) : SV_Target
             {
                 float2 blockPos = floor(i.uv * BlockCount);
                 float2 blockCenter = blockPos * BlockSize + BlockSize * 0.5;
 
                 float4 tex = tex2D(_MainTex, blockCenter);
                 return tex;
             }
             ENDCG
         }
     }
 }
Similar threads and reports I've found:
- "I have the same problem, with Unity 2019.1.9f1. It is only broken with OpenGLES2, not with Vulkan. This might be relevant as well." https://forum.unity.com/threads/graphics-blit-not-working-for-android.534835/ 
 .
- "In my enviroment, Everything works fine with setting OpenGL ES version target to 3.0. Target 2.0 causes black screen on ES3.0 devices such as Nexus7(2013), Xperia Z1, etc. I think it is problem about ES2.0 emulation on ES3.0 devices." https://answers.unity.com/questions/519921/when-using-graphicsblit-in-android-getting-a-black.html 
 .
- "Expected result: Scene should be rendered correctly Actual result: Black screen and lots of errors" https://issuetracker.unity3d.com/issues/gles2-ios-postprocessing-invalid-pass-number-for-graphics-dot-blit-error-is-being-spammed-and-scene-is-not-rendered 
 .
Any thoughts on this?
I'm not a mobile expert by any means, but from memory OpenGL ES 2.0 supports very little in the way of modern rendering tech. Image effects in particular I've always seen as a taboo thing for mobile devices, so it may just be that Unity's internal blit functionality simply isn't supported on ES 2.0. Seeing as you are working with a pixelation effect, you could do it a different way for that platform and just render the screen at a lower resolution without point filtering on the final colour buffer.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                