|
|
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
|
|