Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: transfer function RGBA

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    2

    transfer function RGBA

    Hi,
    I am trying to make a volume renderer in color. To do that, I implemented a shader :

    #define EPSILON (0.001)

    half4 main(
    half3 uvw : TEXCOORD0,
    half4 col : COLOR,

    uniform sampler3D data,
    uniform sampler1D colortable) : COLOR
    {
    half4 value = tex3D(data, uvw);
    half4 color = tex1D(colortable, value.a);
    return color;
    }

    I can see my volume but it in grayscale and not in color.
    The variable data refers to my volume :
    gl.glTexImage3D(GL.GL_TEXTURE_3D, 0, GL.GL_RGBA, width, height, depth, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, data);
    The variable colortable refers to the transferfunction :
    gl.glTexImage1D(GL.GL_TEXTURE_1D, 0, GL.GL_RGBA, TF_TABLE_SIZE, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, m_pColorTable);
    and this is how I build my transfer function :

    int[][] colorTable = new int[4][256];

    for (int j = 0; j < seuil1; j++) {
    colorTable[0][j] = j;
    colorTable[1][j] = 0;
    colorTable[2][j] = 0;
    colorTable[3][j] = j;
    }
    for (int j = seuil1; j < seuil2; j++) {
    colorTable[0][j] = 0;
    colorTable[1][j] = 0;
    colorTable[2][j] = 0;
    colorTable[3][j] = 0;
    }
    for (int j = seuil2; j < 256; j++) {
    colorTable[0][j] = j;
    colorTable[1][j] = 0;
    colorTable[2][j] = 0;
    colorTable[3][j] = j;
    }

    int tmp = 0;
    for (int i = 0; i < 256; i++) {
    m_pColorTableR.put((byte) colorTable[0][i]);
    m_pColorTableR.put((byte) colorTable[1][i]);
    m_pColorTableR.put((byte) colorTable[2][i]);
    m_pColorTableR.put((byte) colorTable[3][i]);
    }
    m_pColorTableR.rewind();

    Does somebody have an idea ?
    Thank you

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    800

    Re: transfer function RGBA

    Hi,
    What filtering mode have u setup for the transfer function texture. And you should check the tf by drawing the transfer function on screen.
    Regards,
    Mobeen

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    2

    Re: transfer function RGBA

    Hi,
    for the transfer function texture, I have setup :
    gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
    gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
    gl.glTexImage1D(GL.GL_TEXTURE_1D, 0, GL.GL_RGBA, TF_TABLE_SIZE, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, m_pColorTable);

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    800

    Re: transfer function RGBA

    OK. Have u tried rendering the tf directly?
    Another thing that I want to ask is does you volume data contain 4bytes per voxel because u r using GL_RGBA? The only reason I can think of using this is to store precomputed gradient in RGB and density in A. Are u doing this?
    Regards,
    Mobeen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •