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

Thread: Sampler variable for SNORM textures

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    Sampler variable for SNORM textures

    What will be the fragment shader for SNORM textures? If i want to use GL_TEXTURE_2D_ARRAY as a target then which type of sampler variable should be used (i,u) ?

    I am getting enuexpected behaviour with following fragment shader:

    Code :
     in vec3 ps_texCoord;
        uniform sampler2DArray tk_diffuseMap;
        out vec4 fragColor;
        void main()
        {
         fragColor = texture(tk_diffuseMap, ps_texCoord);
         }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    You have only three options for generic sampers: floating point, signed and unsigned. Each sampler type is either not prefixed (float), prefixed with i (integer) or u (unsigned integer). Having never used SNORM internal formats to this day, I can only judge from the GLSL spec which states that normalized integers can be retrieved with a floating-point sampler.

    What is it you expect your shader to put out? Are you aware how the texture() family of functions work and what the arguments mean and what the expected return values are?

    Reading the GLSL spec, I find that it does only mention unsigned normalized integers which I don't think was intended. Otherwise this would imply SNORM textures aren't supposed to be accessible from a shader which defeats the purpose of having such internal formats.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    I am using GL_byte as texture data type alongwith "sampler2DArray" variable. I tried with "isampler" variable too but did not get expected o/p.
    just want to know which data type and sampler type will be accurate for SNORM textures.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    As I said, floating-point samplers should work fine. What result do you expect and what result do you get? GL_BYTE denotes a signed integral type just like GL_SHORT or GL_INT - so as far as GLSL is concerned, there shouldn't be a difference if your internal format is one of the SNORM formats. Are your tex coords correct? Do you get any GL errors?

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    I checked for GL_ERROR also verified my texcords. It works fine when i use GL_RGBA instead of snorm textures so their is problem with shader only.

    There is difference in the intensity of color values when i use snorm textures. In case of gl_byte, it applies texture when value is 127 and if its < 127, it takes black.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Sorry it was driver bug. It works perfectly with GL_byte and "sampler"

Posting Permissions

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