This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

random number with mali 400 mp

Note: This was originally posted on 22nd November 2012 at http://forums.arm.com

I am having no success into generating random noise with the MALI 400 MP GPU, the code I'm using is next which works with all the other GPU vendors I've tried.
On this specific GPU will return just a few cross screen dotted thin lines with a wide space between them, instead of the expected random noise.

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

void main()
{
vec3 color  = texture2D(u_texture, v_texcoord);
vec3 noise =  vec3( rand(gl_FragCoord.st / 1000.0) );
gl_FragColor = vec4(color + noise, 1.0);
}


Is there something to take into account in this specific GPU hardware?

Thanks
Parents
  • Note: This was originally posted on 1st December 2012 at http://forums.arm.com

    A was still unable to find a way to create a small and compact grain-noise function for this specific GPU model. And as mentioned in your answer seems the problem is the FP16 limit and the sin and fract functions.
    What would be the way to use FP32 in this specific GPU model? I've tried the "precision highp float;" at the start of the shader but it didn't have any effect.

    I've also tried to avoid using sin and fract all together, but I find that with the mod function I also face the same problem. I think it comes from multiplying the variable variation  times 1000.0,
    I find that with small numbers due to the FP16 limit there is no way to find any proper grain-noise function for the MALI-400-MP GPU.


    varying vec2 v_texcoord;
    uniform sampler2D u_texture;

    vec3 grainNoise(in vec3 color, in float intensity)
    {
    float variation = v_texcoord.x * v_texcoord.y * 1000.0;
    variation = mod(variation, 13.0) * mod(variation, 123.0);
    float grain = mod(variation, 0.01);
    vec3 result = color + color * clamp(0.1 + grain * (intensity * 100.0), 0.0, 1.0);
    return result;
    }
    void main()
    {
    vec3 color = texture2D(u_texture, v_texcoord).rgb;
    color = grainNoise(color, 1.0);
    gl_FragColor = vec4(color, 1.0);
    }


    thanks
Reply
  • Note: This was originally posted on 1st December 2012 at http://forums.arm.com

    A was still unable to find a way to create a small and compact grain-noise function for this specific GPU model. And as mentioned in your answer seems the problem is the FP16 limit and the sin and fract functions.
    What would be the way to use FP32 in this specific GPU model? I've tried the "precision highp float;" at the start of the shader but it didn't have any effect.

    I've also tried to avoid using sin and fract all together, but I find that with the mod function I also face the same problem. I think it comes from multiplying the variable variation  times 1000.0,
    I find that with small numbers due to the FP16 limit there is no way to find any proper grain-noise function for the MALI-400-MP GPU.


    varying vec2 v_texcoord;
    uniform sampler2D u_texture;

    vec3 grainNoise(in vec3 color, in float intensity)
    {
    float variation = v_texcoord.x * v_texcoord.y * 1000.0;
    variation = mod(variation, 13.0) * mod(variation, 123.0);
    float grain = mod(variation, 0.01);
    vec3 result = color + color * clamp(0.1 + grain * (intensity * 100.0), 0.0, 1.0);
    return result;
    }
    void main()
    {
    vec3 color = texture2D(u_texture, v_texcoord).rgb;
    color = grainNoise(color, 1.0);
    gl_FragColor = vec4(color, 1.0);
    }


    thanks
Children
No data