1D Texture coordinates

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.

In C++, you specify the fenceposts. In shaders, you look at the middle of fence crossbeams.

So if you’re using 0.5 as your t coordinate in a shader, you’d better have a fencepost at 1 or greater.

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