与GLSL中的texture2D()和OpenGL中的glTexImage2D()相关的内部格式 [英] internal format related to texture2D() in GLSL and glTexImage2D() in OpenGL

查看:3803
本文介绍了与GLSL中的texture2D()和OpenGL中的glTexImage2D()相关的内部格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑与GLSL中的texture2D()和OpenGL中的glTexImage2D()相关的内部格式,当我使用(注意第三个第八参数):

  glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F_ARB,WINDOW_SIZE,WINDOW_SIZE ,0,GL_RGBA,
GL_FLOAT,floatDataPtr);

我得到了sampler2D的 nonclampedvalue glsl没有被钳位到[0,1]:

pre $ vec4 nonclampedvalue = texture2D(my16floattex2d,texcoord1);

当我使用时:

  glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,WINDOW_SIZE,WINDOW_SIZE,0,GL_RGBA,
GL_UNSIGNED_BYTE,byteDataPtr);

我得到了sampler2D的 clampedvalue glsl被钳位为[0,1]:

pre $ vec4 clampedvalue = texuture2D(myunsignedbytetex2d,texcoord2);

所以我的问题是这样的:


  1. 当调用glTexImage2D(夹紧或不夹紧)时,glsl将获得什么值:

      glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,WINDOW_SIZE,WINDOW_SIZE,0,GL_RGBA,
    GL_FLOAT,floatDataPtr);


  2. 当调用glTexImage2D时,我会得到什么样的值(夹紧或不夹紧):

    $ p $ lt; code> glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F_ARB,WINDOW_SIZE,WINDOW_SIZE,0,GL_RGBA,
    GL_UNSIGNED_BYTE,byteDataPtr) ;


  3. 由于我在OpenGL官网上找不到详细的信息,在调用glTexImage2D()时传递给纹理的数据返回不同的内部格式的sampler2D纹理以及不同的类型(如上面提到的GL_FLOAT或GL_UNSIGNED_BYTE)?什么是规则?


    有没有人可以帮忙?


    当调用glTexImage2D(夹紧或不夹紧)时,我将在glsl中获得什么值:


    这仅受内部格式参数一>。规范化的内部格式是...正常化。他们不存储浮点值;它们将整数值解释为浮点数。最大整数值为1.0,最小值为0.0(如果是SNORM格式,则为-1.0)。

    lockquote

    因为我找不到OpenGL官方网站上的详细信息

    下次看更难;它就在维基上。用于创建内部格式。 org / wiki / Textures#Texture_Objectsrel =nofollow>纹理和 renderbuffers 。它甚至解释了最后三个参数控制像素转换操作:将数据上传到图像。 p>

    I am confused with the internal format related to texture2D() in GLSL and glTexImage2D() in OpenGL, When I use(pay attention to the third and the eighth parameters):

    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA16F_ARB, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA, 
                GL_FLOAT, floatDataPtr);
    

    I got the nonclampedvalue of sampler2D in the glsl without clamped to [0, 1]:

    vec4 nonclampedvalue = texture2D(my16floattex2d, texcoord1);
    

    When I use:

    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA, 
                GL_UNSIGNED_BYTE, byteDataPtr);
    

    I got the clampedvalue of sampler2D in the glsl clamped to [0, 1]:

    vec4 clampedvalue = texuture2D(myunsignedbytetex2d, texcoord2);
    

    So my questions are this:

    1. What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):

      glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA, 
             GL_FLOAT, floatDataPtr);
      

    2. What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):

      glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA16F_ARB, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA,
              GL_UNSIGNED_BYTE, byteDataPtr);
      

    3. As I can't find the detailed information in OpenGL official website, What value will be return in the sampler2D texture with different internal format as well as different type(such as GL_FLOAT or GL_UNSIGNED_BYTE mentioned above) of the data passed to the texture when invoke the glTexImage2D()? what's all the rules?

    Does anyone can help?

    解决方案

    What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):

    This is governed only by the "internal format" parameter. Normalized internal formats are... normalized. They don't store floating point values; they store integer values which are interpreted as floats. The maximum integer value becomes 1.0 and the minimum becomes 0.0 (or -1.0 if it's an SNORM format).

    As I can't find the detailed information in OpenGL official website

    Look harder next time; it's right there on the Wiki. The "internal format" used for creating textures and renderbuffers. It even explains that the last three parameters govern pixel transfer operations: uploading data to the image.

    这篇关于与GLSL中的texture2D()和OpenGL中的glTexImage2D()相关的内部格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆