POV-Ray : Newsgroups : povray.general : how to make image_map (tga) non transparent : Re: how to make image_map (tga) non transparent Server Time
19 Nov 2024 09:41:32 EST (-0500)
  Re: how to make image_map (tga) non transparent  
From: PeterC
Date: 31 Mar 2002 12:32:22
Message: <3ca7481a.7559558@localhost>
On Fri, 29 Mar 2002 17:03:25 +0100, "Sebastian H." <seb### [at] webde>
wrote:

>Hi there
>
>I'am playing around with image maps and cannot disable the transparency 
>of a mapped tga.
>

If you are using 3.5, try:


#macro remove_trans(pig_in)
  #local f1 = function {
    pigment { pig_in }
  }
  #local p_out = pigment {
    average
    pigment_map {
      [ 1
        function { f1(x, y, z).red }
        color_map {
          [ 0.0 color rgb 0 ]
          [ 1.0 color rgb <3, 0, 0> ]
        }
      ]
      [ 1
        function { f1(x, y, z).green }
        color_map {
          [ 0.0 color rgb 0 ]
          [ 1.0 color rgb <0, 3, 0> ]
        }
      ]
      [ 1
        function { f1(x, y, z).blue }
        color_map {
          [ 0.0 color rgb 0 ]
          [ 1.0 color rgb <0, 0, 3> ]
        }
      ]
    }
  }
  p_out
#end


You'de call it something like:

#declare non_trans = pigment {
  remove_trans(
    pigment {
      image_map {
        tga "my_tga32_w_alpha.tga"
      }
    }
  )
}


What is going on there is that it breaks the image into
three functions, one for red, one for green, one for
blue.  In this way we ignore the fourth (alpha) channel.
The average function is used to add the R, G, and B 
channels back together, without the alpha.
This technique could also be used to extract the alpha
channel and make is visable/usable on its own.  This
last I will leave as an exercise for the reader.  :)


Post a reply to this message

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