Hello everyone!
So I am having an issue with UBOs, to be more precise with binding them to the correct Uniform Block inside the shader.
First a few things about what I have checked:
The binding seems to be consistent with what I have defined with glUniformBlockBinding (I also tested it with shader binding and it also exposes the correct values) - I tested this via RenderDoc and
glGetActiveUniformBlockiv(shader_handle, program_resource_index, GL_UNIFORM_BLOCK_BINDING, &binding);
if I call
glBindBufferBase(GL_UNIFORM_BUFFER, binding, ubo_handle)
it does not bind to anything unless binding happens to equal an index of an uniform block. So now I obviously could use glBindBufferBase to just bind to every shader inside the system, but I specifically wanted to implement UBOs in order to reduce the Uniform write operations.
To go over the exact procedure: I compile and link the programs, use glUniformBlockBinding as “post-build-event”, then assemble the scene (this includes creating the UBOs and putting data in them) and then I render while swapping UBO when needed.
Lets assume I have a Shader with the following Uniform Blocks:
Light - index: 0 - binding: 1
Camera - index: 1 - binding: 10
Material - index: 2 - binding: 0
so I would expect that if I
GLuint ubo_handle = 123; //lets assume this handle is valid
glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo_handle)
, the light would now take the data from that ubo, instead what happens is that Camera now takes the data from this ubo 123.
I am using glfw 3.1.2 Win32 and glew 2.1.0, this is vendor independant and happens on multiple Windows OS, OpenGL 4.0 and GL_ARB_shading_language_420pack is available.
As essential values inside the shaders stay undefined I see my defined clear color instead of anything.