View unanswered posts | View active topics It is currently Fri Dec 15, 2017 5:07 pm



Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3
 (libogc) hardware lights 
Author Message

Joined: Thu Sep 08, 2005 8:40 pm
Posts: 53
Hi,

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:
   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);


In wiirrlicht a light is a normal scenenode as well and translated/rotated/scaled by a matrix. To gain the direction, for spotlight or directional light, i use guVecMultiplySR() with an input vector of { 0.0f,0.0f,-1.0f }. But the light direction vector is only used for spotlights and directional lights.

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()).


Sun Sep 05, 2010 6:24 pm
Profile

Joined: Thu Sep 08, 2005 8:40 pm
Posts: 53
Hi,

you've had any success with hardware lighting now?

best regards
shagkur


Tue Sep 07, 2010 8:07 am
Profile

Joined: Sun Jun 20, 2010 9:21 pm
Posts: 15
Well, I haven't tried much because I'm in the middle of my exams. However I've got it more-less working, though I still don't understand how can that be that two faces being at moreless the same distance from the light source can be lit or darken just depending on the orientation if we're not using the normals. That's in fact the part I don't get to work. Also I have been thinking about what causes the bad results in diffuse lighting. The thing is that AF_SPEC works bad, DF_CLAMP works bad, but AF_SPOT works right. And what do Spec and diffuse have in common, different from spot (at least as documentation says)? Normals. Spot lights don't use normals in calculations. Spec and diffuse do. Is there a possibilitiy that normal matrix gets bad loaded or the transformation has a bug?


Tue Sep 07, 2010 8:20 am
Profile

Joined: Thu Sep 08, 2005 8:40 pm
Posts: 53
Well, in my setup GX_DF_CLAMP is still used even though i've GX_AF_SPOT turned on too. So for my understanding in this setup the vertex normals are used aswell in the lighting calculation. As a little sidenote: I didn't renormalize the normals in the RMS mesh loader when i ported it over to wiirrlicht.
I never use AF_SPEC. For specularity i use the TEV and a texture (seen in example 6 & 8).
About the matrix, i presume you load the modelview matrix into the position matrix and a inverse-transpose matrix of the modelview matrix into the normal matrix slot?

best regards
shagkur


Tue Sep 07, 2010 11:40 am
Profile

Joined: Sun Jun 20, 2010 9:21 pm
Posts: 15
Now it works fine shagkur. Thank you so much, Hardware lighting will speed up my engine a lot. Also, for specular lighting I think i'll follow your path and use per-pixel lighting. Once again, thank you so much.


Tue Sep 07, 2010 3:50 pm
Profile

Joined: Thu Sep 08, 2005 8:40 pm
Posts: 53
Hi,

that's great news! Nice to hear you got it working! :)

best regards
shagkur


Tue Sep 07, 2010 6:23 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 26 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads