HOWTO: Make 16bit mode look like 32bit!

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

HOWTO: Make 16bit mode look like 32bit!

Post 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).
Last edited by Maximus32 on Fri Jan 09, 2009 9:43 pm, edited 1 time in total.
ps2devman
Posts: 259
Joined: Mon Oct 09, 2006 3:56 pm

Post by ps2devman »

Interesting! Thanks!
LionX
Posts: 61
Joined: Mon Dec 27, 2004 11:40 am

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

LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post by LBGSHI »

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...
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post 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.
Bricks-OS, Operating System for Game Consoles
Post Reply