简体   繁体   English

GLSL 中的纹理与纹理 2D

[英]texture vs texture2D in GLSL

When sampling a 2D texture in GLSL (a uniform sampler2D ), the texture function is used and the dimension is inferred from the sampler (2D in this case).在 GLSL( uniform sampler2D )中对 2D 纹理进行采样时,将使用texture函数并从采样器(在本例中为 2D)推断维度。 This is the modern way of sampling a texture in the GLSL since 1.30 ( GLSL Reference Pages ).这是自 1.30 以来在 GLSL 中采样纹理的现代方式( GLSL 参考页面)。 However you can also use the texture2D function.但是,您也可以使用texture2D函数。

Is the texture2D function deprecated and if so, will support for the texture2D function be removed (or has been removed) in some version of GLSL?是否不推荐使用texture2D函数,如果是,是否会在某些版本的 GLSL 中删除(或已删除)对texture2D函数的支持?

Yes, texture2D() is deprecated as of (at least) OpenGL 3.3;是的, texture2D()从(至少)OpenGL 3.3 开始被弃用; see page 99 of the3.30 GLSL specification .请参阅3.30 GLSL 规范的第 99 页。 It will continue to be supported in OpenGL compatibility profiles to avoid breaking existing code, but its usage in new code is strongly discouraged. OpenGL 兼容性配置文件将继续支持它以避免破坏现有代码,但强烈建议不要在新代码中使用它。

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;编辑:OpenGL ES 的细节略有不同,但最终结果是相同的:在 OpenGL ES 3.0 中, texture2D()已被弃用并替换为texture() see section 8.8 of the 3.0 GLSL ES specification .请参阅3.0 GLSL ES 规范的第 8.8 节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM