Glsl bilinear and artifact on same scale

I need to implement a glsl bilinear filter (I can’t use GL_LINEAR because i am doing YUY2 ->RGB convert, so I have set this to GL_NEAREST). I have a classic bilinear filtering like this :

void main(void)
{
vec2 f = fract( texcoord.st * vec2(width,height));
vec4 t00 = yuv2rgb(texcoord.st);
vec4 t10 = yuv2rgb(texcoord.st+vec2(1.0/width,0.0));
vec4 tA = mix( t00, t10, f.x );
vec4 t01 =yuv2rgb(texcoord.st+vec2(0.0,1.0/height));
vec4 t11 =yuv2rgb(texcoord.st+vec2(1.0/width,1.0/height));
vec4 tB = mix( t01, t11, f.x );
gl_FragColor=mix(tA , tB , f.y );
}where width and height are the size of the texture. I am trying to do that on Windows with Amd graphic card.If I move the textured quad, scale the textured scale … I see at the some changing location an artifact (horizontal or vertical lines).it seems my shader is very classical … I don’t know what I can do to avoid theses artifacts.

Try
vec2f=fract(texcoord.st*vec2(width,height) - 0.5f);

Pixel center is {0,0} , so {-0.5,-0.5} is its bottom-left coord.

I have test this and it’s not working … same artifact and more … And I don’t understand why I need shift from -0.5

[QUOTE=qnext;1245839]I need to implement a glsl bilinear filter (I can’t use GL_LINEAR because i am doing YUY2 ->RGB convert, so I have set this to GL_NEAREST). I have a classic bilinear filtering like this :

vec2f=fract(texcoord.st*vec2(width,height));
vec4t00=yuv2rgb(texcoord.st);
vec4t10=yuv2rgb(texcoord.st+vec2(1.0/width,0.0));
[/QUOTE]
That is incorrect. It should be something like:

// (0,0) is bottom left corner of texel. As we use nearest filtering - we want to sample at the relevant texel centers.
vec2 tc_tmp = texcoord * vec2(width, height);
vec2 tc_center = floor(tc_tmp - 0.5) + 0.5;
vec2 f = fract(tc_tmp - tc_center);
texcoord = tc_center / vec2(width, height);
vec4 t00 = texture(some_tex, texcoord);
vec4 t01 = texture(some_tex, texcoord + vec2(1.0/width,0.0));
etc.

[QUOTE=Ilian Dinev;1245840]Try
vec2f=fract(texcoord.st*vec2(width,height) - 0.5f);

Pixel center is {0,0} , so {-0.5,-0.5} is its bottom-left coord.[/QUOTE]No it is not. AFAIK Direct3D has that - perhaps you are confusing the two.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.