shelll

01-24-2006, 03:16 AM

this is my simple shader used for reductions, which works ok:

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st + vec2(-1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st + vec2(-1.0, -1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st + vec2(0.0, -1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}but first i used this shader:

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st - vec2(1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st - vec2(1.0, 1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st - vec2(0.0, 1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}which worked only in some cases, what is wierd :( and it should give the same results.

my first shader was this, which gave compleltly bad results, i don't know why :(

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st + vec2(1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st + vec2(1.0, 1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st + vec2(0.0, 1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}my rendering code for quad is like this:

glBegin(GL_QUADS);

glTexCoord2f(0.5f, 0.5f);

glVertex3f(0.0f, 0.0f, -0.5f);

glTexCoord2f(vWidth + 0.5f, 0.5f);

glVertex3f(vWidth >> 1, 0.0f, -0.5f);

glTexCoord2f(vWidth + 0.5f, vHeight + 0.5f);

glVertex3f(vWidth >> 1, vHeight >> 1, -0.5f);

glTexCoord2f(0.5f, vHeight + 0.5f);

glVertex3f(0.0f, vHeight >> 1, -0.5f);

glEnd();i have been experimenting with many different vertex and texture coordinates and shaders, but only current give me good results. i am especially curios about the difference between the 1st and the 2nd shader, which *must* gave same results, but do not.

gf6600gt, 81.85, xp sp2

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st + vec2(-1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st + vec2(-1.0, -1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st + vec2(0.0, -1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}but first i used this shader:

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st - vec2(1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st - vec2(1.0, 1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st - vec2(0.0, 1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}which worked only in some cases, what is wierd :( and it should give the same results.

my first shader was this, which gave compleltly bad results, i don't know why :(

#define GL_ARB_texture_rectangle 1;

uniform sampler2DRect tex;

void main() {

vec4 data;

data.x = texture2DRect(tex, gl_TexCoord[0].st).x;

data.y = texture2DRect(tex, gl_TexCoord[0].st + vec2(1.0, 0.0)).x;

data.z = texture2DRect(tex, gl_TexCoord[0].st + vec2(1.0, 1.0)).x;

data.w = texture2DRect(tex, gl_TexCoord[0].st + vec2(0.0, 1.0)).x;

gl_FragColor.x = max(max(data.x, data.y), max(data.z, data.w));

}my rendering code for quad is like this:

glBegin(GL_QUADS);

glTexCoord2f(0.5f, 0.5f);

glVertex3f(0.0f, 0.0f, -0.5f);

glTexCoord2f(vWidth + 0.5f, 0.5f);

glVertex3f(vWidth >> 1, 0.0f, -0.5f);

glTexCoord2f(vWidth + 0.5f, vHeight + 0.5f);

glVertex3f(vWidth >> 1, vHeight >> 1, -0.5f);

glTexCoord2f(0.5f, vHeight + 0.5f);

glVertex3f(0.0f, vHeight >> 1, -0.5f);

glEnd();i have been experimenting with many different vertex and texture coordinates and shaders, but only current give me good results. i am especially curios about the difference between the 1st and the 2nd shader, which *must* gave same results, but do not.

gf6600gt, 81.85, xp sp2