Question

I have an edge detection shader which works perfectly fine on both render monkey and my HTC Desire HD. However, it doesn't work on my LG 3D P920. Here is the shader:

In short I am taking the centre pixel and subtracting the 8 values around it. The texture is 512x512.

precision highp float;

varying vec2 vTextureCoord;

uniform sampler2D sTexture;

vec4 edges(void)
{
     const float offset = 1.0 / 512.0;
     vec4 c = texture2D(sTexture, vTextureCoord);
     vec4 edge = texture2D(sTexture, vTextureCoord + vec2(-offset, -offset)) +
     texture2D(sTexture, vTextureCoord + vec2(-offset, 0.0)) +
     texture2D(sTexture, vTextureCoord + vec2(-offset, offset)) +
     texture2D(sTexture, vTextureCoord + vec2( 0.0, offset)) +
     texture2D(sTexture, vTextureCoord + vec2( offset, offset)) +
     texture2D(sTexture, vTextureCoord + vec2( offset, 0.0)) +
     texture2D(sTexture, vTextureCoord + vec2( offset, -offset)) +
     texture2D(sTexture, vTextureCoord + vec2( 0.0, -offset));

     return 8.0 * (c + -0.125 * edge);
}

void main() {
     gl_FragColor = edges();
}

Now on the PC and Desire HD this shows as a mainly black image with coloured edges highlighted. On the LG device however it shows as an over exposed image but with quite a bit of noise.

It feels like a precision issue and as you can see I've tried to up the precision, but I don't know what else to try or if I've done that right.

This isn't isolated to this shader, I have a lighting shader that appears to have noise on this device, but not on others.

I have tried clamping the final value too.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top