vs texelFetch

Hi!

I’m having trouble making sense of an issue I have.
I’m trying to store vertex positions in a texture and pass indices to the shader in the vbo.

Now texelFetch returns complete garbage, although the texture seems to be okay (here’s what apitrace is showing)

this is how i try to get the position from the texture in the vertex shader:

void main()
{
    indOut.m = indIn[0];
    indOut.n1 = indIn[1];
    indOut.n2 = indIn[2];

    indOut.debugVert = vec4(floor(indOut.m%11)*1.0f/11, 1.0f-floor(indOut.m%11)*1.0f/11, 0.0f, 1.0f);

    ivec2 indices = ivec2(floor(indOut.m % 11), floor(indOut.m / 11));
    vec4 position = texelFetch(hvt, indices, 0);

    indOut.debugVert += position*0.01f;
    if(position.length() == 4.0f)
        indOut.debugVert += vec4(0.0,0.0,1.0,0.0);



    gl_Position = position;
}

the debugVert is just a color I use to identify issues in the Vertex Shader and to ensure that the texture changes the color (else it gets optimized out). Only the m component of indOut is used, although three indices are passed per vertex. strangely the if statement is always true.

Here’s what’s inside the texture

I have no Idea what I’m doing wrong :confused:

nevermind, figured it out - regular textures aren’t really good at saving arbitrary float data. I’m using a buffer texture now. Also - position.length() should have been length(position)