我正在使用 glslangValidator 编译此着色器,并使用带有扩展名 GL_ARB_gl_spirv 的 OpenGL 4.3 Core Profile,并使用 GLAD Webservice 生成函数指针以访问 Core OpenGL API,并使用 SDL2 创建上下文(如果有任何用处)。
如果我有一个像这样的片段着色器:
#version 430 core
//output Fragment Color
layout (location = 0) out vec4 outFragColor;
//Texture coordinates passed from the vertex shader
layout (location = 0) in vec2 inTexCoord;
uniform sampler2D inTexture;
void main()
{
outFragColor = texture(inTexture, inTexCoord);
}
Run Code Online (Sandbox Code Playgroud)
我如何才能设置inTexture使用哪个纹理单元?
根据我在网上阅读的文档,我无法使用glGetUniformLocation来获取要在 中使用的制服的位置glUniform1i,因为我使用的是 SPIR-V,而不是直接使用 GLSL。
我需要做什么才能将其设置为类似的方式glUniform1i?location我需要在布局修饰符中设置吗?这binding?我尝试过使用统一缓冲区对象,但显然sampler2D只能是统一的。