             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 vertexANormal = normalAtPosition(ivec3(center + vertexAPos.xyz));
+            vec3 vertexBNormal = normalAtPosition(ivec3(center + vertexBPos.xyz));
             vec3 mixedNormal = mix(vertexANormal,vertexBNormal,mixing);
             g_normal = mixedNormal;
             gl_Position = transform * (vec4(center,1.0) + mix(vertexAPos, vertexBPos, mixing));

    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;
    
    float diffY = texture(densities, position * d + vec3(0,d,0)).r - texture(densities, position * d + vec3(0,-d,0)).r;
    
    float diffZ = texture(densities, position * d + vec3(0,0,d)).r - texture(densities, position * d + vec3(0,0,-d)).r;
    return normalize(-vec3(diffX,diffY,diffZ));
    
}

    
    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);
