I’ve been working on the game engine for a month now, and I have completed the basic OpenGL material. However, one thing I can’t work with as I expect is lighting. (Note: this is the first time I've seriously worked with OpenGL)
What I want is proximity to realistic lighting modeling, where surfaces facing the light are illuminated more than those further away, etc. The main light should have position and color. Here's how I thought it could be implemented:
float lightv[4];
float positionv[4];
int lightID = GL_LIGHT0;
int attenuationType = GL_LINEAR_ATTENUATION;
float attenuationValue = 1;
glLightf(lightID, attenuationType, attenuationValue);
glLightfv(lightID, GL_DIFFUSE, lightv);
glLightfv(lightID, GL_POSITION, positionv);
glEnable(lightID);
Instead of doing what I expect from it, it gives me lighting, as if there was a light where the camera is! Each surface has the same lighting!
What am I doing wrong?
Thanks, I appreciate it.