Default vertex color with alpha blending and GU_TFX_MODULATE

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
PlayfulPuppy
Posts: 22
Joined: Fri May 05, 2006 12:04 am

Default vertex color with alpha blending and GU_TFX_MODULATE

Post by PlayfulPuppy »

Okay, after a lot of experimentation and head bashing I've finally got alpha transparencies working with lighting enabled using the following code:

Code: Select all

		sceGuAmbient(0xFF000000);
		sceGuLightColor(0, GU_DIFFUSE, 0xFFFFFFFF);
		sceGuEnable(GU_LIGHTING);
		sceGuEnable(GU_LIGHT0);

		sceGuEnable(GU_TEXTURE_2D);
		sceGuEnable(GU_BLEND);

[snip...]

		sceGuLight(0, GU_POINTLIGHT, GU_DIFFUSE, (ScePspFVector3*)&m_pCamera->GetWorldMatrix().GetRow(3));

[snip...]

		sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
		sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
(For other people bashing their heads trying to get alpha transparencies working with lighting enabled, keep in mind that GU_TFX_MODULATE also works off the alpha values from lights. Make sure all your lights have an alpha of FF, and make sure you set the global ambient color to FF. Note that using lights with GU_AMBIENT_DIFFUSE doesn't appear to work)

Anyways, now onto the current problem. When I render my models, I need to have vertex colors set (GU_COLOR_XXXX in the vertex format) or my model doesn't appear with the above blending/color settings. The reason for this appears to be that the PSP is assuming that if there's no vertex color, the color is 0 (Note with blending disabled, the model turns black, so I'm about 99% sure this is the case).

I was just wondering, is there a way to set what the default vertex color for a mesh should be if GU_COLOR_XXXX isn't applied? I'd prefer to save the 4 bytes per vertex, as most if not all of the meshes in my project won't be using anything other than 0xFFFFFFFF and it seems like a waste.

Thanks guys.
PlayfulPuppy
Posts: 22
Joined: Fri May 05, 2006 12:04 am

Post by PlayfulPuppy »

Note I also tried out sceGuColor(0xFFFFFFFF), and that didn't seem to work. Would appear that value gets stomped somewhere by... something.
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

Have you tried sceGuTexEnvColor ? Not sure it'll do the job, but since you have texturing enabled it might.
Br, Sandberg
PlayfulPuppy
Posts: 22
Joined: Fri May 05, 2006 12:04 am

Post by PlayfulPuppy »

Yep, tried that too. No dice. :\
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

sceGuTexEnvColor() only specifies the constant color for the GU_TFX_BLEND texture effect, nothing else. (just like for opengl)
GE Dominator
Post Reply