GLSL shader crash only on samsung galax s3

Hi to everyone,

I have this fragment shader .

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

uniform float u_percent;

void main()
{
const float alpha = atan(v_texCoord.y - 0.5f, v_texCoord.x - 0.5f);
gl_FragColor = vec4(alpha,alpha,alpha, 1.f) * v_fragmentColor * texture2D(CC_Texture0, v_texCoord) ;
}

This shader works on Windows and ExperiaZ3 (Android 5.1), but crash on Samsung Galaxy S3 (Android 4.3).
I have assumption, it’s because atan function, but i don’t know how to fix it.

Hello, the problem comme from the const. Its à bad use of the word const. Rénové it and after this it supposée to work correctly

Regards

Hi, i try to remove const , but still doesn’t work. :frowning:
After short research i found this:
OpenGL ES 3.0 - This API specification is supported by Android 4.3 (API level 18) and higher.
And this
https://www.opengl.org/sdk/docs/man/html/atan.xhtml.

But still can’t found solution.

Regards.

atan is part of the opengl es 2 also. i have this is a sahder of mine for the android 2.2…

for many driver, define a const var by a function or an operation cause porblem. the const must be used only for define literal value.

if this is not that, i dont know what it can be due to.

have you tried the shader without atan. with a self defined value ? maybe the probleme not come from atan

regards

Actually this is full version of my shader. For cooldown.

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

uniform float u_percent;

void main()
{
float angle = atan(v_texCoord.y - 0.5f, v_texCoord.x - 0.5f) + 3.14159265359f ;
if(angle < 6.28318530718f * u_percent)
gl_FragColor = texture2D(CC_Texture0, v_texCoord);
else
{
float min = 0.1;
float max = 0.5;
float diff = max - min;

float coef = min  + (max - min) * u_percent;
  gl_FragColor = vec4(coef, coef, coef, 1.) * texture2D(CC_Texture0, v_texCoord);

}
}

I remove all consts but still doesn’t work for leveno A536 with Android 4.4.2 and Samsung S3

I found were is my problem. Maybe old phone support only halfs. And when we have something like float a = 0.1f; cant compile it. So solution is just remove f -> “float a = 0.1;”

yep the f is not part of the glsl syntax. on windows there is a transtype of glsl to directx by angle so the problem not appear systematically. but in fact this kind of syntax error might cause error in log not crash.

its weird

if you want to be sure that your syntax is good,
you can check your shader with a offline tool like this soft http://www.funparadigm.com/xshade/ by select the GLES mode

There are addons depending on the IDE you are using that have code highlighting and error detection for GLSL. The reason there is no f in glsl is because all values are assumed to be float. The gpu only deals with floats, it’s specifically optimized for float operations/calculations.