inline double turbulence(module::Perlin& noise, const osg::Vec3d& v, double f )
 {
     double t = -0.5;
     for( ; f<getPixelsPerTile()/2; f *= 2 ) 
         t += abs(noise.GetValue(v.x(), v.y(), v.z())/f);
     return t;
 }
void VoxelChunkCL::createNoiseArrayFromPerlinNoise(module::Perlin perlinModule, float zOffset) {
	int index = 0;
	float height = 0;
	int size = gridSize[0] * gridSize[1] * gridSize[2];
	float* volume = new float[size];
	for (int i = 0; i < gridSize[0]; i++) {
		for (int j = 0; j < gridSize[1]; j++) {
			for (int k = 0; k < gridSize[2]; k++) {
				height = round(perlinModule.GetValue(i * 0.01, j * 0.01, (k + zOffset) * 0.01) * 20) + 15;
				volume[index++] = (float)height;
			}
		}
	}

	cl_image_format volumeFormat;
	volumeFormat.image_channel_order = CL_R;
	volumeFormat.image_channel_data_type = CL_FLOAT;

	cl_mem_flags flags = CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR;
	cl.CreateImage3D(flags, &volumeFormat, gridSize[0], gridSize[1], gridSize[2], 0, 0, volume, volumeData);
	free(volume);
}
 inline double sample(module::Perlin& noise, const osg::Vec3d& v)
 {
     return noise.GetValue(v.x(), v.y(), v.z());
 }
 inline double sample(module::Perlin& noise, double x, double y, double z)
 {
     return noise.GetValue(x, y, z);
 }