Lerp between vertices

I’m trying to make a simple mesh terrain for an ios game. The problem I’m facing is trying to smoothly texture the terrain. As far as I can see the following code should work but when I run it the lerp command appears to do nothing. Can anyone run a fresh pair of eyes over this and hopefully see where I’m going wrong?

		z = 0;
		x = 0;
		i = 0;
		j = 0;
		k = 0;
		Vector3 bl;
		Vector3 br;
		Vector3 lerpX;
		Vector3 lerpZ;
		Vector3 tl;
		Vector3 tr;
		float greenPercent;
		tempColors = new Color[terrainTexSize * terrainTexSize];
		while (z < terrainLength - 1) {
			while (x < terrainLength - 1){
				bl = new Vector3(0, heightPercent[x,z], 0);
				br = new Vector3(0, heightPercent[x + 1, z], 0);
				tl = new Vector3(0, heightPercent[x,z + 1], 0);
				tr = new Vector3(0, heightPercent[x + 1, z + 1], 0);
				while (j < terrainTexSize) {
					lerpX = Vector3.Lerp(bl, br, terrainTexSize);
					while (k < terrainTexSize){
						lerpZ = Vector3.Lerp(tl, tr, terrainTexSize);
						greenPercent = ((lerpX.y + lerpZ.y) / 2);
//						Debug.Log(greenPercent);
						tempColors*.g = greenPercent;*
  •  				i++;*
    
  •  				k++;*
    
  •  			}*
    
  •  			k = 0;*
    
  •  			j++;*
    
  •  		}*
    

_ fullTerrTex.SetPixels(x * terrainTexSize, z * terrainTexSize, terrainTexSize, terrainTexSize, tempColors);_

  •  		x++;*
    
  •  		i = 0;*
    
  •  		j = 0;*
    
  •  	}*
    
  •  	z++;*
    
  •  	x = 0;*
    
  •  }*
    
  •  fullTerrTex.Apply();*
    
  •  renderer.sharedMaterial = TerrainMat;*
    
  •  renderer.material.mainTexture = fullTerrTex;*
    
  •  renderer.material.mainTextureScale = new Vector2(1, 1);*
    

terrainTexSize is greater than 1.