I'm trying to apply the default badlogic.jpg image to a .obj I have. I'm currently loading the texture from AssetManager
and creating a material with a texture attribute (as a diffuse).
In my fragment shader, I try to get the texture value and output it but it just results in a solid black. I outputted v_texCoord
(as a vec4) and I could see different colors that resemble what they should be (which should mean that the texture coordinates are correct). But yet
I still get a solid black color.
I don't understand why the texture is not coming through. Am I missing something?
Code:
/.../
model = assetManager.get("mesh/Sting-Sword-lowpoly.obj", Model::class.java)
texture = assetManager.get("badlogic.jpg", Texture::class.java)
val m = ModelInstance(model)
val mat = Material()
mat.set(TextureAttribute.createDiffuse(texture))
m.materials[0] = mat
/.../
Vertex Shader:
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord0;
uniform mat4 u_projViewWorldTrans;
uniform sampler2D u_diffuseTexture;
varying vec3 v_normal;
varying vec2 v_texCoord;
void main()
{
v_texCoord = a_texCoord0;
v_normal = normalize(a_normal);
gl_Position = u_projViewWorldTrans * vec4(a_position, 1.0);
}
Fragment Shader:
uniform sampler2D u_diffuseTexture;
varying vec2 v_texCoord;
void main()
{
//Get color
vec4 color = texture(u_diffuseTexture, v_texCoord);
gl_FragColor = color;
}