POV-Ray : Newsgroups : povray.advanced-users : Image alpha channel without pigment? Server Time
24 Nov 2024 01:49:27 EST (-0500)
  Image alpha channel without pigment? (Message 1 to 2 of 2)  
From: CShake
Subject: Image alpha channel without pigment?
Date: 30 Mar 2010 12:04:36
Message: <4bb22114$1@news.povray.org>
I'm currently using some functions that someone here wrote (sorry, 
forget who) for scaling the pigments loaded a file (applying a hue, 
etc), but I find that this method seems to completely strip any alpha 
data that the image could have had.

What I'm wondering is if I can somehow either not strip this alpha data 
and still be able to do mathematical functions on the raw rgb values, or 
apply an alpha channel from an image to an existing pigment_map? I am 
able to apply a pigment-wide transmit value, but I need to be able to 
change the alpha based on position.

The pigments are used in uv mapped textures, if that makes any 
difference. The scaling code I'm using is as follows:

------------------------------------
//The parts in the #if(scale2.t>0) blocks are my attempt at not removing 
  the alpha channel if it exists, but it didn't work.

#macro from_black(COLOR)
color_map
{
   [0 color rgb <0,0,0>]
   [1 color COLOR]
}
#end

#macro pigment_scale(PIGMENT, SCALE)
#local scale2 = SCALE+<0,0,0,0>;
#local F = function { pigment {PIGMENT} }
#if(scale2.t>0)
   #local mult=4;
#else
   #local mult=3;
#end
#local R = pigment {function {F(x,y,z).red} 
from_black(mult*SCALE*<1,0,0>) }
#local G = pigment {function {F(x,y,z).green} 
from_black(mult*SCALE*<0,1,0>) }
#local B = pigment {function {F(x,y,z).blue} 
from_black(mult*SCALE*<0,0,1>) }
#local T = pigment { color rgbt mult*<0,0,0,scale2.t>}
#if(scale2.t>0)
   pigment {average pigment_map {[R] [G] [B] [T]} }
#else
   pigment {average pigment_map {[R] [G] [B]}}
#end
#end

#declare deftexmult = <0.6,0.6,0.6>;

#macro tga_scale(IMAGE,SCALE)
   #local scale2 = SCALE+<0,0,0,0>;
   #local imagemap = pigment{
     image_map{
       tga IMAGE
       map_type 0
       interpolate 2
       #if(scale2.t>0)
         transmit all scale2.t
//      #debug concat("transmit all ",str(scale2.t,1,2),"\n")
       #end
     }
   }
   pigment_scale(imagemap,scale2)
#end


Post a reply to this message

From: CShake
Subject: Re: Image alpha channel without pigment?
Date: 30 Mar 2010 12:19:55
Message: <4bb224ab$1@news.povray.org>
Forgot to mention that the .tga images I'm using do have an alpha 
channel and it works if I just include them in a normal 
pigment{image_map{}} block, so it's not an issue with them not being the 
right format or povray not being able to read the channel.

Chris


Post a reply to this message

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