Odd light behavior

Started by jfbguy, April 11, 2012, 02:39:37

Previous topic - Next topic

jfbguy

Hi, I'm getting some oddity with my light in my scene.
Here is a video to show what is happening.
http://www.youtube.com/watch?v=XiNXMAWm0hU
Little cube in air is location of my light, I update it's position for every render.  I thought my problem was with my shaders but this is with them off.  Getting some weird lighting with the polygons I've drawn while the sphere using GLU is lit correctly.
Anyone see anything like this before?

CodeBunny

That looks perfectly normal, I'm not sure what's wrong.

What were you expecting? Shadows? Unless you do some complicated stuff, you can only have lighting be calculated on the model (it's not projected anywhere) and it is only per-vertex.

jfbguy

I guess I thought the light would still light up the walls even if it was close to them.  Shouldn't it?

matheus23

If you really want to have good-looking light effects, you should try programming your own "Per-pixel" shader. That will give you lighting, which looks even better than on the sphere, even if your on a plain wall.

The problem your having that, is, that OpenGL's standard lighting algorithms are per-Vertex. That means: If you have a really huge plain, all pixels/texels/fragments on that plain will have the same "lighted" value. That is, because OpenGL computes the dot product between a FACE's Normal and the normal pointing from the face to the light. Then it takes that value, to calculate a "lit" factor, which will enlight the face. If you have pixel-shaders, you do the same, but per pixel/fragment. That means less performance, but a reaaaaally nice result. Try it :P google some tutorials, there are alot for sure.
My github account and currently active project: https://github.com/matheus23/UniverseEngine

RiverC

The other solution (if you're not particularly interested in 'high quality' light) is to fragment the flat parts into multiple faces. That way you don't *have* to do per-fragment lighting and you'll still get some variety of luminance across the surface.