public BufferedImage renderPrepared(int px, int pz, int sx, int sz, double min, double max)
    {
        BufferedImage res = new BufferedImage(sx, sz, BufferedImage.TYPE_INT_RGB);
        double[] data = get2DData(px, pz, sx, sz);
        
        for(int x = 0; x < sx; x++)
            for(int z = 0; z < sz; z++)
            {
                double val = data[x*sz + z];
                val = (val-min)/(max-min)*256;
                int shade = (int) val;
                int col = shade | (shade<<8) | (shade<<16);
                if(shade < 0 || shade > 255)
                    col = 0x000000FF;
                res.setRGB(x, z, col);
            }
        return res;
    }