Hello all,
I have 2 problems that are probably being caused by the same thing so i decided to make one thread about it. For starters, I’m using a ported openGL implementation called PSPGL (for sony psp) so this problem may just be the lib.
Moving on, specular lighting doesnt work at all. i have modeled my object in a freeware program called Anim8or. It has a simple material interface like so:
As you can see, its all here: ambient, diffuse, specular, emission, roughness (which is GL_SHININESS), and brilliance (which im not implementing)
glMaterialfv(GL_FRONT, GL_AMBIENT, &ambient[0]);
glMaterialfv(GL_FRONT, GL_DIFFUSE, &diffuse[0]);
glMaterialfv(GL_FRONT, GL_SPECULAR, &specular[0]);
glMaterialfv(GL_FRONT, GL_EMISSION, &emissive[0]);
glMaterialf(GL_FRONT, GL_SHININESS, &Roughness);
Here im setting all the components, each array above has R,G,B,A components in the form of GLfloat. Roughness is of course a GLint.
Here is my light source:
static light light0 = {
{0.2f, 0.2f, 0.2f, 1.0f}, // ambient
{1.0f, 1.0f, 1.0f, 1.0f}, // diffuse
{1.0f, 1.0f, 1.0f, 1.0f}, // specular
{1.0f, 0.5f, 1.0f, 0.0f}, // position
};
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0.ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0.diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light0.specular);
glLightfv(GL_LIGHT0, GL_POSITION, light0.position);
Which leads me to my inquiry, WHY ISNT SPECULAR WORKING?
Now that you know the basic material setting code (the first code block) you may help with the second problem.
I have a grass texture, and a water texture. I have a grass material (uses grass texture), water material (uses water texture), and a metal material (uses NO texture). However, it seems as though the metal material inherits the ambient color of the previous material. When i switch to the metal material from grass, it is green, when i switch from water, it is blue! its apparent that im setting the ambient color… so i dont know why its happening.
The metal material is the reason for the specular issue, as it relys heavily on it.
Sorry for the verboseness of this request.