PDA

View Full Version : Texture problem using custom shader program



brusamost
01-15-2007, 06:38 AM
Hi, this is my first post in this comunity so a big CIAO from italy.

I'm moving my first step writing programs in opengl and glsl.

I've write a program that send a texture (500x500 black and white), modify it and write the modified texture to file.

Shader:

// dichiaro la texture
uniform sampler2DRect texUnit1;

void main() {
vec2 pre = vec2(-1,0);
vec4 pixel = texture2DRect(texUnit1, vec2(gl_TexCoord[0]));
vec4 pixelPre = texture2DRect(texUnit1, gl_TexCoord[0].st + pre);

if ( ((gl_TexCoord[0].s > 0 &amp;&amp; gl_TexCoord[0].s < 500)) &amp;&amp; (gl_TexCoord[0].t > 0 &amp;&amp; gl_TexCoord[0].t < 500) ){
pixel = pixel - pixelPre;
}
gl_FragColor = vec4 (pixel.b, pixel.g, pixel.r, 4.0);
} I compile and run it without problems, but the modified texture has some imperfection.
The shader program read the pixel neighbour and sub it to found the vertical boundaries of the shape in the texture.
Every 128 pixel a vertical line run form the top to the bottom of my texture.

I'm not able to resolve this problem, can you help me?

Thanks very mutch
Stefano