Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to get lighting effects on a textured object; I'm using .obj and .mtl files to define them. No matter what I try my object is either invisible, unlit (plain texture), or completely white.

I defined my mtl by having my texture mapped to diffusion (that is, map_Kd texture.png). I found that if I don't set both a Ka and Kd (in addition to the texture) the object is invisible. Also, it seems that the actual ambient values don't change anything - they could be 0 and transparent, as long as they're defined.

If I set my material to have white ambient, diffuse, and specular, then the object is 100% white, no matter what I do with my light source. This is also after I set it to gl_separate_specular_color, as before that, I just got the plain texture. I tried making sure I had a normal defined for at least one face of the model, with no luck. I'm trying to have my texture be dominant, with a little bit of specular lighting on it.

What am I doing wrong? Is the lighting "working" but the all white means I haven't set my shininess properly? Is it being infinitely reflective or something?

Note: I'm using OpenTK and working in C#.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I figured out that my problem was twofold. One, I didn't have enough normals defined. Two, I was using flat shading. With only one normal to go on, all the faces were using the same normal for shading, hence they all reflected light in exactly the same way. So my model was a uniform color. Adding more normals and using smooth shading made it look nice.

share|improve this answer

I don't know if the above method works for you, but I had the same problem; I found that I had not specified the normals of the object. So to solve it, just specify the normals before drawing the textures. For example:

//specify normals 

//front face of cube

glNormal3f(0.0, 0.0, 1.0);

glVertex3f(-1.0, 1.0, 1.0);

glVertex3f(1.0, 1.0, 1.0);

glVertex3f(1.0, -1.0, 1.0);

glVertex3f(-1.0, -1.0, 1.0);

Hopefully this will solve the problem for anyone (I tried every other method that I could find, but only this method worked).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.