PDA

View Full Version : lighting in OpenGL



IlovePascal
22-08-2007, 12:07 PM
Hi all,

I have by now learnt a lot about OpenGL and have started making complex models (tanks, planes, blah blah, the ordinary stuff), and I realise how important lighting is.

I have read a couple of tutorials and after many tries i have grasped the basics of making a light source and giving it ambient, diffuse and the other type of lighting which i can´t remember lol.

I realise how much of an art it is to be able to place each light source to give a good view of the model and give the game it´s in some mood.

What I would like to ask, is for advice on how to do exactly that.
From experience, what are the important things to look out for?
How should I use each type of lighting?
How do I make reflections on a surface or change the ´reflectivity´ of a surface?

And most important, it seems like opengl allows you to make up to 9 light sources called LIGHT0,LIGHT1,LIGHT2...LIGHT8, right?
But if I want to make more than that? I was thinking about a light for each unit in my game, to give it colour and shininess, so what if i have 50 units?

thank you all for you help!
cheers

Robert Kosek
22-08-2007, 01:13 PM
Therein lies the magic. ;) You can only display 8 lights at a time, but no one said you couldn't have as many as you want. You just have to manage which lights are visible at what time.

It is, perhaps, possible to fake additional lights if they are required. But 8 lights is actually a lot of lights, so give it a shot first and see the results. You might be pleasantly surprised what you can do with that number.

Huehnerschaender
22-08-2007, 02:09 PM
Using more than 8 lights does not make any sense in my eyes...

Try thinking the following way:

Position red light above unit 1.
render unit 1
Position red light above unit 2.
render unit 2
Position red light above unit 3.
render unit 3
Position red light above unit 4.
render unit 4
Position red light above unit 5.
render unit 5
Change Color of red light to green
Position green light above unit 6.
render unit 6


So for rendering these 6 units with every unit having a light on its top, 5 of them red and one green, you only need ONE light source...


You will only need more than one if a single model should be lightened from different sides at once... like a tank which is lightened by ambient light and a spotlight at once...

Now what do you think a model will look like when its lightened by more than 8 lights? :)

IlovePascal
23-08-2007, 06:37 PM
You will only need more than one if a single model should be lightened from different sides at once... like a tank which is lightened by ambient light and a spotlight at once...

Now what do you think a model will look like when its lightened by more than 8 lights? :)

lol
I get it, thanks. Of course, I hadn´t thought that the light was only needed to be placed just before rendering, and could be moved afterwards! But of course it makes sense!

cheers