#glsl函数之纹理函数
texture2D
Retrieves texels from a texture
vec4 texture2D(sampler2D sampler, vec2 coord)
vec4 texture2D(sampler2D sampler, vec2 coord, float bias)
Parameters
sampler specifies the sampler to which the texture from which texels will be retrieved is bound.
coord specifies the texture coordinates at which texture will be sampled.
bias specifies an optional bias to be applied during level-of-detail computation.
Description
The texture2D function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type sampler2D and one input parameter of the type vec2 : sampler, the uniform the texture is bound to, and coord, the 2-dimensional coordinates of the texel to look up.
<

本文详细介绍了OpenGL Shading Language (GLSL)中的纹理函数texture2D和textureCube,包括它们的参数、用途以及如何在计算中应用偏移量。通过这两个函数,开发者可以从纹理中检索颜色值,适用于2D和立方体贴图操作。
最低0.47元/天 解锁文章
1633

被折叠的 条评论
为什么被折叠?



