| View previous topic :: View next topic |
| Author |
Message |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sat Mar 24, 2007 5:49 am Post subject: sceGuAmbientColor applies to texture only? |
|
|
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 |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Sat Mar 24, 2007 7:34 pm Post subject: |
|
|
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 |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Mon Mar 26, 2007 3:13 pm Post subject: |
|
|
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 |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Mon Mar 26, 2007 7:51 pm Post subject: |
|
|
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 |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sun Apr 01, 2007 12:27 am Post subject: |
|
|
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 |
|
 |
|