I’m trying to load this model. It has several meshes and several materials. Right now, I just want to load it’s diffuse texture.
However I’m getting this weird behavior.
I load Materials and load meshes function are basically the same as the Sascha Willems repo.
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout( push_constant ) uniform ColorBlock {
vec4 Diffuse;
vec4 Ambient;
vec4 Specular;
float opacity;
} PushConstant;
layout(set =2, binding = 0) uniform UniformBufferObject {
vec3 lightPos;
vec3 eyePos;
vec3 ambient;
vec3 specular;
} LightUbo;
layout(set = 1,binding = 1) uniform sampler2D texSampler;
layout(location = 1) in vec2 fragTexCoord;
layout(location = 2) in vec3 Normals;
layout(location = 3) in vec3 fragPos;
layout(location = 0) in vec3 fragColor;
layout(location = 0) out vec4 outColor;
vec3 lighting(){
vec3 texture = vec3(texture(texSampler,fragTexCoord));
vec3 LightDir = normalize(LightUbo.lightPos-fragPos);
//diffuse
float diff = max(dot(Normals,LightDir),0.0);
vec3 reflectDir = reflect(-LightDir,Normals);
float spec = pow(max(dot(LightUbo.eyePos,reflectDir),0.0),4);
vec3 ambient = LightUbo.ambient * texture * PushConstant.Ambient.xyz;
vec3 diffuse = texture * PushConstant.Diffuse.xyz ;
vec3 specular = LightUbo.specular *texture *PushConstant.Specular.xyz;
return (ambient+diffuse+specular);
}
void main() {
outColor = vec4(lighting(),1.0);
}