jgrossm1

11-02-2007, 06:12 AM

Hi, I'm trying to run a fragment shader, and need to calculate 1D texture coordinates. For fragment shaders I've done with 2D textures, I calculated the coordinates with:

for(i=0; i<int(tex_height); i++) {"

" for(j=0; j<int(tex_width); j++) {"

" tex_index.x = (float(j)+0.5) / float(particle_tex_width);"

" tex_index.y = (float(i)+0.5) / float(particle_tex_height);"

" tex_value = texture2D(position_charge, particle_index);"

}

}

For single dimensions would I just have to set the tex_index.y=0.5 if I make it single dimensional in the x direction?

Also, in the C++ source code I'm using to call this shader program, when rendering the texture, do i specify the texture coordinates (0.0,0.0) and (1.0,0.0) or do i need to add a height to it?

Thanks in advance.

for(i=0; i<int(tex_height); i++) {"

" for(j=0; j<int(tex_width); j++) {"

" tex_index.x = (float(j)+0.5) / float(particle_tex_width);"

" tex_index.y = (float(i)+0.5) / float(particle_tex_height);"

" tex_value = texture2D(position_charge, particle_index);"

}

}

For single dimensions would I just have to set the tex_index.y=0.5 if I make it single dimensional in the x direction?

Also, in the C++ source code I'm using to call this shader program, when rendering the texture, do i specify the texture coordinates (0.0,0.0) and (1.0,0.0) or do i need to add a height to it?

Thanks in advance.