Hello. I render a cube. The texture is a pure blue color.
In the fragment shader, I set the following condition to control the quality of the texturing.
But instead of an expected pattern (reference to the screenshot), I get something strange.
I also checked the uv-coordinate input, it seems to be correct, every 3 uv-pairs(x,y) form a triangle.
There are 36x2 uv pairs that seems to be correct. The model is generated in blender.
The error seem to be about memory etc.
#version 430 core
in vec2 TexCoords;
layout (binding=0) uniform sampler2DArray textureArray;
//layout (location=1) uniform int layer;
out vec4 color;
void main(void)
{
color = vec4(texture2DArray(textureArray, vec3(TexCoords.xy, 0.0f)));
if((TexCoords.x >= 0.1f) && (TexCoords.x <= 0.9f))
{
if((TexCoords.y >= 0.1f) && (TexCoords.y <= 0.9f))
{
color = vec4(1.0f,1.0f,1.0f,1.0f);
}
}
}
The UV-coordinates are loaded this way:
// texture_coordinate
glGenBuffers(1, &obj.glbuffers[UV_BUFFER]);
glBindBuffer(GL_ARRAY_BUFFER, obj.glbuffers[UV_BUFFER]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLfloat)*obj.uv_coordinates.size(),
&obj.uv_coordinates[0],
GL_STATIC_DRAW);
glVertexAttribPointer(5, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(5);
[ATTACH=CONFIG]1772[/ATTACH]