# Lighting vs vertices

Hi there!

Is it possible to change the properties of a light after each vertex in a face? (I want to do some kind of primitive vertex based shadowing) Or is there another way to do this? (for example i want a light to affect 2 vertices with intensity=1 and the third one with only intensity=0.2 )

Couldn’t you just change the color of vertices? For example: 2 vertices are (1.0f, 1.0f, 1.0f) and the last one is (0.2f, 0.2f, 0.2f). The effect will be same in my opinion, because lighting do the same- changing colors. And this should be faster.

I also need the lighting data. When i wrote intensity=1 or 0.2 i mean multipying the ligth intensity by 1 or 0.2. (And i have more than 1 lights)

So multiply them.

Draw shaded elements when GL_LIGHTING is disabled.

Ok, ill explain, maybe i wasn’t clear:
2 lights lit a face, if the first one lits a vertex and the second not (because some object blocks the ray) than i want the first light calculated with intensity=1 and the secont with intesity=0 but maybe both lights lit the second vertex, and none of them lit the third vertex. That’s why i’d like to adjust light parameters before each vertex.
And i cannot do it manually because lighs have different color, intensity, position etc. it would be difficult and slow.

You can change the color at each vertex using glMaterial#, or if you’re slack you can enable GL_COLOR_MATERIAL and just use glColor#. However, per vertex shadowing is not really the way to go (unless you have a very constained scene).

I’d recommend you take a look around at nvidia’s developer site and read some of the papers to find out what your options are, because shadows aren’t really a beginners topic

If you only need to change intensity for vertex lighting, turn off normalizing of normal vectors and premultiply the vertex normal vectors with your intensity factor

Well, thanks, but material and changig the normal works only if i have 1 light source becuse it affects the light from all sources. I’d like to do it somehow to all separate light sources.

Thanks: Bagoj