forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Default vertex color with alpha blending and GU_TFX_MODULATE

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
PlayfulPuppy



Joined: 05 May 2006
Posts: 22

PostPosted: Fri May 05, 2006 12:28 am    Post subject: Default vertex color with alpha blending and GU_TFX_MODULATE Reply with quote

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

Code:

      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.
Back to top
View user's profile Send private message
PlayfulPuppy



Joined: 05 May 2006
Posts: 22

PostPosted: Fri May 05, 2006 12:41 am    Post subject: Reply with quote

Note I also tried out sceGuColor(0xFFFFFFFF), and that didn't seem to work. Would appear that value gets stomped somewhere by... something.
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Fri May 05, 2006 12:57 am    Post subject: Reply with quote

Have you tried sceGuTexEnvColor ? Not sure it'll do the job, but since you have texturing enabled it might.
_________________
Br, Sandberg
Back to top
View user's profile Send private message
PlayfulPuppy



Joined: 05 May 2006
Posts: 22

PostPosted: Fri May 05, 2006 8:52 am    Post subject: Reply with quote

Yep, tried that too. No dice. :\
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Fri May 05, 2006 4:53 pm    Post subject: Reply with quote

sceGuTexEnvColor() only specifies the constant color for the GU_TFX_BLEND texture effect, nothing else. (just like for opengl)
_________________
GE Dominator
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group