I'm just trying to write wavefront files loader in c++. I followed the tutorial at www.opengl-tutorial.org. It doesn't say how to handle mtl files, so I decided to do it myself. I know that Kd is responsible for the color of the diffuse property. On the other hand, map_Kd is responsible for the texture that describes this property. There is always Kd in the mtl file and could be map_Kd. My file look like this:
.
.
.
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd cubetex.bmp
.
.
.
Should I multiply the values of map_Kd by Kd? Or should I only use map_Kd?
EDIT:
Here's my fragment shader:
#version 430 core
in vec2 uv;
in vec3 Position_worldspace;
in vec3 Normal_cameraspace;
in vec3 EyeDirection_cameraspace;
in vec3 LightDirection_cameraspace;
out vec3 color;
uniform sampler2D tex;
uniform vec3 LightPosition_worldspace;
void main()
{
vec3 LightColor = vec3(1,1,1);
float LightPower = 50.0f;
vec3 MaterialDiffuseColor = texture( tex, uv ).rgb;
vec3 MaterialAmbientColor = vec3(0.1,0.1,0.1) * MaterialDiffuseColor;
vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3);
float distance = length( LightPosition_worldspace - Position_worldspace );
vec3 n = normalize( Normal_cameraspace );
vec3 l = normalize( LightDirection_cameraspace );
float cosTheta = clamp( dot( n,l ), 0,1 );
vec3 E = normalize(EyeDirection_cameraspace);
vec3 R = reflect(-l,n);
float cosAlpha = clamp( dot( E,R ), 0,1 );
color = MaterialAmbientColor + MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance*distance) + MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance*distance);
}
I don't know how to compute MaterialDiffuseColor