Path: chuka.playstation.co.uk!chuka.playstation.co.uk!chuka.playstation.co.uk!not-for-mail From: Lewis_Evans@Playstation.sony.com Newsgroups: scea.yaroze.programming.2d_graphics Subject: Clut Fading Date: 9 Mar 1998 17:04:20 -0000 Organization: Sony Computer Entertainment Europe - 119.SS5 Lines: 79 Sender: news@chuka.playstation.co.uk Message-ID: <6e17ek$jo71@emeka.playstation.co.uk> Reply-To: Lewis_Evans@Playstation.sony.com NNTP-Posting-Host: emeka.playstation.co.uk by mail2.fw-sj.sony.com (8.8.8/8.8.8) with ESMTP id JAA06878 for ; Mon, 9 Mar 1998 09:08:57 -0800 (PST) From: Lewis_Evans@Playstation.sony.com To: news@playstation.co.uk Has someone a source for fading an image by updating the CLUT in memory ? would be cool! :-) This example is from memory, but the principle is sound; basically store the original clut in an array (global), then each frame when you want to alter it, get a new clut (set an array according to the original array and the modification function) and load that to the place of the original in VRAM. The other way is to have VRAM contents constant, with lots of cluts for one pixel block; for sprites or polygons, you can just change the cx, cy fields to make it use a different clut each time. Some of the benefits of clut animation can be realised more easily by GsSPRITES, eg rgb alteration (fade up, fade down, alter colour). Lewis // space to hold original clut u_short originalClutBuffer[256]; // function that just grabs the original clut and stores it // in an array; call this just once before clut alterations void GetOriginalClutOfImage( GsIMAGE *image) { RECT clutRect; // could check that image is 4 or 8 bit setRECT( &clutRect, image->cx, image->cy, image->cw, image->ch); // ch will be 1, cw will be 16 or 256 StoreImage( &clutRect, (u_long*) clutBuffer); DrawSync(0); } u_short modifiedClutBuffer[256]; // this actually alters the clut void ChangeClut (GsIMAGE *image) { RECT clutRect; // could check that image is 4 or 8 bit setRECT( &clutRect, image->cx, image->cy, image->cw, image->ch); // ch will be 1, cw will be 16 or 256 // this block: obtain modified clut // eg from original clut and modification function // example only: reverse the clut for (i = 0; i < 256; i++) { modifiedClutBuffer[255-i] = originalClutBuffer[i]; } LoadImage( &clutRect, modifiedClutBuffer); // NOTE: _may_ not want to call DrawSync(0) here, since you may be calling this // function for many different images in one frame }