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 

RGBA rendering not working

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



Joined: 01 Jul 2005
Posts: 197

PostPosted: Mon Aug 22, 2005 9:14 pm    Post subject: RGBA rendering not working Reply with quote

I am trying to render a semi-transparent surface, by using convert image to set the alpha to 0x11 (just as a test), but the texture always displays fully opaque, not partially transparent. I do not have the alpha channel testing function on, and I am using the TCC_RGBA flag, and have tried all the texture effect flags with no avail.
Has anyone got a texture to render with translucency? Can anyone help?

EDIT: I think that it may have something to do with sceGuBlendFunc(), but can't quite work out what.
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Tue Aug 23, 2005 3:59 am    Post subject: Reply with quote

You're on the right track atleast.

To do alpha-blending, you must first enable it using sceGuEnable(GU_BLEND). Next, you have to sample the texture properly (as you already do) using GU_TCC_RGBA. Also make sure you use a texture effect that treats the alpha properly, or you'll scratch your head a bit there aswell. Next, setup the blend-function using sceGuBlendFunc(). If everything goes to plan, you should have a partially transparent primitive on screen.

Have a look at the primitive blend-sample in the SDK at samples/gu/blend. It should give you an idea how to do it.
_________________
GE Dominator
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Tue Aug 23, 2005 10:33 pm    Post subject: Reply with quote

Well, I've been working on this, but can't quite get it to work. The complication, I believe is this: all my textures need to be lit, so I need to use GU_TFX_MODULATE, but when I do that, all the objects that share the same texture and vertices can be seen through each other. E.G. All the enemies are the same model, and they are partly transparent, but the only thing that you can see through them are other renders of the same models(more enemies), so you can't see the walls/shots through them. The main confusing part is that the effect is the same for all objects, whether they have a partially transparent alpha channel or not.

It's difficult to explain. Sorry.
Back to top
View user's profile Send private message
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Wed Aug 24, 2005 3:30 am    Post subject: Reply with quote

Those problems come from the order you render your objects.
For alpha blending to work correctly (and this applies to every platform except the dreamcast), you have to:

1. Render all opaque objects.
2. Make a list of your visible alpha blended objects. Roughly sort it by Z (a single iteration of a bubble sort of this object list per frame, if you keep it between frames, should be good enough, that's O(n))
3. Render your list of alpha blended objects, farthest first, nearest last.
_________________
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Thu Aug 25, 2005 2:30 am    Post subject: Reply with quote

Ok, I've got it to work now, the problem was rendering the alpha'ed parts too soon, and so when I put them to the end, It works fine (because my billboards were already in Z-Order). I now have it reading the RGB from one file and the Alpha channel from another file, so now it's all nice and smooth.

I might as well ask my next question here: I am trying to get a 2D layer to go over my game for the HUD and other things, I've setup the 512x512 texture exactly like the sample, but I need to know what sort of unsigned short will control the 4444 colour palette properly. Is it in the format 0xffffff? or do you need to use a bit-shifting macro? What I would like to know is if I want to set one of the pixels to colour ARGB 255,100,200,100 , how would I do that using the 4444 palette?
Thanks.
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Thu Aug 25, 2005 6:34 pm    Post subject: Reply with quote

Is anybody using the GU blit sample? If so, what code are you using to set the colours?
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