Original Post
Hi, I have a problem reading texture values from vertex shader. Basicly, I try to read positions from a texture and assign the value as position as the vertex position. (in vertex shader) here is a part of my display: ------------------------------------------------------------------------------------- glBegin(GL_POINTS); for(int i=0; i<CURR_Particle; i++) glVertex3f((int)i/(TEXSIZE),i%(TEXSIZE),0.0); glEnd(); ------------------------------------------------------------------------------------- vertex shader: ------------------------------------------------------------------------------------- uniform sampler2D render_position_tex; void main(void){ vec2 normalized_coor; vec2 coor = gl_Vertex.xy; float texSize = 256.0; normalized_coor.x = (coor.x / texSize) + (1.0/(texSize*2.0)); normalized_coor.y = (coor.y / texSize) + (1.0/(texSize*2.0)); vec4 particle_position = texture2D(render_position_tex, normalized_coor); gl_Position = gl_ModelViewProjectionMatrix * particle_position; } ------------------------------------------------------------------------------------- and fragment shader : ------------------------------------------------------------------------------------- void main(void) { gl_FragColor = gl_Color; } ------------------------------------------------------------------------------------- The values in texture is either x,y,0,1.0 or 0,0,0,0. x and y are different for each texel. What I get as a result is only two points one at origin and other somewhere else unrelated(or I think it is unrelated). I think I am correctly setting up the uniform so why is all the texture lookup return only two values Btw. I am running on NVIDIA 9600GT. I setup the texture as ------------------------------------------------------------------------------------- glActiveTexture(textureunit); glBindTexture(GL_TEXTURE_2D, texID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F_ARB , TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_FLOAT, 0); ------------------------------------------------------------------------------------ Thanks in advance.