Download

Procedual Mesh Texturing

Hello everyone
Currently we create a huge procedual mesh (over 1.5 million vertices and 9.5 million triangles) without a problem. The created mesh describes the heightmap of our current level. Now we want to apply a Material to this mesh, which fails. When applying the material we end up with rather a pitch black or single colored terrain with no visible texture. When we add the points to the vertices array we also add an point to the UV array. When creating our mesh we inrease it by adding quads to the vertices array. We want our Material to cover one of these quads. (see the code example)



int AHeigthMesh::AddQuad(int row, int col) {

if (row + skip > this->ascdata->rows || col + skip > this->ascdata->collumes) {
return -1;
}

GameAnchorPoint *tl = this->ascdata->HeightMatrix[row][col]; //topleft
GameAnchorPoint *tr = this->ascdata->HeightMatrix[row][col + skip]; //topright
GameAnchorPoint *bl = this->ascdata->HeightMatrix[row + skip][col]; //bottomleft
GameAnchorPoint *br = this->ascdata->HeightMatrix[row + skip][col + skip]; //bottomright

// we may need to add some of the gameanchorpoints
if (tl != NULL && tl->id == 0) { // uninitialized, but valid!
tl->id = vertices.Add(FVector(tl->x, tl->y, tl->z)); UV0.Add(FVector2D(0, 0));
}

if (tr != NULL && tr->id == 0) { // uninitialized, but valid!
tr->id = vertices.Add(FVector(tr->x, tr->y, tr->z));
UV0.Add(FVector2D(1, 0));
}
return 0;
}

We would really appreciate your help!