basically that's not completely wrong what you do. The difference to mine is that, for a point light, i don't initialize the light direction.
Furthermore i have angle attenuation turned off. And the distance attenuation function i use is GX_DA_MEDIUM.
So here's, pretty short, the way i do it (for a point light):
Code: Select all
guVector lpos = {0,-50,50};
guVecMultiply(view,&lpos, &lpos);
GX_InitLightPos(&lobj,lpos.x,lpos.y,lpos.z);
GX_InitLightSpot(&lobj,0.0f,GX_SP_OFF);
GX_InitLightDistAttn(&lobj, 100.0f, 0.5f, GX_DA_MEDIUM);
GX_InitLightColor(&lobj,SC_WHITE);
GX_LoadLightObj(&lobj,GX_LIGHT0);
Have a look at lightscenenode.cpp and in gxdriver.cpp at assignHardwareLight. In lightscenenode.cpp i "manually" calculate the distance attenuation coefficients but the formula is the one from GX_DA_MEDIUM.
Again: Every local light, regardless if it's a point light or spot light has a light radius, so i can calculate the DA coefficients. Also such a radius for local lights makes it possible to do some kind of culling for lights (look in gxdriver.cpp at loadLocalLights()).