View Full Version : lighting performance

04-27-2009, 02:30 AM
Hi all, we are developing a game application and we are facing "strange" result with the lighting...
We have modeled everithing using Display list and
basically when we enable lighting we get a decrease of around 40% in the frame rate....
We are using an Intel core with Intel GPU.

Can anyone help us?
Many thanks in advance Francesco.

04-27-2009, 04:55 AM
Without more precisions it will be hard to help you.
Explain how you compute the scene lighting which is one of the heaviest computation in computer graphics, so your frame rate drop does not mean anything...

04-27-2009, 09:05 AM
If you render in FFP and you have more than 8 lights GL may fall back to software rendering.

04-28-2009, 12:49 AM
This is our lighting and materials model.

Our application is structured in this manner: the file model.cpp contains the geometry model and the file scene.cpp contains the rendering function.
In the model file (model.cpp) we specify materials as global arrays, then we put together with vertexes position, normals in a display list.
In the render scene file (scene.cpp) we activate light (glEnable(GL_LIGHTING)) and specify a single global light

float lightDir[] = {0.0f, 0.0f, 10.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightDir);

Each time we redraw the scene we call the GLCallList(ObjectList).
The animation consist of redrawing the whole scene with a frame rate of 20 frame/sec

an example of (file model.cpp)

GLfloat white_plastic_ambient[] =
{0.33, 0.22, 0.03, 1.0}, white_plastic_diffuse[] =
{0.50, 0.50, 0.50, 1.0}, white_plastic_specular[] =
{0.90, 0.90, 0.80, 1.0}, white_plastic_shininess[] = {60.0};

ObjectModel :: ObjectModel(){

//[....code omitted...]

glNewList(ObjectList, GL_COMPILE);
glLightfv(GL_LIGHT0, GL_AMBIENT, white_plastic_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, white_plastic_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, white_plastic_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, white_plastic_shininess);

glRotated(72, 1.0, 0.0, 0.0);
glRotated(90, 0.0, 1.0, 0.0);


for (int i = 0; i < numSectors; ++i) {
double angle1 = (i * 2 * Pi) / numSectors;
GLdouble x5 = alpha_1 * sin(angle1);
GLdouble y5 = alpha_1 * cos(angle1);
GLdouble x6 = alpha_2 * sin(angle1);
GLdouble y6 = alpha_2 * cos(angle1);

double angle2 = ((i + 1) * 2 * Pi) / numSectors;
GLdouble x7 = alpha_2 * sin(angle2);
GLdouble y7 = alpha_2 * cos(angle2);
GLdouble x8 = alpha_1 * sin(angle2);
GLdouble y8 = alpha_1 * cos(angle2);

quad(x8, y8, x7, y7, x6, y6, x5, y5); // Function for calculate our model.



} // end of the constructor

Many thanks, Francesco.