     x - y + z
     );
   
-vec3 normalAtPosition(in vec3 position) {
-    float d = 1.0 / (a_dim - 1);
-    float diffX = texture(densities, position * d + vec3(d,0,0)).r - texture(densities, position * d + vec3(-d,0,0)).r;
+vec3 normalAtPosition(in ivec3 position) {
+    int d = 1;
+    float diffX = texelFetch(densities, position + ivec3(d,0,0), 0).r - texelFetch(densities, position + ivec3(-d,0,0), 0).r;
     
-    float diffY = texture(densities, position * d + vec3(0,d,0)).r - texture(densities, position * d + vec3(0,-d,0)).r;
+    float diffY = texelFetch(densities, position + ivec3(0,d,0), 0).r - texelFetch(densities, position + ivec3(0,-d,0), 0).r;
     
-    float diffZ = texture(densities, position * d + vec3(0,0,d)).r - texture(densities, position * d + vec3(0,0,-d)).r;
+    float diffZ = texelFetch(densities, position + ivec3(0,0,d), 0).r - texelFetch(densities, position + ivec3(0,0,-d), 0).r;
     return normalize(-vec3(diffX,diffY,diffZ));
     
 }

            float vertexADensity = vertexDensities[vertexA];
            float vertexBDensity = vertexDensities[vertexB];
            float mixing = vertexADensity / (vertexADensity - vertexBDensity);
            vec3 vertexANormal = normalAtPosition(center + vertexAPos.xyz);
            vec3 vertexBNormal = normalAtPosition(center + vertexBPos.xyz);
            vec3 mixedNormal = mix(vertexANormal,vertexBNormal,mixing);
            g_normal = mixedNormal;
            gl_Position = transform * (vec4(center,1.0) + mix(vertexAPos, vertexBPos, mixing));

    
    float[8] vertexDensities;
    for (int k = 0; k < vertices.length(); k++) {
        vertexDensities[k] = texelFetch(densities, ivec3(center + (vertices[k]).xyz), 0).r;
    }
    
    int v0present =  int(vertexDensities[0] > 0);
