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 

Alpha blending ??

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



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Fri Oct 28, 2005 8:56 am    Post subject: Alpha blending ?? Reply with quote

Hi guys,

I have a really hard time getting my alpha blending to work. Basically I've taken the setup from how it is done in the sprite sample, which works fine.
The code is shown below (it taken from several places in the project, but the code below shows the order and parameters to the GU calls). It has been stripped down to a minimum, to only two vertices for a single sprite, but it still doesn't work.

Some info. My textures are correct and I've also tried to use the ball.raw from the sprite sample Also, if I don't call sceGuEnable(GU_ALPHA_TEST), the sprite shows up correct. I have other renderings in the projects, where the alpha channel seems to be used just fine ?

Can anyone seem to difference, from what I'm doing here to what is done in the sprite sample ??

Code:


   sceGuAlphaFunc(GU_GREATER,0,0xff);
   sceGuEnable(GU_ALPHA_TEST);
   sceGuEnable(GU_TEXTURE_2D);

   // setup texture
   sceGuTexMode(GU_PSM_5551,0,0,0);
   sceGuTexImage(0,width, height, width, (void *)offset);
   sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA);

   sceGuDepthFunc(GU_ALWAYS);
   sceGuAmbientColor(0xffffffff);

   sceGumMatrixMode(GU_MODEL);
   sceGumLoadIdentity();
      {
      ScePspFVector3 pos = { 0, 0, -4.5f };
      sceGumRotateXYZ(&rot);
      }

   jsaParticleVertex* l_vertices = (jsaParticleVertex*)sceGuGetMemory(2 * sizeof(jsaParticleVertex));
      jsaParticleVertex *index = &l_vertices[0];

      index[0].u = 0;
      index[0].v = 0;
      index[0].color = 0xffffffff;
      index[0].x = - 1.0f;
      index[0].y = - 1.0f;
      index[0].z = 0;

      index[1].u = 1;
      index[1].v = 1;
      index[1].color = 0xffffffff;
      index[1].x = 1.0f;
      index[1].y = 1.0f;
      index[1].z = 0;

   sceGumDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D,2,0,l_vertices);

   sceGuDepthFunc(GU_GEQUAL);
   sceGuDisable(GU_ALPHA_TEST);
   sceGuDisable(GU_TEXTURE_2D);


_________________
Br, Sandberg
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Sat Oct 29, 2005 9:19 am    Post subject: Reply with quote

Anyone ?

I don't have the faintest clue about, why my alphachannel is ignored when I enable alpha blending and I set the texture function to modulate and take the alpha channel into account ?
_________________
Br, Sandberg
Back to top
View user's profile Send private message
Paco



Joined: 09 Oct 2005
Posts: 54

PostPosted: Sat Oct 29, 2005 11:34 am    Post subject: Reply with quote

I don't see anything wrong with that code. Alpha testing (you're NOT! doing alphablending) is working here, but I use 4444 textures, so it's not identical to yours.
_________________
Paco
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Sat Oct 29, 2005 12:28 pm    Post subject: Re: Alpha blending ?? Reply with quote

I havent done much (ok. any) psp graphics coding, but are you sure you dont mean:
Code:
   sceGuEnable(GU_BLEND);
instead of GU_ALPHA_TEST ???

alpha testing will simply pass/fail a pixel depending on if its alpha value is above/below/equal a certain threshold, much the same a depth testing does on the z value.
alpha blending is transparency and all that.

/me tries to remember back to openGL days..
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Sat Oct 29, 2005 5:19 pm    Post subject: Re: Alpha blending ?? Reply with quote

cheriff wrote:
I havent done much (ok. any) psp graphics coding, but are you sure you dont mean:
Code:
   sceGuEnable(GU_BLEND);
instead of GU_ALPHA_TEST ???

alpha testing will simply pass/fail a pixel depending on if its alpha value is above/below/equal a certain threshold, much the same a depth testing does on the z value.
alpha blending is transparency and all that.

/me tries to remember back to openGL days..


I do have blending enabled in the real project. But I've disabled it here, to make it easier to figure out why the alpha testing isn't working.

It is alpha testing that I need to work here. But it seems like it is ignoring my alpha plane. I'll try to convert and load the texture in 4444 format, to see if that makes any difference.
_________________
Br, Sandberg
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Sat Oct 29, 2005 5:39 pm    Post subject: Re: Alpha blending ?? Reply with quote

Oh, sorry i must have misread you 1st post, it sounded like you were having a hard time getting blending to work..
If we still have time for one more uninformed stab in the dark, I don't see where you are setting the parameters for the apha test, are you calling
Code:
void sceGuAlphaFunc(int func, int value, int mask);
somewhere in the app?
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Sat Oct 29, 2005 5:56 pm    Post subject: Re: Alpha blending ?? Reply with quote

cheriff wrote:
Oh, sorry i must have misread you 1st post, it sounded like you were having a hard time getting blending to work..
If we still have time for one more uninformed stab in the dark, I don't see where you are setting the parameters for the apha test, are you calling
Code:
void sceGuAlphaFunc(int func, int value, int mask);
somewhere in the app?


That's in the first line in the code :)
_________________
Br, Sandberg
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Sat Oct 29, 2005 6:19 pm    Post subject: Reply with quote

so it is. Looks like im having a bad day, so i'll shutup now. :)
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Sat Oct 29, 2005 8:26 pm    Post subject: Reply with quote

Now I've come a little further. The only code which was different from the stuff that worked and the stuff that didn't work, was that the stuff working wasn't using 3D transforms (they were icons drawn at absolute places).

If I change the line below:

Code:

sceGumDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D,2,0,l_vertices);


So that they don't ask the GE to do the 3D transform as shown below.

Code:

sceGumDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D,2,0,l_vertices);


Then the alpha test works ?? Should there be any differences in using the 3D transform ??

This is really strange. Any comments or thoughts ?? Since I don't want to do the transforms my self :)
_________________
Br, Sandberg
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sat Oct 29, 2005 8:49 pm    Post subject: Reply with quote

I got 8888 alpha channels to work in 3D in my RoboTORN3D game. See http://forums.ps2dev.org/viewtopic.php?t=3391

I used the blend code

Code:
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0xffffffff, 0xffffffff);
And that I used GU_TFX_REPLACE instead of MODULATE. That means that lighting doesn't affect it, but that was the effect I was aiming for.
Try these parameters and see if they help.
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