Texture3D back face does not show after rotation

Hi,

I am trying to show slices from a 3D volume using texture3d. I can get the code run and the slices shown. The problem is when I rotate the rendered slice to its back facing me, the slice disappears, leaving nothing. How can I solve this? I guess I did something wrong in setting up the parameters for texture3d?

Thank you in advance.

I did this in the initialization:


    // options
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnable(GL_NORMALIZE);

    // lightening
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    // texture 3d settings
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    glEnable(GL_TEXTURE_3D);
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);

   // voldata values
   ...

    // texture 3d id
    GLuint texid;
    glGenTextures(1,&texid);

    // bind specific texture
    glBindTexture(GL_TEXTURE_3D,texid);

    // set the texture parameters
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage3D(GL_TEXTURE_3D,0,GL_INTENSITY,n1,n2,n3,0,GL_LUMINANCE,GL_FLOAT,voldata);
   

And in the paintGL(), I did the following:


    // options
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(10,1.0f,0.1f,20);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glPushMatrix();

    glTranslatef(0.0, 0.0, -10.0);

    // set rotation and zoom
    glRotatef(xRot, 1.0, 0.0, 0.0);
    glRotatef(yRot, 0.0, 1.0, 0.0);
    glRotatef(zRot, 0.0, 0.0, 1.0);
    glScaled(zoomScale, zoomScale, zoomScale);

    // draw the slices
    draw();

    glPopMatrix();

And resizeGL():


    int side = qMin(width, height);
    glViewport((width - side) / 2, (height - side) / 2, side, side);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(10,1.0f,0.1f,20);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

Think I have found the solution:

This line should be removed: glEnable(GL_CULL_FACE);

Thank you.

[QUOTE=nebulaekg;1291191]Hi,

I am trying to show slices from a 3D volume using texture3d. I can get the code run and the slices shown. The problem is when I rotate the rendered slice to its back facing me, the slice disappears, leaving nothing. How can I solve this? I guess I did something wrong in setting up the parameters for texture3d?

Thank you in advance.

I did this in the initialization:


    // options
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnable(GL_NORMALIZE);

    // lightening
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    // texture 3d settings
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    glEnable(GL_TEXTURE_3D);
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);

   // voldata values
   ...

    // texture 3d id
    GLuint texid;
    glGenTextures(1,&texid);

    // bind specific texture
    glBindTexture(GL_TEXTURE_3D,texid);

    // set the texture parameters
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage3D(GL_TEXTURE_3D,0,GL_INTENSITY,n1,n2,n3,0,GL_LUMINANCE,GL_FLOAT,voldata);
   

And in the paintGL(), I did the following:


    // options
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(10,1.0f,0.1f,20);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glPushMatrix();

    glTranslatef(0.0, 0.0, -10.0);

    // set rotation and zoom
    glRotatef(xRot, 1.0, 0.0, 0.0);
    glRotatef(yRot, 0.0, 1.0, 0.0);
    glRotatef(zRot, 0.0, 0.0, 1.0);
    glScaled(zoomScale, zoomScale, zoomScale);

    // draw the slices
    draw();

    glPopMatrix();

And resizeGL():


    int side = qMin(width, height);
    glViewport((width - side) / 2, (height - side) / 2, side, side);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(10,1.0f,0.1f,20);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

[/QUOTE]