POV-Ray : Newsgroups : povray.newusers : Complex blending between multiple image_maps : Re: Complex blending between multiple image_maps Server Time
29 Jul 2024 16:23:25 EDT (-0400)
  Re: Complex blending between multiple image_maps  
From: Mike Williams
Date: 22 Jul 2005 17:17:21
Message: <IB+x$GAlIW4CFwST@econym.demon.co.uk>
Wasn't it Eric James who wrote:
>
>The closest I can see would be to use custom functions to do it, which is
>above my knowledge level without a bit of further guidance or examples, for
>which I would be extremely appreciative.

It's not easy. What you have to do is this:

Declare pigment functions from the two image maps

#declare IM1 = function {pigment {image_map {jpeg "tex1.jpg" interpolate 2}}}
#declare IM2 = function {pigment {image_map {jpeg "tex2.jpg" interpolate 2}}}

Perform separate mathematical operations on the red, green and blue channels, to
produce three blended pigments, one for each colour channel. These pigment
functions need to have a colour_map that triples the brightness (see later).

You can perform whatever arithmetic operations you want here. I'm just going to
add them.

#declare R = pigment {function {IM1(x,y,z).red + IM2(x,y,z).red}
   colour_map{[0 rgb 0][1 rgb <3,0,0>]}}

#declare G = pigment {function {IM1(x,y,z).green + IM2(x,y,z).green}
   colour_map{[0 rgb 0][1 rgb <0,3,0>]}}

#declare B = pigment {function {IM1(x,y,z).blue + IM2(x,y,z).blue}
   colour_map{[0 rgb 0][1 rgb <0,0,3>]}}

Finally assemble the three component pigments using an "average" pigment_map.
By averaging three pigments that are on different colour channels, the
brightness gets divided by 3. That's why we tripled the brightness earlier. 
E.g. if the output colour of a particular pixel is white, we'd get that by the
fact that (<3,0,0> + <0,3,0> + <0,0,3>)/3 = <1,1,1>.

sphere {0,1
  pigment {average
    pigment_map {
      [1 R]
      [1 G]
      [1 B]
    }
  }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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