# Combine material coefficients and textures in Phong Shading

I'm trying to implement a simple Phong shader that supports non-physically-based materials and textures. Even though the material has a texture for each light component I still want the respective material coefficient to have some effect. My doubt is how to handle both of them. Should I mix, multiply or sum them? Right now I've multiplied them:

ambient  = material.ambient_color  * light.ambient  * texture_ambient;
diffuse  = material.diffuse_color  * light.diffuse  * diffuse_strength  * texture_diffuse;
specular = material.specular_color * light.specular * specular_strength * texture_specular;


It seems kinda dark, is this the correct way to combine material coefficients and textures?

• that is the correct way. maybe darkness comes from not doing calculations in linear space? – Sebastián Mestre Jan 28 '18 at 20:42
• Have you tried increasing the light amounts? – user1118321 Jan 28 '18 at 21:24
• @SebastiánMestre What do you mean by linear space? I'm sorry, I'm new to this. – Daniel Marques Jan 28 '18 at 23:42
• @user1118321 No, I've been using only one light, a directional light. In my mind it should be enough and it shouldn't be as dark as it is. – Daniel Marques Jan 28 '18 at 23:43
• i mean linear colour space. images are usually gamma compressed and can give wrong results when using them in shading. they should first be gamma corrected. you can search what that means online. – Sebastián Mestre Jan 29 '18 at 0:18