View Full Version : How to simulate light?
I want to implement a drive simulation using OpenGL. In the application , headlight, streetlight and time changing are all needed. How to implement these effects at the same time just like in game "Need For Speed".
Can anyone give me some ideas?
Thank u very much!
Sorry for my poor English.
04-04-2002, 12:04 AM
Why do you want to 'simulate' the light ? With OpenGL you can get a true, dynamic light ! You should look for some tutorials, for example have a look at http://nehe.gamedev.net
If you're new to opengl, it might be a good idea to get the 'opengl superbible' book.
I don't know need for speed well enough to see what you're talking about, but all you need to achieve reasonnable lighting in a game is available in openGL: colored lights, material properties, lights at infinity (like the sun), spotlights, and up to 8 lights lighting the same triangle in only one pass. All that you hardware can do is available through opengl.
But there are some problems when using OpenGL true lights.
1.When using true spotlights, if two vertex of a triangle are out of frustum, the triangle will not be lighted.
2.when more than 8 lights are needed in a scene(such as in a channel), OpenGL can't satisfy.
I implement time changing using OpenGL infinity light as the sun. It works well.
And I implement a headlight by add a dynamic spotlight in scene. Because of problem 1 ,the headlight doesn't work well. Some triangles in scene can't be lighted.
I know multi-texture and light map can be used to simulate light and vertex coloring can be used to simulate light also. But I don't know how to use these methods to simulate a headlight and how to let them work with OpenGL true lights(like the sun) at the same time.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.