Welcome! Log In Create A New Profile

Advanced

Hardware lights

Posted by technik 
Hardware lights
April 26, 2009 08:27PM
Hi, I'm modifying the light system of revolution engine to hardware in order to improve performance, but it isn't working and i can't find what I'm missing.

This is what I do to create a Light
	GXLightObj lit;
	GX_InitLightColor(&lit, color);
	GX_InitLightShininess(&litt, 1.0f);

Then, every frame I do this
	guVecMultiply(cam, &litDir, &pos);
	GX_InitSpecularDirv(&lit, &pos);
	GX_LoadLightObj(&litt, GX_LIGHT0);

make this set up
	GX_SetChanCtrl(GX_COLOR0,GX_ENABLE,GX_SRC_REG,GX_SRC_REG,GX_LIGHT0,GX_DF_NONE,GX_AF_SPEC);
	GX_SetChanCtrl(GX_ALPHA0,GX_DISABLE,GX_SRC_REG,GX_SRC_REG,GX_LIGHT0,GX_DF_NONE,GX_AF_SPEC);
	GX_SetChanAmbColor(GX_COLOR0A0, (GXColor){80,80,80,255});
	GX_SetChanMatColor(GX_COLOR0A0, Obj->clr);
	GX_SetNumTevStages(1);
	GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
	GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
	GX_SetNumChans(1);

	guMtxConcat(cam,absMtx,modelview);
	guMtxInverse(modelview, nMtx);
	guMtxTranspose(nMtx, nMtx);
	GX_LoadNrmMtxImm(nMtx, GX_PNMTX0);
	GX_LoadPosMtxImm(modelview, GX_PNMTX0);

Do you anyone know what I'm missing?
Thanks
Re: Hardware lights
May 10, 2009 02:46PM
i have the question i'm new in this tuff of coding
but i love it
how do you do to make a code ?
Re: Hardware lights
May 11, 2009 09:27AM
what do you mean with "make a code"?
Re: Hardware lights
May 11, 2009 10:42AM
Hi Hermartin,
I assume you wanna know how to do some programming for the Wii,
but you must read the rules of the forums before posting :)

Rules for posting in coding area

Good luck!

@technik,
I think I saw a demo somewhere on the forum on how to use hardware lighting on this board... Will search and see.
(I haven't got round to using the lighting system yet sorry)
Re: Hardware lights
May 11, 2009 11:05AM
Some topics I remember from the good old gcdev:

[www.gcdev.com]
[www.gcdev.com]


I don't know if this helps. You might want to contact this Samson guy, he's one of the few persons I'm aware of that tried to really experiment stuffs with GX features and he certainly knows his subject very well.



Edited 2 time(s). Last edit at 05/14/2009 03:21PM by ekeeke.
Re: Hardware lights
May 13, 2009 09:54PM
You need to normalize the vector you pass GX_InitSpecularDirv().
You setup a 'lit' light structure, but then you also use a 'litt' (double tee's) structure elsewhere.

Michael
Re: Hardware lights
May 14, 2009 02:13PM
the litt mistake is just a typing mistake I made when copying the code. The original code actually compiles, links and runs properly on my wii. The problem is that lighted surfaces seem to have just two states: on and off. I mean, surfaces can be full lighted or non-lighted at all. There is no kind of middle state, there is no shading. For example when I put a sphere and light it, no matter the source is a directional or positional light, the sphere gets half full illuminated and half non illuminated at all (except for the ambient light). So the resulting rasterized vertex of the lighting equation is alwais ambient light or ambientlight plus full lighting, there is no attenuated light (neither by distance attenuation nor by diffuse attenuation).
I've done some testing and I know that rasterized vertex color is correctly used through TEV, the problem seems to be in the lighting equations. If I use GX_DF_NONE and GX_AF_NONE the result is always one (as espected), but, for example, if I use GX_DF_CLAMP and GX_AF_NONE, the result should be the dot product of the normal and the light direction (substracting the vertex position from the light origin) but the actual result is just one o zero.
Sorry, only registered users may post in this forum.

Click here to login