Page 1 of 1

HOWTO: Make 16bit mode look like 32bit!

Posted: Sat Oct 18, 2008 4:13 am
by Maximus32
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: Select all

// 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).

Posted: Sat Oct 18, 2008 7:04 pm
by ps2devman
Interesting! Thanks!

Posted: Thu Jan 08, 2009 10:04 am
by LionX
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: Select all


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();
}


Posted: Thu Jan 08, 2009 12:09 pm
by LBGSHI
Nice; I'll have to play with that very soon.

Also, I need to check out Bricks-OS; looks cool.

Posted: Fri Jan 09, 2009 9:35 pm
by Maximus32
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.
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.