Advertisement

Lighting a plane :S

Started by December 09, 2000 03:50 AM
2 comments, last by Divide Overflow 23 years, 11 months ago
Hey everyone, There is this thingy if been trying to do for a long while now, but I don''t seem to succeed... I want to light up a passageway, when a fireball passes (just like Quake2 when you shoot with your blaster). Anyway, I''ve got 3 planes (see the bad ascii drawing ), consisting all of like 100 triangles, then I send a GL_LIGHT0 thru the passageway, and it lights up, but all at the same intensity. ab aa bb aa bb cccccccccc (a = plane1, b = plane2, c = plane3, viewport = front) (just incase you''re wondering :D) I want just a small proportion of the hallaway light up. Not the whole scene. Can someone help ? -- Divide Overflow "Don''t quote me -- Epidemi"
check your normals, check if they are really the normals of the surfaces, check if you define all of them, and check if they are normalized or not. you have to normalize them.
Advertisement
you need to set some attenuation on your light. Natural light follows an inverse square law (one of many in physics) where the relative intensity of the light is equal to the reciprocal of the square of the distance from the source 1/(d^2) or d^-2, open GL however allows you to specify constant, linear, or quadratic attenuation. The formula goes somewhat like this (periods used for spacing)

.......i1
--------------- = i2
c + l*d + q*d^2

where i1 = the origeonal intensity and i2 = the adjusted intensity (of a particular point) OpenGL lets you set the constants c, l, and q. the starting falues are 1,0,0 respectively creating no fall of. Basically you just tweak these numbers until you get what you want. You''ll start to get a feel for them after a while, but if you want a quick representation, just whip out the old graphing calculator :-).
The API functions that go along with this are:

glLightf(GL_LIGHT#, GL_CONSTANT_ATTENUATION, light.c);
glLightf(GL_LIGHT#, GL_LINEAR_ATTENUATION, light.l);
glLightf(GL_LIGHT#, GL_QUADRATIC_ATTENUATION, light.l);

Hope this helps.

Brought to you by: O.G.A.P.O.
+----------------------------------------+
| Surgeon General''s Warning - |
| OGAPO can cause serious mental damage |
| if taken in large doses. |
+----------------------------------------+
/* Never underestimate the power of stupid people in large groups */
Brought to you by: [email=ogapo@ithink.net]O.G.A.P.O.[/email] +----------------------------------------+| Surgeon General's Warning - || OGAPO can cause serious mental damage || if taken in large doses. |+----------------------------------------+/* Never underestimate the power of stupid people in large groups */
Yo, how do you make an effect such as the one in the 1st place halloween demo where the light looks real and only lights up the terrain in certain places??



Open mouth, insert foot

This topic is closed to new replies.

Advertisement