rasmus wrote:I've done a bit of experimenting and here are my results:
On the light type register (0x5f on light 0) it seems bit 1 switches between specular and diffuse lighting (1 is specular, 0 is diffuse). Bit 8-9 changes the light direction somewhat, so I guess it changes point / directional / spot light or something like that. It does not affect specular/diffuse though. Bit 0 is really interesting though. It turns on some kind of component that increases when the light hit the surface near grazing angle. It is also raised to the power of sceSpecular() register. Does anyone know what this lighting model is called?
The three color components for each light source (0x8f..0x91 on light 0) are in order amibent, diffuse/specular and grazing angle color.
It seems I'm not getting any closer to a combined diffuse specular light though :(
I did some experimenting of my own last night, and I've commited my results to PSPSDK. This should help you and others get lighting working. I'll commit a new sample as soon as I've cleaned it up and verified my results, but you should be able to use the new defines in pspgu to your advantage before this. Do note however that this new version of pspgu has a lot of other changes when it comes to defines, which WILL break your app, but it will be easy to fix.
There are, as you say, three different kind of lights available: directional, pointlights and spotlights.
From what I can see, you can combine lights to enable parts of the equation. Remember sceGuLightColor() and how it sets its registers? Well it turns out this is how you enable lights aswell, so for example to setup a diffuse light this:
Code: Select all
ScePspFVector3 lpos = { 5, 0, -20 };
sceGuEnable(GU_LIGHTING);
sceGuEnable(GU_LIGHT0);
sceGuLight(0, GU_DIRECTIONAL, GU_DIFFUSE, &lpos);
sceGuLightColor(0, GU_DIFFUSE, 0xffffff);
To get diffuse AND specular, you can do this:
Code: Select all
ScePspFVector3 lpos = { 5, 0, -20 };
sceGuEnable(GU_LIGHTING);
sceGuEnable(GU_LIGHT0);
sceGuLight(0, GU_DIRECTIONAL, GU_DIFFUSE_AND_SPECULAR, &lpos);
sceGuLightColor(0, GU_DIFFUSE, 0xffffff);
sceGuLightColor(0, GU_SPECULAR, 0xff00ff);
and GU_DIFFUSE_AND_SPECULAR is simply the value 6, or (GU_DIFFUSE|GU_SPECULAR). To set them both in one go you do:
Code: Select all
sceGuLightColor(0,GU_DIFFUSE_AND_SPECULAR,0xffffff);
From what I understood in sceGuLight(), lights can contain either ambient & diffuse (giving you a virtual 5th light if you want to have global changes) or diffuse & specular. Components are filtered, so that you can only either pass in GU_AMBIENT_AND_DIFFUSE or GU_DIFFUSE_AND_SPECULAR to this function to switch between light type 0 and 1.
ALSO, this exposed that you can apparently pass in the value '8' as a component which enables light type 2, and this might be some other kind of lighting-model. I have not yet figured it out, so it is still undocumented.