How can I effectively import and texture a large height mapped terrain mesh? I am looking for advice on how to handle a large terrain mesh that I am importing from an existing file format through a custom add-on I am writing. Currently, I import heights from a height map file and generate vertices, edges and faces to create a single grid plane mesh. Here is an example of how it looks:



I have a total of 202,800 vertices and the dimension of my mesh is 520x390. Each 5x5 vertices (4x4 faces) represents 1 "tile" in the original file format and contains a pair of blended 256x256 textures. It's at this point that I am unsure how to best proceed because the dimensions of my mesh give me a fairly high number of "tiles" -- 8112. So here is my question:


Should I add 8112 materials to the mesh to texture each group of faces that represent a tile? OR
Should I break my mesh into 8112 objects, each representing a tile? OR
Is there a completely better way to handle this that I am missing?


Thanks for taking a look.

EDIT Adding some more information as recommended my Duarte

The terrain comes from an old 3D game and right now my only objective is to be able to render the terrain with textures in blender and manipulate the content. I don't really have a preference for which render engine to use (is one better than the other? I am an entry-level blender user).

More technically, for each 4x4 face I want to:


Blend 3 textures (256x256)
Apply the new texture to those faces
Render the mesh with all faces textured 


EDIT2

After sleeping on it and taking a new look at the problem I realized that I could trim the number of "tiles" from 8112 to 224. This was due to the fact that not each tile is unique and some of the textures are duplicated ("tiled"). I added 224 default materials to the mesh and memory usage was not too bad (707mb - untextured). Going to experiment with this and will report back if it turns out to be a good solution for me.
I have since found a good solution for my problem. What I've done is break up the mesh into individual "chunks" and then applied a material to each to texture it. I discovered that Blender can handle that many objects and my perception otherwise was due to the script functions I was using. Here is some pseudo code for what worked for me with good performance (10-15 seconds to create 8112 5x5 objects with 25 faces each):

for chunk in chunks:
    mesh = bpy.data.meshes.new(str(chunk.name))
    mesh.from_pydata(chunk.vertices, chunk.edges, chunk.faces)

    obj = bpy.data.objects.new(obj+str(chunk.name), mesh)
    obj.location = (chunk.offset.x, chunk.offset.y, 0

    bpy.context.scene.objects.link(obj)


The key was to not use any operations in bpy.ops but to instead create and link the mesh/obj/scene for better performance. See here to understand details Python performance with Blender operators.