Shader not works well on Adreno 320

Hello:
I worked with a shader code And it works well with most mobile devices.


But it seems that when some android phones with adreno 320 GPU (Quacomm) run it , it performed like this:
[tested devices are Google Nexus 4, GALAXY Note 3(N9008)] Other deivces work well.

There are many black shadows and the screen is splitted into 2 parts by a slash
I don’t know how what the problem is . I wonder how to fix it ?

Shader "Test/Wave" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_TimeX ("Time", Range(0.0, 1.0)) = 1.0
_ScreenResolution ("_ScreenResolution", Vector) = (0.,0.,0.,0.)
}
SubShader
{
Pass
{
ZTest Always
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#pragma glsl
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _TimeX;
uniform float _Value;
uniform float _Value2;
uniform float _Value3;
uniform float4 _ScreenResolution;
struct appdata_t
{
float4 vertex   : POSITION;
float4 color    : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float2 texcoord  : TEXCOORD0;
float4 vertex   : SV_POSITION;
float4 color    : COLOR;
};
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color;
return OUT;
}


float4 frag (v2f i) : COLOR{

float2 rv=i.texcoord.xy+float2(_Value2,_Value3);
float3 c=float3(0,0,0);
float z=_Time*20;
float l=z;
float2 uv=rv;
float2 p=uv;
p-=.5;
z+=.07;
l=length(p);
uv+=p/l*(sin(z)+_Value)*abs(sin(l*9.-z*2.));
c.r=.01/length(abs(fmod(uv,1.)-.5));
uv=rv;
p=uv;
p-=.5;
z+=.07;
l=length(p);
uv+=p/l*(sin(z)+_Value)*abs(sin(l*9.-z*2.));
c.g=.01/length(abs(fmod(uv,1.)-.5));
uv=rv;
p=uv;
p-=.5;
z+=.07;
l=length(p);
uv+=p/l*(sin(z)+_Value)*abs(sin(l*9.-z*2.));
c.b=.01/length(abs(fmod(uv,1.)-.5));

c+=tex2D(_MainTex,i.texcoord.xy);
return float4(c/l,1.0);
}
ENDCG
}
}
}

Anyone who has idea about this problem?

Guessing numerical precision, I also vaguely recall people complaining about the low quality of the approximation of the sin() function on one of the low end Adreno GPUs I think it might’ve been the 320/300 series.

Seems like a fair bit of instrucions for some lens flares, you can’t just use some sprites for these, looks like the resolution could be like 8x4 on the sprite texture to get a similar effect…

Thanks, Cound any shader modification fix the accuracy of sin() function?:face_with_spiral_eyes:

You could replace sin in your shader with your own function, like this example code:

Thank you! I replaced the function, Then the black shadows reduced but still exist. I wonder if the dot function or any other operation also did some truncation of the float value:sweat_smile:

Anyone who knows how to debug this . Dont know why the color data was lost.:eyes: