In GL Shader language spec 4.6 texture2D is an opaque type listed in section 4.1 , but it not appeared in the grammar section (chapter 9). I’ve tried to use it in real shader source, it can’t compile. What I’ve missed ? Is it in fact replaced by image2D? Many thanks!
texture2D only exists when compiling GLSL to SPIR-V targeting Vulkan. In Vulkan-GLSL, your shader can access a texture that has no sampler data coupled to it. You can provide sampler parameters separately from a texture in OpenGL, but associating the texture with the sampler object happens outside of GLSL. In Vulkan, a texture can be associated with a sampler inside the shader, which is why the type
sampler also exists in Vulkan-GLSL.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.