We have a problem where our shader works fine in the editor, but if we make an android build nothing happens. Our shader is a fragment shader that should do a cellular automata simulation. You color exactly one pixel by clicking on it and then the shader expands the pixel in a hexagon like shape. The fragment shaders output is written into a RenderTexture and then fed back in for further calculations. Sorry if this code makes you barf, this is the first time we are doing shaders and we have zero ideas why this does not do anything on android. We already played around with minimum API settings,always included shader and set the graphics api to opengles3. If you have any idea why this is not working, we would really appreciate your help. Updating the shader Code (CSharp): Graphics.Blit(texture, buffer, material); Graphics.Blit(buffer, texture); Updating the click Code (CSharp): foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved) { pos = Camera.main.ScreenToViewportPoint(touch.position); } } int x = Mathf.RoundToInt(pos.x * pixelSize.x); int y = Mathf.RoundToInt(pos.y * pixelSize.y); material.SetVector("_Click", new Vector4(x, y, 0f, 0f)); The shader Code (CSharp): Shader "Unlit/GameOfLifeRound" { Properties { _MainTex("Texture", 2D) = "white" {} _PixelsX("PixelsX", Float) = 256 _PixelsY("PixelsY", Float) = 256 _Click("Click", Vector) = (0,0,0,0) _SpreadValue("Spread", Float) = 0.1 _Color("Color", Vector) = (0,0,0,0) [MaterialToggle] _clearToWhite("ClearToWhite", Float) = 0 } SubShader { //Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True" } LOD 100 Pass { //ZWrite Off //Blend SrcAplha OneMinusSrcAplha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" #pragma target 3.0 struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _MainTex; float4 _MainTex_ST; float _PixelsX; float _PixelsY; float4 _Click; float _clearToWhite; float _SpreadValue; float4 _Color; v2f vert(appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); UNITY_TRANSFER_FOG(o,o.vertex); return o; } fixed4 frag(v2f i) : SV_TARGET { if (_clearToWhite == 1) { return float4(1,1,1,0); } float s_x = 1 / _PixelsX; float s_y = 1 / _PixelsY; float4 left = tex2D(_MainTex, i.uv + fixed2(-s_x, 0)); // Centre Left float4 top = tex2D(_MainTex, i.uv + fixed2(-0, -s_y)); // Top Centre float4 center = tex2D(_MainTex, i.uv + fixed2(0, 0)); // Centre Centre float4 bottom = tex2D(_MainTex, i.uv + fixed2(0, +s_y)); // Bottom Centre float4 right = tex2D(_MainTex, i.uv + fixed2(+s_x, 0)); // Centre Right float4 topleft = tex2D(_MainTex, i.uv + fixed2(-s_x, -s_y)); float4 topright = tex2D(_MainTex, i.uv + fixed2(+s_x, -s_y)); float4 bottomleft = tex2D(_MainTex, i.uv + fixed2(-s_x, +s_y)); float4 bottomright = tex2D(_MainTex, i.uv + fixed2(+s_x, +s_y)); if (center.a >= 1) { return center; } float spreadvalue = 0.05; if (center.a % spreadvalue == 0) { if (top.a > _SpreadValue) { return float4(top.r, top.g, top.b, center.a + spreadvalue); } if (right.a > _SpreadValue) { return float4(right.r, right.g, right.b, center.a + spreadvalue); } if (bottom.a > _SpreadValue) { return float4(bottom.r, bottom.g, bottom.b, center.a + spreadvalue); } if (left.a > _SpreadValue) { return float4(left.r, left.g, left.b, center.a + spreadvalue); } } else { _SpreadValue *= 1.5; if (topleft.a > _SpreadValue) { return float4(topleft.r, topleft.g, topleft.b, center.a + spreadvalue); } if (topright.a > _SpreadValue) { return float4(topright.r, topright.g, topright.b, center.a + spreadvalue); } if (bottomright.a > _SpreadValue) { return float4(bottomright.r, bottomright.g, bottomright.b, center.a + spreadvalue); } if (bottomleft.a > _SpreadValue) { return float4(bottomleft.r, bottomleft.g, bottomleft.b, center.a + spreadvalue); } } //Draw Pixels depending on _Click float x = round(i.uv.r * _PixelsX); float y = round(i.uv.g * _PixelsY); if (y == _Click.g && x == _Click.r) { return _Color; } return tex2D(_MainTex,i.uv); } ENDCG } } }
Could you elaborate this part? What do you mean "android build nothing happens" is it pink (Our internal shader for error) or black (In case of NaN or other issues) or is it not rendered? I really recommend check logcat for some hints from shader compilation by drivers, because it is really hard to tell simply from shader.