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.
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?
A texture is an OpenGL Object that contains one or more images that all have the same image format. A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.
A sampler is a set of GLSL variable types. Variables of one of the sampler types must be uniforms or as function parameters. Each sampler in a program represents a single texture of a particular texture type. The type of the sampler corresponds to the type of the texture that can be used by that sampler.
gl_FragColor is the principal variable that your fragment shader is designed to change. If your code does not assign a value to it then it is left undefined for the rest of the pipeline. gl_FragData is an array of data that can be used by the rest of the pipeline.
The OpenGL Shading Language (GLSL) is the principal shading language for OpenGL. While, thanks to OpenGL Extensions, there are several shading languages available for use in OpenGL, GLSL (and SPIR-V) are supported directly by OpenGL without extensions. GLSL is a C-style language.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With