View Full Version : Lighting is confusing...
K A Z E
12-24-2005, 08:22 PM
Could someone explain lighting in detail? I've tried experimenting with it but it still puzzles me. I got a 3D room that I can walk around and I've tried things like only setting the diffuse or only setting the ambient. But it looks so much alike I can't really tell a difference. When I have them both enabled the room is lighter. Also, when I enable color material and set the shininess to 128 and the spectral to 1.0f, 1.0f, 1.0f it's almost as bright as when the lighting is disabled. So could someone tell me in detail what diffuse, spectral, and ambient do, and color material. And I read in a tutorial that if I don't specify a position it becomes a "directional" light. What exactly does that mean? And the tutorial did this:
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 10.0f);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 75.0f);
to make the light a spotlight. I'm guessing the cutoff has to do with how far away an object can be before it will get dimmer or something. But I got no clue what the exponent is. Could someone also explain that? Thanks in advance.
12-25-2005, 01:27 AM
The major difference between the ambient and diffuse parameters is that the ambient light is not depend on the object vectors, but the diffuse light is. So if you specify an ambient color in your light, you actually add some lights to all the aspects of your objects. It's like a general light. But the diffuse color is depend on the object vectors. Let's give an example:
Assume that we have a cube in a room. We insert many lights around the cube. So all the aspects of the cube will be shined with these lights. It's an ambient light.So the ambient light adds a light to all aspects of your object and is not depend on the vector of the object. Now we insert one light in the room-- With a specified color. Only some parts of the cube will recieve this light. It's a diffuce light. So the diffuse light adds a light to some parts of your object and is depend on the object vetors.
Merry christmas & Happy new year.
K A Z E
12-25-2005, 05:34 PM
Okay, so ambient is kind of in the air and affects everything, and diffuse affects only what gets hit by it? That kind of makes sense as a concept, but opengl's lighting seems so unpredictable. Aside from the crapiness of per vertex lighting and how unrealistic it looks (unless I tesselate my objects real good and kill frame rate), there's other things that don't make sense. I made a spotlight with spot cutoff 50 and exponent 65. When I set the ambient and diffuse to red, it works like I think it should, kind of like a flashlight. The room is dark except where I look, so it's kind of like I'm holding a flashlight or something. But when I set the diffuse and ambient to green, it's not like that at all. The room is way lighter and it's, well, not like I'm holding a flashlight anymore. All I changed was the color. That just doesn't make sense. Why does it change so much? It's not even like a spotlight anymore.
how did you set your materials ?
12-28-2005, 04:26 AM
I answered a question in the Vega forum and thought a I would post similar info here, dont forget you need tesselation for spot lights
Many users seem to struggle with the limitations of and how spot lights will actually light geometry in Opengl and thus Creator/Vega/Vega prime/Performer/OSG/V-tree etc....
The image below shows how a spot light works with regards to geometry tessellation
you can cleary see that as the tessellation increase we see the spot lights cone being defined
12-28-2005, 04:29 AM
Ambient light is supposed to add a SMALL overall cast to a scene and should be a LOW value
The higher the value the more white washed your scene will be ( or color you set the ambient to) so in generally the ambient should be close to black
K A Z E
12-28-2005, 04:30 AM
My walls are tesselated well enough. And it looks like (at least I think) it should when the color is red. But when it's green, it's not like a spotlight at all. The walls to my right and left that I'm not even looking at are lit up and stuff. As for material properties, I was trying to figure out lighting by itself first so I haven't set any of those.
12-28-2005, 04:40 AM
Just checking as alot of folks dont realise they need to tesselate when using spot lights
Yep Materials just can confuse the issue , and you probably already have read more on materials any
Ambient, controls the intensity of the constant illumination added to the database by a light source.
Diffuse, controls the color of the light that a light source adds to the database.
Specular, effects the color of the highlight or glare produced on objects in the database by the light source.
Spot Cone Cutoff Angle, controls the angle between the axis of the cone defining a spot light and the sharp cutoff that occurs along the edge of the cone
Spot Cone Dropoff Exponent controls the dropoff that occurs within the cone of effect defined for a spot light. Increasing this value makes the light source more focused
Shininess, is the mirror-like quality of the material’s surface. Shininess is indicated by the size of the highlight on the material ball, a high shininess value produces a small highlight, giving the material a metallic appearance.
Alpha, is the amount of transparency in the material. A value of 0 defines a transparent material; a value of 1 defines an opaque material.
Ambient, the amount and color of light that the material reflects from other objects in the scene. This affects surfaces that are not illuminated directly, the face color interacts with the ambient lighting effect
Diffuse, the amount and color of light that the material reflects in all directions, regardless of the eyepoint position. This results in a flat reflection that is brightest where light strikes the surface at a 90° angle, the ace color interacts with the diffuse lighting effect.
Specular, the brightness and color of the highlight, or glare,this is brightest when the eyepoint is located at the light’s angle of reflection. Metal often imparts a reflected color to the specular highlight. Specular light is directly affected by the Shininess property.
Emissive. this defines the amount and color of non-reflective light the material produces. In other words, the color of the material, this parameter is used for objects that glow
12-28-2005, 04:58 AM
is this what you expecting ?
The ambient is set at a dark green, the one on the right shows the normals
K A Z E
12-28-2005, 05:15 AM
Yes, that's what it should look like. It's like that when it's red. I'm standing with my back to one wall of my room, looking at the other, and there's a "circle" of light on the wall. Whereas, if I turn the light to green, and do the same thing, the entire wall opposite of me is lit up. And when it's red, I can see the vertexes of the walls, because they're brightest. But when i'ts green, I can't. The entire wall is equally well lit up. It's weird.
Edit: Also, when it's red, if I ram my camera up real close to a wall, so that there are no vertexes in my view, the screen goes dark. Now that's annoying and unrealistic, but that's how I figure it should work if the lighting is per vertex. When it's green, it doesn't go dark no matter how close I get. I doesn't matter if there are no vertexes in view. It just doesn't seem to be behaving as a spotlight.
12-28-2005, 05:31 AM
what color component are you setting ?
Diffuse or Ambient ?
K A Z E
12-28-2005, 06:58 AM
Both. I'm changing ambient from (0.5, 0, 0) to (0, 0.5, 0) and diffuse from (1, 0, 0) to (0, 1, 0). That's all.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.