|
![](/i/fill.gif) |
Wasn't it tahoma who wrote:
>Mike Williams <nos### [at] econym demon co uk> wrote:
>> 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]
>> }
>> }
>> }
>
>Whoa, pretty nice :)
>
>I tried it and it works great but only with non uv mapped image_maps. When
>using "uv_mapping" povray complains with "The 'uv_mapping' pattern cannot
>be used as part of a pigment function!". Nevertheless, I never was so close
>to the solution, thank you so far.
You're probably just putting the "uv_mapping" keyword in the wrong
place. Don't do the uv_mapping when you define the pigment functions, do
it when you apply the complete texture to the object.
sphere {0,1
texture {uv_mapping
pigment {average
pigment_map {
[1 R]
[1 G]
[1 B]
}
}
}
}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |