POV-Ray : Newsgroups : povray.general : Changing image maps' transparency? Server Time
30 Jul 2024 06:25:05 EDT (-0400)
  Changing image maps' transparency? (Message 1 to 6 of 6)  
From: SharkD
Subject: Changing image maps' transparency?
Date: 7 Nov 2009 19:41:53
Message: <4af613d1$1@news.povray.org>
Is there a way to adjust the transparency without modifying the images 
themselves? Thanks!

Mike


Post a reply to this message

From: SharkD
Subject: Re: Changing image maps' transparency?
Date: 7 Nov 2009 20:23:57
Message: <4af61dad@news.povray.org>
On 11/7/2009 7:41 PM, SharkD wrote:
> Is there a way to adjust the transparency without modifying the images
> themselves? Thanks!
>
> Mike

Nevermind. It tells how to do it in the docs.

Mike


Post a reply to this message

From: clipka
Subject: Re: Changing image maps' transparency?
Date: 7 Nov 2009 20:35:46
Message: <4af62072@news.povray.org>
SharkD schrieb:
> Is there a way to adjust the transparency without modifying the images 
> themselves? Thanks!

Well, yes and no...

 From the documentation:

------
You can give the entire image a filter or transmit value using filter 
all Amount or transmit all Amount. For example:

   image_map {
     gif "stnglass.gif"
     filter all 0.9
   }
------

However, this does not /adjust/, but rather /override/ an image's alpha 
channel. For more sophisticated tampering with the transparency, you'll 
need to mix multiple variants of your image, governed by the image's 
alpha channel, such as:

   pigment {
     image_pattern { png "foo.png" use_alpha }
     pigment_map {
       [0.0 image_map { png "foo.png" transmit all 0.2 }]
       [0.5 image_map { png "foo.png" transmit all 0.3 }]
       [1.0 image_map { png "foo.png" transmit all 0.7 }]
     }
   }

Note however that this will drastically increase the memory footprint 
(in the example, the image is loaded 4 times); if this is an issue, you 
may instead want to use functions and averaging to compose the image, 
such as:

   #declare PgFoo = pigment { png "foo.png" }
   #declare FnFoo = function { pigment { PgFoo } }

   pigment {
     average
     pigment_map {
       [1.0
         function { FnFoo(x,y,z).red }
         color_map { [0 rgbt 0][1 red 4] }
       ]
       [1.0
         function { FnFoo(x,y,z).green }
         color_map { [0 rgbt 0][1 green 4] }
       ]
       [1.0
         function { FnFoo(x,y,z).blue }
         color_map { [0 rgbt 0][1 blue 4] }
       ]
       [1.0
         function { FnFoo(x,y,z).transmit }
         color_map {
           [0.0 transmit 4 * 0.2]
           [0.5 transmit 4 * 0.3]
           [1.0 transmit 4 * 0.7]
         }
       ]
     }
   }

which does the same, but loads the image only once, probably at some 
speed disadvantage.


Post a reply to this message

From: SharkD
Subject: Re: Changing image maps' transparency?
Date: 8 Nov 2009 02:36:06
Message: <4af674e6$1@news.povray.org>
On 11/7/2009 8:35 PM, clipka wrote:
> SharkD schrieb:
>> Is there a way to adjust the transparency without modifying the images
>> themselves? Thanks!
>
> Well, yes and no...
>
>  From the documentation:
>
> ------
> You can give the entire image a filter or transmit value using filter
> all Amount or transmit all Amount. For example:
>...
> However, this does not /adjust/, but rather /override/ an image's alpha
> channel. For more sophisticated tampering with the transparency, you'll
> need to mix multiple variants of your image, governed by the image's
> alpha channel, such as:
>...
> which does the same, but loads the image only once, probably at some
> speed disadvantage.

Thanks for the tip.

Mike


Post a reply to this message

From: Kenneth
Subject: Re: Changing image maps' transparency?
Date: 9 Dec 2009 09:05:00
Message: <web.4b1fade36cafa19665f302820@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Well, yes and no...
>

Just came across this post. THANKS, Clipka, for explaining some great
workarounds to this situation, which I'll be trying out ASAP. The inability to
use 'transmit all' with alpha-channel images has been a stumbling block for me
for quite awhile.

The funny thing is, it *does* work as intended with 'typical' image_maps (those
with no alpha channel, like .bmp or .jpeg images.) I would assume that transmit
all has a bug of some sort at present, since the docs seem to indicate that it
can be used successfully with *any* type of image_map. Further assuming that
it's a problem related to transparency in general(?)

Again, thanks!

Ken


Post a reply to this message

From: Kenneth
Subject: Re: Changing image maps' transparency?
Date: 16 Dec 2009 06:05:01
Message: <web.4b28baf16cafa19665f302820@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> Is there a way to adjust the transparency without modifying the images
> themselves? Thanks!
>

I forgot to mention a rather simple technique I came up with awhile ago. (I'm
somewhat embarrassed to admit that I didn't remember it in relation to your
question until now--even though I use it quite frequently! Sometimes I forget
techniques I've used in the past, and end up 'reinventing the wheel'...)

It's probably not as visually correct as clipka's ideas, but works well enough
in many situations. It uses a simple pigment_map:

pigment{
     average
     pigment_map{
             [1.0 png "my_image.png"] // has alpha-channel transparency
             [1.0 rgbt <.5,.5,.5,1>] // fully transparent
                }
       }

Adjust the 'weighting' of the rgbt color to get the amount of transparency you
want.  The drawback is that the 'color' of the rgbt pigment is slightly imposed
on the 'real' part of the image_map, depending on the 'weighting.' (Though NOT
on the *transparent* parts of the alpha-channel image--they remains fully
transparent.)  Through experience, I chose rgbt <.5,.5,.5,1> (a 'transparent
gray') as it seems to have the least visual impact on the image_map.

Ken


Post a reply to this message

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