I am compiling this shader with glslangValidator, and am using OpenGL 4.3 Core Profile with the extension GL_ARB_gl_spirv, and using the GLAD webservice to generate function pointers to access the Core OpenGL API, and SDL2 to create the context, if that is of any use.
If I have a fragment shader like so:
#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);
}
How would I be able to set which texture unit inTexture
uses?
From what I have read online through documents, I cannot use glGetUniformLocation
to get the location of this uniform to use in glUniform1i
, because of the fact I am using SPIR-V, instead of GLSL directly.
What would I need to do to set it in a fashion like glUniform1i
? Do I need to set the location
in the layout modifier? The binding
? I've tried to use Uniform Buffer Objects, but apparently sampler2D
can only be a uniform.
layout(binding = 1) uniform sampler2D inTexture;
– D-RAJsampler2D
from my main program? – KapowCabbage1
intoglUniform
? – KapowCabbageglUniform1i
even though i'm not 100% sure about it. From what i do know, its not an easy task to use SPIR-V to work with OpenGL. – D-RAJglUniform1i
. Thanks for your help. – KapowCabbage