LWJGL Forum

Programming => OpenGL => Topic started by: Mihai_Ionut_Floares on December 02, 2020, 23:01:50

Title: Help with OpenGL Uv Coordonates
Post by: Mihai_Ionut_Floares 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:
(https://img.imageupload.net/2020/12/02/New-Project-3.png)

And look how it should apply:
(https://img.imageupload.net/2020/12/02/New-Project-4.png)
(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;


}