Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texturing terrain using alpha maps

Started by CodeZero May 19, 2006 at 12:03 PM 0 replies 400+ views
Original Post
CodeZero
CodeZero
So I have a chunk of terrain I want to render with an alpha map pre-generated for each texture on that chunk. I'm trying to fiddle around with blending to get it all to render now, but I can't seem to get the calls right. Do I make 2 separate rendering passes, one drawing the alpha map and the other drawing the texture on top? My background right now is grey (the same color as my fog) so I get my texture showing up faintly in areas it isn't supposed to. Can anybody help? This is clunky test code, but it shows what I'm getting at, hopefully:

glEnable(GL_BLEND);
for (int j = 0; j < terrain->textureNum; j++) {
	glBlendFunc(GL_DST_COLOR, GL_ZERO);
	glInterleavedArrays(GL_T2F_N3F_V3F, 0, terrain->alphaVertices);
	glBindTexture(GL_TEXTURE_2D, textureManager->textures[terrain->terrainChunks->alphaIndices[j]]);
	glDrawElements(GL_TRIANGLES, terrain->mipMaps->triangleVertexNum, GL_UNSIGNED_INT, terrain->mipMaps->triangleIndices);

	glBlendFunc(GL_ONE, GL_ONE);
	glInterleavedArrays(GL_T2F_N3F_V3F, 0, terrain->vertices);
	glBindTexture(GL_TEXTURE_2D, textureManager->textures[terrain->textureIndices[j]]);
	glDrawElements(GL_TRIANGLES, terrain->mipMaps->triangleVertexNum, GL_UNSIGNED_INT, terrain->mipMaps->triangleIndices);
} // for j
glDisable(GL_BLEND);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.