Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: technology behind Morpheus ....

From: holger:rebol at: 30-Oct-2001 14:57

On Tue, Oct 30, 2001 at 12:04:46PM -0800, Carl Sassenrath wrote:
> Actually, Holger recently rewrote the entire effect pipeline when he added alpha channels. :) That sounds like a priority to me.
Ok, so the cat is out of the bag. Some more infos on that, because Petr is going to ask anyway :). All of these changes are expected to be in Express 1.0 and the next View release (no release date yet). - REBOL uses what are refered to as "non-premultiplied transparency" alpha values. The "transparency" indicates that the alpha channel describes the amount of transparency, not opaqueness, so 0 means solid and 255 means fully transparent. "non-premultiplied" means that you can change alpha and color values independently, i.e. the color information does not have to be adjusted when the alpha value is changed. - The image! datatype supports alpha information. Color tuples now contain a fourth byte, with the alpha channel. You can still use 3-byte tuples though to "change" an image. - PNG and GIF loaders and the PNG saver support alpha channel data. The BMP and JPEG formats do not support transparency. - Molding an image includes alpha data if the image contains some transparent section. Upward and downward compatibility for load and mold with older REBOL versions is ensured. - The effect pipeline supports alpha information, i.e. all alpha information (including alpha information from the image associated with a face and temporary alpha information, e.g. for keying) is kept during effect processing, and at the end the image is composited onto the background using the alpha channel. - to-image on a face does NOT return alpha information. It returns the face contents after compositing it onto the background. Also, don't expect windows to be transparent just because they contain an image with alpha data :-). - All effects can now be used in any combination and in any order. This includes things like "key" followed by "luma", which previously produced unpredictable results. Keying is resolved into alpha channel information whenever necessary, allowing you to process keyed images by other effects without affecting the background, or even to stack "key" effects for multiple keyed colors. - The "shadow" effect supports images with alpha data, i.e. a partially transparent pixel throws a shadow that is less dark, and the shadow of another pixel (if any) shines through :-). Also, the "shadow" effect no longer renders the image and shadow immediately, but rather keeps both around in a single, combined image, with the shadow represented by alpha data. This allows you to post-process an image with other effects after applying the shadow effect. - The "shadow" effect now enlarges the image to allow the complete image to throw a shadow. Of course in order to see it completely your face as to be large enough as well. - Added "shadow smooth" effect for shadows with smooth edges. - Some bug fixes and performance improvements in the effect pipeline. - Added "anti-alias" effect. It performs minor, non-aggressive alpha-based anti-aliasing on the borders of images. - Added "func" effect. This allows you to call a REBOL function from within the effect pipeline, manipulate the current image (including its alpha information) and pass an image back to the effect pipeline. - There will probably be a way to copy data around between the alpha plane and other color planes, and between images, e.g. to use a color plane or the grayscale value of some other image as the alpha channel in the current image, but we do not have full specs on that yet. Changes that affect compatibility with existing scripts: - The shadow effect has changed. Instead of "shadow 1.2.3", with a color value, it now uses the current key color, to be set by "key", i.e. use "key 1.2.3 shadow" instead of "shadow 1.2.3". The idea is that "key" sets the key color, and other words such as "shadow" set the keying mode (with the default being regular chroma/luma-keying, depending on whether you pass a tuple or an integer). In the future there might be more keying modes. - Previously the effect pipeline had an undocumented side effect, that if the face was transparent and did not have an image, the effects would not apply to the face, but rather to the background behind the face. This would allow you to create faces that act as filters. Because of the implied transparency caused by alpha channels, this side effect no longer exists, i.e. an effect always applies to the image itself, never to the background. You can still create faces that act as filters, but you need to tell the system about that. The effect keyword for that is "merge". It can appear anywhere in an effect block, but will most commonly appear at the beginning. What "merge" does is merge the image currently in the pipeline with the background behind the face, using alpha-based compositing. The result is then used as the current pipeline image. If there is no current image then just the background itself is used. For instance, if you previously used [colorize 255.0.0] to colorize the background behind a face red you now have to use [merge colorize 255.0.0]. - Some effects would previously allow you to pass a color value as an integer! instead of a tuple!. This has never been documented and has now been removed to allow integer arguments to fulfill a different purpose with some effects in the future. - "pick"ing a color value from an image now returns a four-byte tuple, with the fourth byte being the alpha information. The only compatibility issue here is that if you compare the returned color value directly to a 3-byte tuple using "=" or "<>" you may get wrong results. Comparisons of the type "<", ">", "<=" and ">=" should work correctly though. -- Holger Kruse [holger--rebol--com]