IPhone : GLSL atan on iPhone 6 Plus gives wrong result

on Tuesday, March 31, 2015

Consider the following fragment shader. When I run it on the Simulator or iPhone 5 (8.3) it shows the expected color (red). If I run it on an iPhone 6 Plus (8.2) it goes to the second if clause (green) that is clearly wrong as the correct result of the calculation should be around 1.22. If I supply the atan parameters directly as compile time constants then the calculation works.


I have tried both on the newest Xcode 6.2 and the newest 6.3 Beta.



void main()
{
highp float y = 0.57;
highp float x = 0.21;

highp float a = atan(y, x);
// works if changed to atan(0.57, 0.21);
// does not work if changed to atan(y / x);

if (a > 1.2 && a < 1.25)
{
// Should always come here
// Works on Simulator, iPhone 5
gl_FragColor = vec4(1, 0, 0, 1);
}
else if (a > 1.5 && a < 1.55)
{
// Comes here on iPhone 6 Plus
gl_FragColor = vec4(0, 1, 0, 1);
}

return;
}

0 comments:

Post a Comment