POV-Ray : Newsgroups : povray.binaries.images : using 'transmit all' with PNG alpha-channel image_maps-- a flaw? : using 'transmit all' with PNG alpha-channel image_maps-- a flaw? Server Time
15 May 2024 01:36:46 EDT (-0400)
  using 'transmit all' with PNG alpha-channel image_maps-- a flaw?  
From: Kenneth
Date: 8 Jan 2016 13:15:01
Message: <web.568ffc27b138edc733c457550@news.povray.org>
I don't know if this situation has ever been discussed in the newsgroups. I've
been meaning to post about it for several years(!); I apologize for its extreme
lateness.

When animating in POV-Ray, I sometimes like to 'fade out' an image_map pigment
over time, using 'transmit all' (and 'clock', for example.) This works perfectly
well for JPEG, BMP (Windows-specific) and 'basic' PNG images-- i.e., images that
do not have a built-in alpha channel.

Like this:

pigment{
 image_map{jpeg "my_image.jpg" once interpolate 2 transmit all *some value*}
       }

But if the image has been pre-made with an alpha-channel mask (a PNG file for
example, made in Photoshop),'transmit all' produces some unexpected results: As
the transmit all value goes from 0 to 1, the opaque part of the image does
indeed fade out as expected; but the 'masked-off' part of the image-- which
begins by being fully transparent-- actually fades IN, and in an odd way that's
hard to describe. Basically, the normally-invisible 'background' color of the
alpha-channel's mask area fades in with a *complementary* color, and looks like
*filtered* transparency. Very strange. This happens in POV-Ray v3.7 as well as
v3.62.

See the attached image for a visual description. (Normally, the 'invisible' part
of an alpha-channel image has either a white or black color as a default
'background'; I changed that in Photoshop to be more colorful before running the
renders in POV-Ray, in order to show the odd result.)

I tried an alpha-channel TIFF image, too; same behavior. I even tried a POV-made
alpha-channel PNG image; same behavior.

I realize that the idea of fading-out an image that *already* has a mask
attached may seem redundant or unnecessary; but the technique can be really
useful for custom-shaped 'decals' or logos or whatever (with soft-edged masks as
well.) Presently, the only way that I know of to do this fade-out is to prepare
*multiple* PNG images-- each with a slightly different alpha-channel-- and call
them in sequence during the animation. Not very elegant! (There might be a way
of doing this trick by splitting the image into four(?) functions first, in
POV-Ray, then manipulating the 't' function; but offhand, I don't yet know how
that could be done.)

I have my own guesses as to why this doesn't work:
A) 'Transmit all' was never designed to do work with an alpha channel.
B) POV-Ray's transparency code was written before PNG was invented (?!)
C) There's an unforeseen flaw in how POV-Ray 'sees' an image's alpha-channel
information.

From the visual behavior of the results, it seems that POV's transparency code
is (naturally) trying to alter not just the 'opaque' part of the image_map, but
also the areas where there is already 'full transparency'-- as if all the
underlying PNG image 'information' is of the same type, to be treated equally.
My own (naive) suggestion for a fix would be to 'clamp' any full-transparency
values, encountered in the image's alpha-channel or during the fade, to a fixed
'base' value. Would that make sense?


Post a reply to this message


Attachments:
Download 'transmit_all_problem.jpg' (126 KB)

Preview of image 'transmit_all_problem.jpg'
transmit_all_problem.jpg


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.