openGL之API学习(三十五)texture和texture2D

纹理采样函数

texture2D() is deprecated as of (at least) OpenGL 3.3; see page 99 of the 3.30 GLSL specification. It will continue to be supported in OpenGL compatibility profiles to avoid breaking existing code, but its usage in new code is strongly discouraged.

Between glsl 120 and 130 they changed the function to texture and made it accept every kind of samplers, not just a sampler2D.

EDIT: The details are slightly different for OpenGL ES, but the end result is the same: texture2D() was deprecated and replaced by texture() in OpenGL ES 3.0; see section 8.8 of the 3.0 GLSL ES specification.

 

gvec4 texture(     gsampler1D sampler,
      float P,
      [float bias]);
 
gvec4 texture(     gsampler2D sampler,
      vec2 P,
      [float bias]);
 
gvec4 texture(     gsampler3D sampler,
      vec3 P,
      [float bias]);
 
gvec4 texture(     gsamplerCube sampler,
      vec3 P,
      [float bias]);
 
float texture(     sampler1DShadow sampler,
      vec3 P,
      [float bias]);
 
float texture(     sampler2DShadow sampler,
      vec3 P,
      [float bias]);
 
float texture(     samplerCubeShadow sampler,
      vec4 P,
      [float bias]);
 
gvec4 texture(     gsampler1DArray sampler,
      vec2 P,
      [float bias]);
 
gvec4 texture(     gsampler2DArray sampler,
      vec3 P,
      [float bias]);
 
gvec4 texture(     gsamplerCubeArray sampler,
      vec4 P,
      [float bias]);
 
float texture(     sampler1DArrayShadow sampler,
      vec3 P,
      [float bias]);
 
float texture(     gsampler2DArrayShadow sampler,
      vec4 P,
      [float bias]);
 
gvec4 texture(     gsampler2DRect sampler,
      vec2 P);
 
float texture(     sampler2DRectShadow sampler,
      vec3 P);
 
float texture(     gsamplerCubeArrayShadow sampler,
      vec4 P,
      float compare);

 

sampler

    Specifies the sampler to which the texture from which texels will be retrieved is bound.

    指定要从哪个纹理单元采样
P

    Specifies the texture coordinates at which texture will be sampled.

    采样点的纹理坐标
bias

    Specifies an optional bias to be applied during level-of-detail computation.

   指定lod的层级,在此层级上进行采样。该层级的lod与原图存在计算关系
compare

    Specifies the value to which the fetched texel will be compared when sampling from gsamplerCubeArrayShadow.

   指定比较值

 

 

 

 

你可能感兴趣的:(opengl,图形学,着色器)