I am trying to create a simple visualization of a 3D array in opengl. The 3D array contains color values. To achieve this, I could just draw the cubes, giving them texture coordinates to indicate the correct texel. Well, I tried and it works. But I need a lot more, and the only way to achieve what I want is to simply draw full 2D planes on each grid in a different axis direction when the plane is on, and these are 6 directions. For example, I draw an XY-plane from -15 to +15, on Z-coordinates from -15 to +15, and I do this also for the back-XY-plane, YZ-plane, back-YZ-plane, ... So that way, I can just place the coordinates of the 3D texture in each corner, and interpolation should do the rest.
I took the coordinates of the array as the coordinates of the texture, between 0 and 32, the reason is that in the shader I can smooth the coordinate of the texture and then divide it by 32 to get the exact text for each pixel on the grid.
But alas ... the pixel shader constantly doubts the choice, one pixel is mapped to a different texel than the next pixel, while the next next pixel correctly displays again.
I used to solve these problems by adding 0.5 or 0.35 to the floats to make sure that the floats are rounded correctly on all hardware platforms, but this still seems like such a hack for me. In addition, it does not work with 3D texture.
Can someone tell me how to handle this?
source share