Hello Guest

Help with OpenGL Uv Coordonates

  • 0 Replies
  • 2922 Views
Help with OpenGL Uv Coordonates
« on: December 02, 2020, 23:01:50 »
I succeeded import meshes, but the UV are very weird. Look how it applies a dirt texture to suzane:


And look how it should apply:

(Don't ask me why do I want a dirt textured monkey)

If the model loading works(vertices), the uvs should work too because they are using the same algorithm. Plus, the uvs are exported in obj file from blender with triangulated faces.
That's how shader process the uvs from obj:
vertexshader:
Code: [Select]
layout(location = 1) in vec2 vertexUV;void main(){
gl_Position = Proj * View * Model * vec4(vertexPosition_modelspace,1);
  UV = vertexUV;

}


fragmentshader
Code: [Select]

in vec2 UV;
out vec4 color;

uniform sampler2D myTextureSampler;


void main(){
color = texture( myTextureSampler, UV ).rgba;


}