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 7 of 7

Thread: Question on using short CT data create texture

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6

    Question on using short CT data create texture

    My CT volume is 12-bits short data, but the negative values can be simply ignored.

    I want ask what's the difference between:

    glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, imgWidth_, imgHeight_, imgSlice_, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, volume_);

    and

    glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, imgWidth_, imgHeight_, imgSlice_, 0, GL_LUMINANCE, GL_SHORT, volume_);

    which one is better for creating 3d texture? and when I use GLSL doing the sampling, should I times 16.0 to let the 12-bits value normalized to (0.0 - 1.0).

    Thanks a lot!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,580

    Re: Question on using short CT data create texture

    Did you check :
    http://www.opengl.org/sdk/docs/man/x...DrawPixels.xml

    Use GL_SHORT, otherwise the 12bits negative values will become big positive values in your GLSL sampler wich will become hard to detect and ugly to interpolate.
    Edit : scratch that, you should set your negative 12bits values to 0, in any case.

    Then, to keep precision, you have to specify something better for internalFormat, rather than a default GL_LUMINANCE (which will probably be interpreted as GL_LUMINANCE8). I advise using at least GL_LUMINANCE16 to keep precision if your hardware supports it. Otherwise the x16 in shader will amplify precision errors.


  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6

    Re: Question on using short CT data create texture

    Thank you ZBuffeR.

    And I want ask, after I setting the negative values to 0.

    Then I create Short texture and UShort texture with GL_LUMINANCE16.

    Then I doing the sampling in GLSL, the value at the same coordinate will be same or, the value in Short Texture will be 2 times as in UShort texture?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,580
    Sorry I can seem to parse your question.
    Short or ushort only differs of interpretation of large values as negative or not.
    Say you enter 0x00FF as short value in the data, it will come out in the GLSL shader as 255/65636 = 0.003885... something.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6
    Hi, ZbuffeR. Are you sure of that? Because I think the maximum value of a short should be 32767.

    If the GL_SHORT and GL_UNSIGNED_SHORT are totally same, why they need 2 symbols.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    GL_UNSIGNED_SHORT means values in the range [0, 65535] which will be normalized to the range [0.0,1.0] (0 -> 0.0, 65535 -> 1.0).
    GL_SHORT means values in the range [-32768, 32767] which in your case will be normalized to the range [0.0,1.0] but every negative value will be clamped to zero (0 -> 0.0, 32767 -> 1.0). If you use a signed texture internal format then you can use the negative values too, but not with GL_LUMINANCE.

    As a side note: GL_LUMINANCE is deprecated, use GL_RED and sized internal formats like GL_R8 and use ARB_texture_swizzle to map the single red channel to the others (i.e. swizzle as (R, R, R, 1)).
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  7. #7
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6
    Thank you very much!

    I won't use the negative value, so let them clamped to 0 with GL_LUMINANCE16 is the best way for me.

Posting Permissions

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