So I’m trying to render my terrain with a grass and rock texture using a 3D texture to blend between them. But when I go to render, it tiles the textures next to eachother. In this sample, I’m actually trying to render just the grass texture on a quad but its rendering the rock on the top half and the grass on the bottom half. Oops, that’s my water texture in the picture, not grass.
void initTextures(void) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &gui_tex);
glBindTexture(GL_TEXTURE_3D, gui_tex);
importBMP("512A.bmp", &bmp[0][0][0][0], 512);
importBMP("512B.bmp", &bmp[1][0][0][0], 512);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 4, 512,
512, 0, GL_RGB, GL_UNSIGNED_BYTE, gui_bmp);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
}
void renderScene(void) //**RENDERSCENE**//
{
glutTimerFunc( 1000/30.0, timer, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_3D);
glBegin(GL_QUADS);
glTexCoord3d(0,0,1); glVertex3f( 3, 3,0);
glTexCoord3d(0,0,0); glVertex3f( 3, -3,0);
glTexCoord3d(0,1,0); glVertex3f(-3, -3,0);
glTexCoord3d(0,1,1); glVertex3f(-3, 3,0);
glEnd();
glutSwapBuffers();
}