For example, I found this in the old wiki under a section about HLSL shaders, and it says, "For applying dynamic lights, use the following function:"
That's all it says, and this seems to be the best explanation I can find, even though I don't know where to use it.
PS It was late when I started this thread so I think I may have put it in the wrong forum, should be in scripting.. sorry
Code:
float4 vecLightPos[8];
float4 vecLightColor[8];
float3 vecFalloff = float3(0.f, 0.f, 2.f);
...
float4 DoPointLight(float3 P, float3 N, int i)
{
// calculate the light ray pointing from the light to the surface
float3 D = (float3)vecLightPos[i]-P;
// calculate the angle between surface and light ray
float NdotL = dot(N,normalize(D));
// modulate the light by the surface angle
float4 Color = vecLightColor[i] * NdotL;
// calculate the light attenuation factor, DX uses a really strange formula here
float fac = 0.f;
if (NdotL >= 0.f && vecLightPos[i].w > 0.f)
{
// get the distance factor
float LD = length(D)/vecLightPos[i].w;
#ifdef DXLIGHTING
if (LD < 1.3f)
fac = 1.f/(vecFalloff.x + vecFalloff.y*LD + vecFalloff.z*LD*LD);
#else // linear Lighting
if (LD < 1.f)
fac = 1.f - LD;
#endif
}
return Color * fac;
}