So, to begin with a bit of backstory, I’m building a graphics engine for a game engine that I am making via following some youtube video series. Upon getting to use of texture arrays and being able to use multiple textures at once/batch rendering textures this error occured. Originally this error manifested as Nvoglv32.dll requiring Nvoglv32.pdb to debug. However, after checking my uniforms I managed to discover that the issue was due to one of them. But, this left me with the current crashing issue. I’m certain theres something wrong with the array of samplers I am trying to use, but I’m unsure. The program only crashes upon a specific line in the shader, removal of this allows me to render a none textured sprite manually quite happily.
Here are my shaders,
vertex:
#version 330 core
layout (location = 0) in vec4 position;
layout (location = 1) in vec2 uv;
layout (location = 2) in float tid;
layout (location = 3) in vec4 color;
uniform mat4 pr_matrix;
uniform mat4 vw_matrix = mat4(1.0);
uniform mat4 ml_matrix = mat4(1.0);
out DATA
{
vec4 position;
vec2 uv;
float tid;
vec4 color;
} vs_out;
void main()
{
gl_Position = pr_matrix * vw_matrix * ml_matrix * position;
vs_out.position = ml_matrix * position;
vs_out.uv = uv;
vs_out.tid = tid;
vs_out.color = color;
}
and fragment:
#version 330 core
layout (location = 0) out vec4 color;
uniform vec4 col;
uniform vec2 light_pos;
in DATA
{
vec4 position;
vec2 uv;
float tid;
vec4 color;
} fs_in;
uniform sampler2D textures[32];
void main()
{
float intensity = 1.0f / length(fs_in.position.xy - light_pos);
vec4 texColor = fs_in.color;
if(fs_in.tid > 0.0)
{
int tid = int(fs_in.tid + 0.5);
texColor = texture(textures[tid], fs_in.uv);
}
color = texColor * intensity;
//color = vec4(tid, 0, 0, 1) * intensity;
}
The exact line that the crash occurs is, texColor = texture(textures[tid], fs_in.uv);
As far as I can see the tid (texture ID) being passed in from my renderer is properly assigned to the textures that I’m trying to use. Using the tid value in the bottom color set also incurrs the same crash as trying to use the array of samplers. Any help into if I’m doing anything wrong would be greatly appreciated. Also, if I need to provide more code please say so.