Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Noise Algorithm fails in Samsung Galaxy SIII (GLES)

I am struggling to get the next simple algorithm working in the Samsung Galaxy SIII

float rand(vec2 co)
{
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

....
vec3 color = texture2D(u_texture, v_texcoord);
gl_FragColor.rgb = color + vec3(rand(gl_FragCoord.xy + time / 1000.0));
....

The code generates perfectly the expected noise in Samsung Galaxy S1 and Google Nexus S. But it fails completely in the new smartphone which uses ARM's Mali-400/MP4.

Anyone can spot anything wrong with this algorithm? Or maybe understand why could it fail?

like image 987
PerracoLabs Avatar asked Jul 02 '12 12:07

PerracoLabs


1 Answers

Your problem likely comes from taking the sin of a big number. The result of this depends on the exact implementation of sin, which is not available. Obviously the sin function used by the Mali chip has more predictable results with big numbers than the others.

It seems to me that you should use an actual noise function, not this thing. At least it will have predictable results across hardware.

like image 176
Nicol Bolas Avatar answered Nov 11 '22 20:11

Nicol Bolas