POV-Ray : Newsgroups : povray.general : Changing image maps' transparency? : Re: Changing image maps' transparency? Server Time
30 Jul 2024 04:15:45 EDT (-0400)
  Re: Changing image maps' transparency?  
From: clipka
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

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