View Full Version : Lamp, or sun, or moon, or spot light: How to draw?
04-06-2004, 12:47 AM
OpenGL:Lamp, sun, spotlight?
Does anyone know of any tutorial that teaches how to draw, using OpenGL, spot lights (or lamps, or moon or sun)that shine on regions or objects to illuminate them?
Basically, I need to render a realistic light source with the rest of the scene.
Pls advice if you know any method or tutorial.
04-06-2004, 03:04 AM
draw a sphere and give it a material with some emissive color, ie glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color). This will not make it emit light, but will make it look correct after you make it emit light. Now place a light at the center of your sphere, and it will look like it is lighting everything up. Thats the best way I can think of, just make sure your other objects are sufficiently tesselated and to remove the emissive color when you are done with the lamp/sun/whatever.
04-06-2004, 04:29 PM
I'll try it out!
There's one part I do not really understand about your reply, which is about tessallation. In layman's terms, can you tell me what is that?
04-06-2004, 04:34 PM
I'll explain what I meant by it. Opengl lighting is per vextex, so if your planets are just squares they won't look very good if you put a sun in the middle. People expect a nice gradient but with only 4 vertices you generally get something that doens't look very nice. This is especially obvious when you point an opengl spotlight at a single quad. Instead of getting a flashlight pattern you get nothing because the vertices are outside of the cone. Tesselation means that you split single polygons into many, in this case you do it to drastically improve lighting.
04-06-2004, 04:49 PM
oh, ok.. So with tessalation, the number of normal vectors will increase, and hence you can make the effect of the light source on the object more realistic,right?
but if I were to do it, I will probably do it manually, meaning to say I will just draw out each and every small region of the object, doing something like this:
so all the triangles will make up the object, and I have to add in individual normals to each triangle.
Is that correct? Or is there a short cut??
Thanks once again!!
04-06-2004, 05:02 PM
yes, but even a perfectly flat surfaace needs to be tessalated to look good with opengl lighting. There is a glu tesselation function but I have no idea how it works, you would have to look it up. Most people use modeling software to make anything complicated and import the model
04-06-2004, 05:07 PM
ok, thanks for the prompt reply, will try to look up the glu tessalation!!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.