|
![](/i/fill.gif) |
Wasn't it tahoma who wrote:
>I started with povray some days ago to convert some realtime scenes to
>povray files. After reading the documentation again and again i wondered if
>it would be possible to define materials or textures just like in OpenGL,
>3dsMax and so on.
>
>E.g. the modulation of an image_map color with a constant color:
>pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
>color.green, image_map[u,v].blue * color.blue>
This can be achieved with pigment functions, but it's a bit tricky.
Let there be a colour "C".
We first have to split the colour into its components, because the parser
doesn't like the syntax "C.red" in the next stage.
#declare Cr = C.red;
#declare Cg = C.green;
#declare Cb = C.blue;
Now define a pigment function from the image_map.
#declare IM = function {pigment {image_map {jpeg "tex.jpg" interpolate 2}}}
Then calculate three pigments that will be the components of the modulated
pigment. In this case the calculation is IM.red * C.red, which gives you the
pattern of the pigment. The pattern is then colour_mapped to the range black-
to-red (otherwise it ends up greyscale).
#declare R = pigment {function {IM(x,y,z).red * Cr}
colour_map {[0 rgb 0][1 rgb <1,0,0>]}}
#declare G = pigment {function {IM(x,y,z).green * Cg}
colour_map {[0 rgb 0][1 rgb <0,1,0>]}}
#declare B = pigment {function {IM(x,y,z).blue * Cb}
colour_map {[0 rgb 0][1 rgb <0,0,1>]}}
Then assemble the three components using an average pigment_map
sphere {0,1
pigment {average
pigment_map {
[1 R]
[1 G]
[1 B]
}
}
}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |