I have a scalar field of values which I have mapped to a 3D texture( image_texture ). And then given a plane gPlaneParams , I have to render the texture of the scalar-field along it.
What I'm doing:
I send 4 points which span the window dimensions using two triangles to the shaders. I bind the texture using a sampler in the fragment shader. Below is the fragment shader  code.
#version 330 core
uniform sampler3D text_sampler;
uniform vec4 gPlaneParams;
in vec4 inPos;
void main()
{
    vec4 Pos = inPos;
    // position input is a square[-1,1]^2
    // and needs to be mapped the plane ax+by+cz=d, where a,b,c,d are the plane parameters;
    //where x,y,z belongs to [0,1]^3
    if (gPlaneParams.z!=0){
        Pos.z = (gPlaneParams.w - gPlaneParams.x*Pos.x - gPlaneParams.y*Pos.y)/gPlaneParams.z;
    }
    else{
        if (gPlaneParams.x!=0){
            Pos.z=Pos.x;
            Pos.x = (gPlaneParams.w - gPlaneParams.y*Pos.y - gPlaneParams.z*Pos.z)/gPlaneParams.x;
        }
        else if (gPlaneParams.y!=0){
            Pos.z=Pos.y;
            Pos.y = (gPlaneParams.w - gPlaneParams.x*Pos.x - gPlaneParams.z*Pos.z)/gPlaneParams.y;
        }
    }
    gl_FragColor=vec4(1.0,0,0,0)*texture3D(text_sampler,(Pos.xyz+1)/2);
}
In my C++ code, I bind the texture as follows:
glGenTextures(1,textureID);
    glBindTexture(GL_TEXTURE_3D,textureID[0]);
    glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB,object_size[0],object_size[1],object_size[2], 0, GL_RGB, GL_UNSIGNED_INT, image_texture1);
    glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_3D,GL_TEXTURE_WRAP_R,GL_CLAMP_TO_EDGE);
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_3D,textureID[0]);
    bool err=glIsTexture(textureID[0]);
    cout<<"Texture bound?"<<err<<endl;
Unfortunately, this does not render any output. Can someone help me figure out what I'm doing wrong?
I have done everything else correctly
- The 4 Vertices and 2 triangles are properly bound (I can render them by giving them constant colours)
- The image texture is contiguous in memory image_texture = (unsigned int*) malloc(object_size[0] *object_size[1] *object_size[2]*3* sizeof(unsigned int));
- All my inputs to the shader are successfully bound.:
gSamplerLocation = glGetUniformLocation(ShaderProgram, "text_sampler");
gPLaneLoc = glGetUniformLocation(ShaderProgram, "gPlaneParams");
glUniform1i(gSamplerLocation, 0);    
glUniform4f(gPLaneLoc,plane_params[0],plane_params[1],plane_params[2],plane_params[3]);
