天天看點

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.

   指定比較值

繼續閱讀