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 

sceGuAmbientColor applies to texture only?

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



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sat Mar 24, 2007 5:49 am    Post subject: sceGuAmbientColor applies to texture only? Reply with quote

Hello :)
I'd like to "tint" my 2D objects. It worked so far as I did just use textures.
Code:
void setTint(int alpha, color)
{
    sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
    sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
    sceGuAmbientColor(alpha<<24 | color);
}

The problem is that it does not seem to apply to untextured objects :(
Is it normal? What should I do in this case? :)
(except multiplying my vertex colors with current tint, I'd like a general purpose solution without overhead ;))

Thanks in advance :)
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Sat Mar 24, 2007 7:34 pm    Post subject: Reply with quote

Yes, indeed it's normal that sceGuTEXFunc only applies to textured objects ;)

Assuming you need the blend stage for the real alpha blend, the only thing I can think of to do is have a 1pixel texture map that is applied to the quad/triangle with the color you want it to have. That 'texture' can be generated easily (write one int to (VRAM_BASE + 480*4)) on the fly and wouldn't drain the texture hardware too much thanks to the texture cache (set all u/v's to 0 - if the hardware is clever it notices it's calculating a zero delta), and you're left with the overhead of supplying u/v coordinates with your 'untextured' stuff plus a little from the 'texturing' stage.

Dunno if that would be faster than using real untextured mode and applying the tint to your vertices with a fast software blend.

Hope that helps :)
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Mon Mar 26, 2007 3:13 pm    Post subject: Reply with quote

Thank you very much Raphael :)
I think I'll rather do a software blend then, because with your method I would have to sync the GE in case of repetitive calls ;)
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Mon Mar 26, 2007 7:51 pm    Post subject: Reply with quote

Well, you could avoid the sync if you increase the 'texture' address so you make use of the whole framebuffer stride and wrap around once you reached an upper limit (maybe the 32x32 quad in that area, so you have 1024 repetitive calls before the textures overlap and you need to sync).
Code:

*tex_address++ = quad_color;
if ((tex_address&(512*4-1))==0) tex_address += 480*4;
if (tex_address>=(VRAM_BASE + 32*512*4)) tex_address = VRAM_BASE + 480*4;

_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Apr 01, 2007 12:27 am    Post subject: Reply with quote

Ok I see :) Thank you ^^
And btw it depends from the current framebuffer mode, so it's better to do 16 pixels per line I think :)
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
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