Path: chuka.playstation.co.uk!news From: Alex Herbert Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Fading.. Date: Fri, 15 May 1998 00:42:44 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 48 Message-ID: <355B8173.7AC90863@ndirect.co.uk> References: <6j25v8$aek17@chuka.playstation.co.uk> <355A20ED.50CE92BF@netmagic.net> Reply-To: aherbert@ndirect.co.uk NNTP-Posting-Host: dialin2-54.ndirect.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Elliott Lee wrote: > Anders Clerwall wrote: > > > > Hi.. I've seen some fading done in many Yaroze programs.. How's it done? > > If I LoadImage(&pic, (u_long *)picaddr); how do I fade it up/down to/from > > black??? I really wanna do this.. please help! > > > > // Anders > > One postscript: Jim and Robert's solutions are currently the best > way to do it. If you only modify the RGB intensity values in your > GsSPRITE structure and say you smoothly decrement/increment them, > you'll notice some weird flickering as the image's RGB values get > mapped from whatever internal true color scheme is used into 15-bit color. > > - e! > tenchi@netmagic.net > http://www.netmagic.net/~tenchi/yaroze/ Yep, I agree with that. Some other points of interest though. When using the "Box" method of screen fading, it is a good idea to represent your "Fade Amount" variable as 5-bit (range 0-31) which is native to the display hardware. Then simply shift the bits 3 digits to the left when placing it into GsBOXF's r,g and b values. This translates the Fade Amount into the 8-digit format as required by the OS. The result being that you get a perfectly smooth fade without visible "stepping". (Well, at 50 or 60fps anyhow). However, it does restrict your fade to only 32 frames in length. Slower fades will always step, due to the 5-bit colour depth. Or was Anders talking about the other type of fade, where overlaid screen objects fade into invisiblilty? This can be achieved with semi-transparent objects when using the additive or subtractive transparency modes. (Tick both "Transparent for black" and "Translucent except black" in TimUtil, and set the attribute bits correctly in your code.) Then it's just a case of reducing the object's r,g and b values to fade. When r,g and b become zero, the object will be totally invisible. Subtractive transparency is perfect for smoke and shadow effects (ie where light is reduced). Additive transparency is good for fire, lights, flares, etc. (where light is created.) Herbs