I'm working on some simple terrain texturing, and I am quite confused on how you go about interpolating between 3 different textures for a terrain, where you'd interpolate based on the height value of the terrain. I'm also confused about normals for these textures. Each texture has a normal map, so you have 3 normal maps read into the shader. How do you decide which normal to use for the lighting, do you interpolate between the 3 normals as well?
This is what im currently doing. I am interpolating between 2 textures and I am unsure how to interpolate between three and also have lighting work based on each textures normals.
vec3 grasNormalmap = texture(grassNormalMap, texcoords).rgb;
vec3 rocksNormalmap = texture(rocksNormalMap, texcoords).rgb;
vec3 snowNormalmap = texture(snowNormalMap, texcoords).rgb;
//surface normal being used currently but would like to use normal for each texture
// when doing lighting
vec3 N = normalize(normal);
// Ambient lighting
vec3 ambient = vec3(0.2, 0.2, 0.2) * rockTextureColor;
// Diffuse lighting
vec3 diffuseAmount = vec3(0.5, 0.5, 0.5);
float diff_dot_product = max(dot(N, LightDirection), 0.0);
vec3 diffuse = diffuseAmount * diff_dot_product * rockTextureColor;
float grass_height = 1.f;
float rocky_height = 2.0f;
float mountain_snow_height = 3.0f;
// heightValue is from height map
float t = (heightValue - rocky_height) / (grass_height - rocky_height);
color = mix(rockTextureColor, grassTextureColor, t);