title: Whats causing this artefacts?
body: <p>I'm trying to map a 3D Texture to a Voxel Terrain, the pixel color from the texture should align with the terrain geometry and I don't want any gradients.</p>
  
  <p>It's kinda working but depending on the camera angle I can see artefacts and I would like to know what's causing this and how to fix it.</p>
  
  <p>Is it some kind of bleeding? I've already tried to change my texture as described here: 
  <a href="http://www.ogre3d.org/forums/viewtopic.php?f=4&amp;t=61602" rel="nofollow noreferrer">ogr3d tilemap</a> but without success.</p>
  
  <p>I think it's not a mipmapping bug because I turned it off and if I turn it on it looks way worse.</p>
  
  <p>The geometry is grid aligned.
  I set min and mag filtering to nearest and wrapping to clampToEdge.</p>
  
  <p>fragment:</p>
  
  <pre><code>vec2 computeSliceOffset(float slice, float slicesPerRow, vec2 sliceSize) {
    return sliceSize * vec2(mod(slice, slicesPerRow), floor(slice / slicesPerRow));   
  }
  
  vec4 sampleAs3DTexture(sampler2D tex, vec3 texCoord, float size, float numRows, float slicesPerRow) {    
    float slice   = texCoord.z * size;                                                
    float sliceZ  = floor(slice);                                                     
    float zOffset = fract(slice);                                                     
  
    vec2 sliceSize = vec2(1.0 / slicesPerRow, 1.0 / numRows);
    vec2 sliceOffset = computeSliceOffset(sliceZ, slicesPerRow, sliceSize);
    vec2 uv = texCoord.xy * sliceSize;                                           
    vec4 sliceColor = texture2D(tex, sliceOffset + uv);                               
    return sliceColor;                                                                
  }
  
  vec3 texCoord = mod(worldPosition.xyz,128.0)/128.0;                                 
  vec4 myColor = sampleAs3DTexture(texture_0,texCoord,64.0,8.0,8.0);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qCyIT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qCyIT.png" alt="pic"></a>
  <a href="https://i.stack.imgur.com/uAceo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uAceo.png" alt="pic"></a></p>