POV-Ray : Newsgroups : povray.newusers : color modulation in textures : Re: color modulation in textures Server Time
29 Jul 2024 18:17:08 EDT (-0400)
  Re: color modulation in textures  
From: tahoma
Date: 11 May 2005 11:55:01
Message: <web.42822a7c9d44ff21929af40a0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> 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.

Is there another way or do i have to wait for a new povray version? Is this
a features already put on the roadmap of development?
This little feature seems so easy to implement and i wonder if nobody else
needed it in the past 10 years :o

Regards,
Jan


Post a reply to this message

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