• Create Account

### #ActualTsus

Posted 13 September 2012 - 04:44 PM

Hi!

If you write
float attenuation = 1.0f / d*d;
if will evaluate to . Therefore, you haven’t had any attenuation at all.

If you change it to
float attenuation = 1.0f / (d*d);
you got what you want:

By the way, the other attenuation parameters (constant and linear) are just for artistic purposes. Squared attenuation would be most correct, since the irradiance of a point light is:
E = max(0, cosAngle) * vLightIntensity / (squaredDistance);
For a diffuse surface the radiance then becomes:
L = E * vSurfaceColor / Pi;
You got it right, except for the division by Pi. (It is there for the energy conservation.)

Anyway, the reason why things are getting dark is, that your light source is probably too far away. Consider a distance of 10 units in space. Squared and divided gives you 1/100 of your un-attenuated intensity. I think, things should work for you, if you make your light brighter, i.e. your variable “lightColor”. The lightColor actually stores the luminous intensity in candela (cd). A candle has about 1 candela. A 100 watt light bulb has about 130 cd. So, I guess you need rather large values. :-)

By the way, your test model is quite beautiful. Is it available online? I'd like to use it in my thesis.

Cheers!

### #1Tsus

Posted 13 September 2012 - 04:43 PM

Hi!

If you write
float attenuation = 1.0f / d*d;
if will evaluate to . Therefore, you haven’t had any attenuation at all.

If you change it to
float attenuation = 1.0f / (d*d);
you got what you want:

By the way, the other attenuation parameters (constant and linear) are just for artistic purposes. Squared attenuation would be most correct, since the irradiance of a point light is:
E=max(0,cosAngle) * lightColor / (dist2);
For a diffuse surface the radiance then becomes:
L=E*vSurfaceColor/Pi;
You got it right, except for the division by Pi. (It is there for the energy conservation.)

Anyway, the reason why things are getting dark is, that your light source is probably too far away. Consider a distance of 10 units in space. Squared and divided gives you 1/100 of your un-attenuated intensity. I think, things should work for you, if you make your light brighter, i.e. your variable “lightColor”. The lightColor actually stores the luminous intensity in candela (cd). A candle has about 1 candela. A 100 watt light bulb has about 130 cd. So, I guess you need rather large values. :-)

By the way, your test model is quite beautiful. Is it available online? I'd like to use it in my thesis.

Cheers!

PARTNERS