Then you’re looking in the wrong place. If you’re trying to learn OpenGL, you should be looking at OpenGL learning materials. That GLSL is intended for Vulkan, so if you’re trying to learn OpenGL, you’re looking at the wrong code.
If you’re using C++, and you see
SomeTypeName(...), what you’re seeing is a constructor call that creates a temporary object of type
SomeTypeName, passing in
... as the arguments to the constructor.
This is exactly what
sampler2D is doing here.
To fetch data from a texture requires two things: the image data to be used by operation, and a set of sampling parameters that define how the data will be fetched. In Vulkan these are (or can be) separate objects, so Vulkan-flavoured GLSL incorporates them as two distinct types.
texture* types represent the various kinds of image views, and
sampler represents the sampling parameters.
However, OpenGL didn’t work that way. In OpenGL texture objects texture objects have sampling parameters built into them. As such, every texture is essentially a sampler object. Because GLSL was built in accord with OpenGL, the GLSL types that correspond to OpenGL textures don’t give these distinct concepts. Thus,
sampler2D is a type that represents both a view of an image and its sampling parameters; it represents an OpenGL texture object.
This means that all of GLSL’s texture functions expect you to provide a
sampler* type. Therefore, Vulkan-flavoured GLSL requires that, if you’re using separate texture and sampler data, you must create a
sampler* object to combine these two in order to fetch from a texture. That’s what the
sampler2D(...) constructor call is doing: it’s creating a sampler value from a texture and a set of sampling parameters.