Some HW lighting examples

Post Reply
lupidan
Posts: 7
Joined: Wed Jun 24, 2009 10:44 am

Some HW lighting examples

Post by lupidan » Wed Jun 24, 2009 10:51 am

Hi there!
Well, I was searching for some lighting examples in wii-examples and gc-examples, but I couldn't find anything related. The only thing was this Hermes 3D manual, but I can't get lighting to work.
Whenever I try to set up a light in GX_LIGHT0, I end up messing up and get a dark red cube with two faces a bit clearer. (The cube is actually multicolored)

¿Do you know where can I find a comprehensive example, just the basic lighting?

Thanks for your help :)

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

Re: Some HW lighting examples

Post by shagkur » Wed Jun 24, 2009 2:22 pm

Hi,

i can't really show you a comprehensive example, but maybe this will help you too:
http://code.google.com/p/wiirrlichtcust/

It's a port of the IrrLicht engine i'm working on. Have a look into gxdriver.cpp for lightning.

Hope this helps.

regards
shagkur

lupidan
Posts: 7
Joined: Wed Jun 24, 2009 10:44 am

Re: Some HW lighting examples

Post by lupidan » Wed Jun 24, 2009 5:32 pm

I have seen your code and more or less your code and I have more or less the same thing. But nope, still dark red....
¿what am I doing wrong?
¿What channels do i need to set?¿Maybe I have to do something with the Texture Enviroment?

Code: Select all

	GXLightObj light;
	GXColor clight = {L->GetColor()[0]*255, L->GetColor()[1]*255, L->GetColor()[2]*255, L->GetColor()[3]*255};
	Vector light_pos = {L->GetPosition()[0]*255,L->GetPosition()[1]*255,L->GetPosition()[2]*255};

	GX_InitLightPosv(&light,&light_pos);
	GX_InitLightColor(&light,clight);

	GX_LoadLightObj(&light,GX_LIGHT0);

	GX_SetNumChans(1);
	GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE,GX_SRC_REG,GX_SRC_VTX,GX_LIGHT0,GX_DF_CLAMP,GX_AF_NONE);

	GXColor Ambiente = {128,128,128};	
	GX_SetChanAmbColor(GX_COLOR0A0, Ambiente);
I am not multiplying light_pos because I am using an orthogonal view, ¿do I have to multiply it by something?¿If so, what with?
So many questions... I'm so sorry
Thanks in advance

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

Re: Some HW lighting examples

Post by shagkur » Fri Jun 26, 2009 12:32 pm

Hi,

do you use Normals in your vertex data? As this is needed for lightning calculations. Also you've to retrive the inverse-transposed matrix of the model-view matrix (which you loaded into the Position Matrix slot) and load it into the Normal Matrix slot.

Furthermore it's kinda hard to tell, from this small code snippet what's going wrong. This snippet seems okay to me so far.

regards
shagkur

lupidan
Posts: 7
Joined: Wed Jun 24, 2009 10:44 am

Re: Some HW lighting examples

Post by lupidan » Fri Jun 26, 2009 1:01 pm

Hi,

do you use Normals in your vertex data? As this is needed for lightning calculations. Also you've to retrive the inverse-transposed matrix of the model-view matrix (which you loaded into the Position Matrix slot) and load it into the Normal Matrix slot.

Furthermore it's kinda hard to tell, from this small code snippet what's going wrong. This snippet seems okay to me so far.

regards
shagkur
Well, I use normals directly exported from blender.
What I didn't coded is to load the inverse of the Model-view matrix in the normal matrix (first time hearing about this :S)
Reading the code I have seen this func:
GX_LoadNrmMtxImm (Mtx mt, u32 pnidx)
¿I guess that's where I load the inverse right?

Thanks a lot, I will try it as soon as I can :)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest