public void generateWoodTexture(Texture tex) {
		float noise;
		float grainNoise;
		float sample_x;
		float sample_y;
		float freq;
		float amp;
		
		float majorFrequency = 1.0f;
		int majorOctaves = 1;
		float majorPersistence = 0.5f;
		float majorBands = 32.0f; // "Density" of major wood bands (i.e. frequency of discontinuities)
		
		float grainFrequency = 32.0f; // Control noise frequency
		float grainAmplitude = 0.2f; // Controls intensity of grain colour change
		int grainOctaves = 2;
		float grainPersistence = 0.5f;
		float grainStretch = 16.0f; // Control noise sample position stretch factor
		
		PerlinNoise noiseMaker = new PerlinNoise();
		
		colorGradient.addColor(0.0f, new Color(0x472207)); // Dark
		colorGradient.addColor(1.0f, new Color(0xA55015)); // Light

		for (int y=0; y<tex.height; ++y) {
			for (int x=0; x<tex.width; ++x) {
				sample_x = (float)x/tex.width;
				sample_y = (float)y/tex.height;
				
				
				// Major wood pattern
				noise = 0.0f;
				freq = majorFrequency;
				amp = 1.0f;
				for (int i=0; i<majorOctaves; ++i) {
					noise += amp * noiseMaker.noise(sample_x*freq, sample_y*freq, 0.5f);
					
					freq *= 2.0f;
					amp *= majorPersistence;
				}
				
				if (noise > 1.0f)
					noise = 1.0f;
				if (noise < -1.0f)
					noise = -1.0f;

				noise += 1.0f;
				noise *= 0.5f;
				
				noise *= majorBands;
				noise = noise - (float)Math.floor(noise);
				
				// Fine wood grain detail
				grainNoise = 0.0f;
				freq = grainFrequency;
				amp = grainAmplitude;
				for (int i=0; i<grainOctaves; ++i) {
					grainNoise += amp * noiseMaker.noise(sample_x*freq*grainStretch, sample_y*freq, 0.5f);
					
					freq *= 2.0f;
					amp *= grainPersistence;
				}
				
				noise += grainNoise;
				
				if (noise > 1.0f)
					noise = 1.0f;
				if (noise < 0.0f)
					noise = 0.0f;
				

				// Apply the colour value
				Color result = colorGradient.getColor(noise);
				tex.pixels[y*tex.width + x] = result.getRGB();
			}
		}
	}