sceGuAmbientColor applies to texture only?

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

Moderators: cheriff, TyRaNiD

Post Reply
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

sceGuAmbientColor applies to texture only?

Post by Brunni »

Hello :)
I'd like to "tint" my 2D objects. It worked so far as I did just use textures.

Code: Select all

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&#40;alpha<<24 | color&#41;;
&#125;
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
Image Oldschool library for PSP - PC version released
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

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
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

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: Select all

*tex_address++ = quad_color;
if &#40;&#40;tex_address&&#40;512*4-1&#41;&#41;==0&#41; tex_address += 480*4;
if &#40;tex_address>=&#40;VRAM_BASE + 32*512*4&#41;&#41; 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
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
Post Reply