 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Maximus32
Joined: 27 Aug 2007 Posts: 41
|
Posted: Sat Oct 18, 2008 4:13 am Post subject: HOWTO: Make 16bit mode look like 32bit! |
|
|
It is really very simple to make 16bit mode look good using the hardware dithering present in the PS2. Adding just 2 lines of code to your GIF initialization packet is enough to get it running.
Pseudo code (needs to be included in a gif packet):
| Code: | // Setup 4x4 dithering matrix
GIF_SET_DIMX(4,2,5,3,0,6,1,7,5,3,4,2,1,7,0,6);
// Enable dithering
GIF_SET_DTHE(1);
// Enable color clamping, thanks to LionX
GIF_SET_COLCLAMP(1); |
The result I have looks even better than GT4 (@1080i).
EDIT: Feel free to try out some samples in PAL, NTSC, SXGA and 1080i. The SXGA version looks really cool on my SXGA monitor :-).
EDIT2: Added color clamping to prevent colors from overflowing. Thanks to LionX (see below).
Last edited by Maximus32 on Fri Jan 09, 2009 9:43 pm; edited 1 time in total |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 265
|
Posted: Sat Oct 18, 2008 7:04 pm Post subject: |
|
|
| Interesting! Thanks! |
|
| Back to top |
|
 |
LionX
Joined: 27 Dec 2004 Posts: 61
|
Posted: Thu Jan 08, 2009 10:04 am Post subject: |
|
|
Nice, i added it to my graphics lib, looks just like 32 bit. but the colors in my images that had black or white got overflowed, so i enaable Color Clamp(reg: COLCLAMP ) and it looks PERFECT!!!!.
you just saved me about 50% of memory in the GS.
| Code: |
void sGsEnableDithering(unsigned char enable, int mode)
{
sGS_R_DIMX *dithermatrix;
sGS_R_DTHE *dither;
sGS_R_COLCLAMP *cc;
sgs_setPRIMTAG(((sGS_PRIMTAG *)&send_buf[0]), 3,1,0,0,0,0,1,0x0e);
dithermatrix = ((sGS_R_DIMX *)&send_buf[1]);
dither = ((sGS_R_DTHE *)&send_buf[2]);
cc = ((sGS_R_DTHE *)&send_buf[3]);
if(enable)
{
sgs_setR_DTHE(dither, 1);
// thanks to:"Maximus32" on ps2dev.org for matrix code
sgs_setR_DIMX(dithermatrix, 4,2,5,3,0,6,1,7,5,3,4,2,1,7,0,6);
sgs_setR_COLCLAMP(cc, 1);
}
else
{
sgs_setR_DTHE(dither, 0);
sgs_setR_DIMX(dithermatrix, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
}
sFlushCache(0);
gs_dma_send((unsigned int *)&send_buf[0],1+3);
gs_dma_wait();
}
|
|
|
| Back to top |
|
 |
LBGSHI
Joined: 07 Aug 2006 Posts: 136
|
Posted: Thu Jan 08, 2009 12:09 pm Post subject: |
|
|
Nice; I'll have to play with that very soon.
Also, I need to check out Bricks-OS; looks cool. _________________ I may be lazy, but I can...zzzZZZzzzZZZzzz... |
|
| Back to top |
|
 |
Maximus32
Joined: 27 Aug 2007 Posts: 41
|
Posted: Fri Jan 09, 2009 9:35 pm Post subject: |
|
|
| Quote: | | Nice, i added it to my graphics lib, looks just like 32 bit. but the colors in my images that had black or white got overflowed, so i enaable Color Clamp(reg: COLCLAMP ) and it looks PERFECT!!!!. | Thanks, I'll add the color clamping to my code as well. I wasn't having a problem with it, but I can see where it will go wrong.
| Quote: | | you just saved me about 50% of memory in the GS. | That's how most commercial games do it. (GT4, Crash of the Titans, ...). If you look real close to (not fast moving) images of the game, you can see the dithering. On GT4 in full-hd this is REALLY visible, becouse the image is stretched to full-hd resolution. _________________ Bricks-OS, Operating System for Game Consoles |
|
| Back to top |
|
 |
|
|
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
|