I'm a bit new to OpenGL, so please bear with me. I'm trying to create a smooth transition from one texture to another on a simple heightmapped terrain. To do this, I'm currently rendering the baseline texture (a simple sand texture) and then trying to blend the second texture in over the top of it with varying alpha values at the four vertices on the edge. Unfortunately, I can't seem to make the glColor() function's alpha values do much of anything on anything but unlit, untextured polygons. Any way to get this working?
The code I've got currently looks like so:
Doesn't do much, presently. Anything I can do to make this work? Are there any possible alternative methods?
EDIT: Looks like I should probably handle this through multitexturing... not yet quite sure how to code it so that it blends the two textures according to the alpha values I've got calculated above, though.
The code I've got currently looks like so:
Alpha1 = Clamp(TerrainMap[x, y].Height + 3.5, 0.0, 1.0) Alpha2 = Clamp(TerrainMap[x + 1, y].Height + 3.5, 0.0, 1.0) Alpha3 = Clamp(TerrainMap[x + 1, y + 1].Height + 3.5, 0.0, 1.0) Alpha4 = Clamp(TerrainMap[x, y + 1].Height + 3.5, 0.0, 1.0) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND) glEnable(GL_BLEND) glBegin(GL_QUADS) glTexCoord2f(0.0, 0.0); glColor4f(0.0, 0.0, 0.0, Alpha1) glVertex3f(x, y, TerrainMap[x, y].height) glTexCoord2f(1.0, 0.0); glColor4f(0.0, 0.0, 0.0, Alpha2) glVertex3f(x + 1, y, TerrainMap[x + 1, y].height) glTexCoord2f(1.0, 1.0); glColor4f(1.0, 1.0, 1.0, Alpha3) glVertex3f(x + 1, y + 1, TerrainMap[x + 1, y + 1].height) glTexCoord2f(0.0, 1.0); glColor4f(0.0, 0.0, 0.0, Alpha4) glVertex3f(x, y + 1, TerrainMap[x, y + 1].height) glEnd()
Doesn't do much, presently. Anything I can do to make this work? Are there any possible alternative methods?
EDIT: Looks like I should probably handle this through multitexturing... not yet quite sure how to code it so that it blends the two textures according to the alpha values I've got calculated above, though.