GLSL中的Texture vs Texture2D [英] texture vs texture2D in GLSL

查看:466
本文介绍了GLSL中的Texture vs Texture2D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GLSL中对2D纹理进行采样(a uniform sampler2D)时,将使用texture函数,并从采样器(在这种情况下为2D)推断尺寸.从1.30开始,这是在GLSL中对纹理进行采样的现代方法( GLSL参考页 ).但是,您也可以使用texture2D函数.

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). This is the modern way of sampling a texture in the GLSL since 1.30 (GLSL Reference Pages). However you can also use the texture2D function.

texture2D函数是否已被弃用,如果是,则在某些版本的GLSL中是否会删除(或已删除)对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?

推荐答案

是的,自(至少)OpenGL 3.3起,不推荐使用texture2D().请参见 3.30 GLSL规范的第99页. OpenGL兼容性配置文件将继续支持它,以避免破坏现有代码,但强烈建议不要在新代码中使用它.

Yes, 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.

编辑:OpenGL ES的详细信息略有不同,但最终结果是相同的:OpenGL ES 3.0中不推荐使用texture2D()并由texture()替换;请参见 3.0 GLSL ES规范的第8.8节.

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.

这篇关于GLSL中的Texture vs Texture2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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