i have question about glsl. so i have a 1D texture that holds a bunch of index. i had it with integer value (32 bit), so i save it to GPU memory using this command:
in the GLSL code, i want to fetch each value as an integer instead of a 0-1 decimal value, trying to avoid rounding problem. im using texelFectch() so im going to access the precise integer coordinate. how can i fetch the value as an integer?
is it possible to do that? how can this affect the value that i save to the GPU memory? what should i do in the GLSL to get the integer value instead of 0-1?
isampler1d tex;
ā¦
ā¦
int red = texelFetch(tex, ivec, 0).r;
did i miss anything? sorry i asked too much. new to GLSL and it seems theres no easy way to debug using GLSL, and it seems like the compiler does not complain much like other language :-s
int startPointValue = texelFetch(texStartPoint, vertCoord, 0).r;
but no luck. the value always return 0. i checked and rechecked the array sent is not all zero. its normal array of integer with the right size. any idea why this happens and how to make it works?
yeah sorry i think i missed that.
okay i (think) im successfully implement my 2D integer texture. but the weird thing is my i implement the same thing for 1D texture, it returns a constant 0 (while im sure the data is not all 0).
Have you ever succeeded on this issue? Iām facing the very same problem and itās driving me crazy! Iād be grateful if you could give me some heads-up. Thanks in advance.
Context:
Iām trying to implement the Marching Cubes algorithm. Therefore, I need to lookup a 2d-texture containing the triangle table. This texture is called āInTriangleTableā.
I can check its contents by using gDEBugger GL by graphicREMEDY. So, I can for sure say that each texel has a different value and none of them equals 0. Also, I can confirm that āInEdgeVertexOffsetā is initialized correctly and every entry in that array differs from each other.
Itās exactly like I do it, but for some reason it just doesnāt workā¦ Iād be glad to have a look through your code. Thereās got to be something Iām not aware of.
the glsl is a little bit long. the spFit is the texIndexStartPoint in the GLSL. i use the real enum value since using GL_R32I gives me compiling error. quick question: have you enable the extension on the top of the fragment shader like in the blog?
By default, it is set to use mipmaps. If you didnāt supply mipmaps, or change the filter to not use mipmaps, then the texture is incomplete and youāll get [0,0,0,1] when sampling.