Path: chuka.playstation.co.uk!tjs From: tjs@cs.monash.edu.au (Toby Sargeant) Newsgroups: scee.yaroze.beginners Subject: Re: transparency question Date: 21 May 1999 23:34:02 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 52 Message-ID: References: <7i3kv1$1186@chuka.playstation.co.uk> NNTP-Posting-Host: longford.cs.monash.edu.au X-Newsreader: slrn (0.9.4.3 UNIX) On Fri, 21 May 1999 13:51:47 +0100, Derek da Silva wrote: > > >I want to fade an opaque foreground sprite into invisibility against it's >background (and back again) - kinda like the onscreen icons in Zelda64. In >terms of transparency rate, sprite brifghtness values, etc - how is this >effect achieved? Very not easily, I'm afraid. One way to do it is this: Take a copy of the sprite on a black background. Use the subtract mode to subtract a copy of the background that it's currently on top of from the copy of the sprite. You need to leave all the transparent pixels the same though (i.e. the ones with the sprite pixel value 0x0000), which *might* require CPU intervention. If it's a static background, you're in luck, and you can precompute this. This leaves you with an area of VRAM that is essentially (sprite - background) then you can use the add mode to get (sprite - background) + background, which is == sprite. by varying the semitransparency rate, you get: n*(sprite - background) + background, == n*sprite + (1 - n)*background which is the alpha transparency formula you wanted. Also, because pixels can't have negative intensities, you'd better be sure that all the pixels in your sprite are brighter than the ones in the background, otherwise computing (sprite - background) will cause clipping of colour values, and the effect won't look right (some pixels in the unfaded version will appear to be transparent (or the wrong colour) when they shouldn't be). [Not just brighter, by the way; every R, G and B component in the sprite has to be brighter] All in all, I think it's better to either a) fake it. (most games I've seen do this) b) (for small sprites) do it with the CPU. Proper alpha transparency. Another reason why a Yaroze 2 would be so much more fun. Toby.